Completed
Push — master ( 057712...43b720 )
by Yannick
10:00
created
require/class.SpotterImport.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -40,6 +40,10 @@
 block discarded – undo
40 40
 	}
41 41
     }
42 42
 
43
+    /**
44
+     * @param string $id
45
+     * @param string $ident
46
+     */
43 47
     public function get_Schedule($id,$ident) {
44 48
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 49
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class SpotterImport {
16
-    private $all_flights = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_flights = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $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']);
106
+			}
107
+			$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']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$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']));
116
-       }
116
+	   }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
119 119
 	$Translation->db = null;
@@ -128,78 +128,78 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 	  */
130 130
 	}
131
-    }
131
+	}
132 132
 
133
-    public function checkAll() {
133
+	public function checkAll() {
134 134
 	global $globalDebug, $globalNoImport;
135 135
 	if ($globalDebug) echo "Update last seen flights data...\n";
136 136
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137
-	    foreach ($this->all_flights as $key => $flight) {
137
+		foreach ($this->all_flights as $key => $flight) {
138 138
 		if (isset($this->all_flights[$key]['id'])) {
139
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
-    		    $Spotter = new Spotter($this->db);
141
-        	    $real_arrival = $this->arrival($key);
142
-        	    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']);
143
-        	}
144
-	    }
139
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
+				$Spotter = new Spotter($this->db);
141
+				$real_arrival = $this->arrival($key);
142
+				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']);
143
+			}
144
+		}
145
+	}
145 146
 	}
146
-    }
147 147
 
148
-    public function arrival($key) {
148
+	public function arrival($key) {
149 149
 	global $globalClosestMinDist, $globalDebug;
150 150
 	if ($globalDebug) echo 'Update arrival...'."\n";
151 151
 	$Spotter = new Spotter($this->db);
152
-        $airport_icao = '';
153
-        $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+		$airport_icao = '';
153
+		$airport_time = '';
154
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
-    	    if (isset($closestAirports[0])) {
158
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
-        	    $airport_icao = $closestAirports[0]['icao'];
160
-        	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
-        	    foreach ($closestAirports as $airport) {
164
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
-        		    $airport_icao = $airport['icao'];
166
-        		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
-        		    break;
169
-        		}
170
-        	    }
171
-        	} 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))) {
172
-        		$airport_icao = $closestAirports[0]['icao'];
173
-        		$airport_time = $this->all_flights[$key]['datetime'];
174
-        	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
-        	}
177
-    	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
-    	    }
156
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+			if (isset($closestAirports[0])) {
158
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
+				$airport_icao = $closestAirports[0]['icao'];
160
+				$airport_time = $this->all_flights[$key]['datetime'];
161
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
+				foreach ($closestAirports as $airport) {
164
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
+					$airport_icao = $airport['icao'];
166
+					$airport_time = $this->all_flights[$key]['datetime'];
167
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
+					break;
169
+				}
170
+				}
171
+			} 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))) {
172
+				$airport_icao = $closestAirports[0]['icao'];
173
+				$airport_time = $this->all_flights[$key]['datetime'];
174
+			} else {
175
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
+			}
177
+			} else {
178
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
+			}
180 180
 
181
-        } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
-        }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
-    }
181
+		} else {
182
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
+		}
184
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+	}
186 186
 
187 187
 
188 188
 
189
-    public function del() {
189
+	public function del() {
190 190
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 191
 	// Delete old infos
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194
-	    if (isset($flight['lastupdate'])) {
194
+		if (isset($flight['lastupdate'])) {
195 195
 		if ($flight['lastupdate'] < (time()-5900)) {
196
-		    $this->delKey($key);
196
+			$this->delKey($key);
197 197
 		}
198
-	    }
198
+		}
199
+	}
199 200
 	}
200
-    }
201 201
 
202
-    public function delKey($key) {
202
+	public function delKey($key) {
203 203
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 204
 	// Delete old infos
205 205
 	if (isset($this->all_flights[$key]['id'])) {
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 	}
216 216
 	unset($this->all_flights[$key]);
217
-    }
217
+	}
218 218
 
219
-    public function add($line) {
219
+	public function add($line) {
220 220
 	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;
221 221
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222 222
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -242,20 +242,20 @@  discard block
 block discarded – undo
242 242
 	
243 243
 	// SBS format is CSV format
244 244
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245
-	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
245
+		//print_r($line);
246
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 248
 
249 249
 		// Increment message number
250 250
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251
-		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
251
+			$current_date = date('Y-m-d');
252
+			if (isset($line['source_name'])) $source = $line['source_name'];
253
+			else $source = '';
254
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
256
+				$this->stats[$current_date][$source]['msg']['date'] = time();
257
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
259 259
 		}
260 260
 		
261 261
 		/*
@@ -271,54 +271,54 @@  discard block
 block discarded – undo
271 271
 		//$this->db = $dbc;
272 272
 
273 273
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
274
+			if (!isset($line['id'])) $id = trim($line['hex']);
275
+			else $id = trim($line['id']);
276 276
 		
277 277
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
279
-		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $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' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
-		    if (!isset($line['id'])) {
278
+			if ($globalDebug) echo 'New flight...'."\n";
279
+			$this->all_flights[$id] = array();
280
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
+			$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' => ''));
282
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
+			if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			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')));
286 286
 //			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')));
287 287
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
288
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
288
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+			if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
-		    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') {
301
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
+			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') {
303 303
 			$timeelapsed = microtime(true);
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305
-			    $Spotter = new Spotter($this->db);
306
-			    if (isset($this->all_flights[$id]['source_type'])) {
305
+				$Spotter = new Spotter($this->db);
306
+				if (isset($this->all_flights[$id]['source_type'])) {
307 307
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
308
-			    } else {
308
+				} else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310
-			    }
311
-			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
310
+				}
311
+				$Spotter->db = null;
312
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315
-		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
315
+			}
316
+			if ($globalAllFlights !== FALSE) $dataFound = true;
317
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319
-	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
-	        }
319
+			if (isset($line['id']) && !isset($line['hex'])) {
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
+			}
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
324 324
 			$Spotter = new Spotter($this->db);
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 		}
348 348
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
349 349
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
350
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
350
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
351 351
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
352
-		    } else {
352
+			} else {
353 353
 				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";
354 354
 				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";
355 355
 				/*
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 				print_r($line);
359 359
 				*/
360 360
 				return '';
361
-		    }
361
+			}
362 362
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
363 363
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
364 364
 			return '';
@@ -374,21 +374,21 @@  discard block
 block discarded – undo
374 374
 		}
375 375
 
376 376
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
377
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
377
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
378 378
 		}
379 379
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
380
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
380
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
381 381
 		}
382 382
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
383
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
383
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
384 384
 		}
385 385
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
386
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
386
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
387 387
 		}
388 388
  
389 389
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
390 390
 
391
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
391
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
392 392
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
393 393
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
394 394
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -397,23 +397,23 @@  discard block
 block discarded – undo
397 397
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
398 398
 				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']));
399 399
 			} else {
400
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
400
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402 402
 				$timeelapsed = microtime(true);
403
-            			$Spotter = new Spotter($this->db);
404
-            			$fromsource = NULL;
405
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
406
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
403
+						$Spotter = new Spotter($this->db);
404
+						$fromsource = NULL;
405
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
406
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
407 407
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
408 408
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
409 409
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
410
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
410
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
411 411
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
412 412
 				$Spotter->db = null;
413 413
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
-			    }
414
+				}
415 415
 			}
416
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
416
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
417 417
 		    
418 418
 /*
419 419
 		    if (!isset($line['id'])) {
@@ -423,63 +423,63 @@  discard block
 block discarded – undo
423 423
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
424 424
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
425 425
   */
426
-		    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']));
426
+			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']));
427 427
 
428
-		    //$putinarchive = true;
429
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
428
+			//$putinarchive = true;
429
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
430 430
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
431
-		    }
432
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
431
+			}
432
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
433 433
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
434
-		    }
435
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
434
+			}
435
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
438 438
 			$timeelapsed = microtime(true);
439 439
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
440 440
 				$Spotter = new Spotter($this->db);
441 441
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
442 442
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
443
-		    		$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' => ''));
443
+					$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' => ''));
444 444
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
-                        }
446
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
445
+						}
446
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447 447
 			$timeelapsed = microtime(true);
448 448
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
449
-			    $Spotter = new Spotter($this->db);
450
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
451
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
449
+				$Spotter = new Spotter($this->db);
450
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
451
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
452 452
 				$Translation = new Translation($this->db);
453 453
 				$ident = $Translation->checkTranslation(trim($line['ident']));
454 454
 				$route = $Spotter->getRouteInfo($ident);
455 455
 				$Translation->db = null;
456
-			    }
457
-			    $Spotter->db = null;
458
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
-                    	}
456
+				}
457
+				$Spotter->db = null;
458
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
+						}
460 460
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
461
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
461
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
463 463
 				//    $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']));
464
-		    		$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']));
465
-		    	    }
464
+					$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']));
465
+					}
466 466
 			}
467 467
 			if (!isset($globalFork)) $globalFork = TRUE;
468 468
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
469 469
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
470 470
 			}
471
-		    }
471
+			}
472 472
 		}
473 473
 
474 474
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
475 475
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
476
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
-		    //$dataFound = true;
476
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
+			//$dataFound = true;
479 479
 		} 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'])) {
480
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
-		    if ($distance > 1000 && $distance < 10000) {
482
-		    // use datetime
480
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
+			if ($distance > 1000 && $distance < 10000) {
482
+			// use datetime
483 483
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
484 484
 			$speed = $speed*3.6;
485 485
 			if ($speed < 1000) {
@@ -488,48 +488,48 @@  discard block
 block discarded – undo
488 488
 	  		} else {
489 489
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
490 490
 	  		}
491
-		    }
491
+			}
492 492
 		}
493 493
 
494 494
 
495 495
 
496
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
497
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
498
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499
-	    	    	return false;
500
-	    	    }
501
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
-	    	    else unset($timediff);
503
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
-	    	    else unset($timediff_archive);
505
-	    	    if ($this->tmd > 5
506
-	    	        || (isset($line['format_source']) 
507
-	    	    	    && $line['format_source'] == 'airwhere' 
508
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
509
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
510
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
511
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
512
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
513
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
514
-	    	    		)
515
-	    	    	    )
516
-	    	    	)
517
-	    		|| (isset($globalVA) && $globalVA) 
518
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
519
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
520
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
521
-	    	    	|| (isset($globalVAM) && $globalVAM)
522
-	    	    	|| !isset($timediff)
523
-	    	    	|| $timediff > $globalLiveInterval
524
-	    	    	|| ($timediff > 30 
525
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
526
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
527
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
528
-	    	    	    )
529
-	    	    	) {
496
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
497
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
498
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499
+					return false;
500
+				}
501
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
+				else unset($timediff);
503
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
+				else unset($timediff_archive);
505
+				if ($this->tmd > 5
506
+					|| (isset($line['format_source']) 
507
+						&& $line['format_source'] == 'airwhere' 
508
+						&& ((!isset($this->all_flights[$id]['latitude']) 
509
+						|| !isset($this->all_flights[$id]['longitude'])) 
510
+						|| (isset($this->all_flights[$id]['latitude']) 
511
+							&& isset($this->all_flights[$id]['longitude']) 
512
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
513
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
514
+						)
515
+						)
516
+					)
517
+				|| (isset($globalVA) && $globalVA) 
518
+					|| (isset($globalIVAO) && $globalIVAO)
519
+					|| (isset($globalVATSIM) && $globalVATSIM)
520
+					|| (isset($globalphpVMS) && $globalphpVMS)
521
+					|| (isset($globalVAM) && $globalVAM)
522
+					|| !isset($timediff)
523
+					|| $timediff > $globalLiveInterval
524
+					|| ($timediff > 30 
525
+						&& isset($this->all_flights[$id]['latitude']) 
526
+						&& isset($this->all_flights[$id]['longitude']) 
527
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
528
+						)
529
+					) {
530 530
 
531 531
 			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']))) {
532
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
532
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
533 533
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
534 534
 				|| !$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'])) {
535 535
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
538 538
 				$this->tmd = 0;
539 539
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
540
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
541
-				    $timeelapsed = microtime(true);
542
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
540
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
541
+					$timeelapsed = microtime(true);
542
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543 543
 					$Spotter = new Spotter($this->db);
544 544
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
545 545
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -547,11 +547,11 @@  discard block
 block discarded – undo
547 547
 					$Spotter->db = null;
548 548
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
549 549
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
550
-				    }
550
+					}
551 551
 				}
552 552
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
553
-			    } 
554
-			    /*
553
+				} 
554
+				/*
555 555
 			    else {
556 556
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
557 557
 				else {
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
 			}
566 566
 
567 567
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
568
-			    //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) {
568
+				//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) {
569 569
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
570 570
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
571 571
 					$this->all_flights[$id]['time_last_coord'] = time();
572 572
 				}
573 573
 				//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)) {
574 574
 				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)) {
575
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576
-				    $dataFound = true;
577
-				    $this->all_flights[$id]['time_last_coord'] = time();
575
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576
+					$dataFound = true;
577
+					$this->all_flights[$id]['time_last_coord'] = time();
578 578
 				}
579 579
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
580 580
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -585,24 +585,24 @@  discard block
 block discarded – undo
585 585
 				    //$putinarchive = true;
586 586
 				}
587 587
 				*/
588
-			    /*
588
+				/*
589 589
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
590 590
 				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";
591 591
 			    }
592 592
 			    */
593 593
 			}
594 594
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
595
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
596
-			    //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) {
595
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
596
+				//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) {
597 597
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
598 598
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
599 599
 					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				//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)) {
602 602
 				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)) {
603
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604
-				    $dataFound = true;
605
-				    $this->all_flights[$id]['time_last_coord'] = time();
603
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604
+					$dataFound = true;
605
+					$this->all_flights[$id]['time_last_coord'] = time();
606 606
 				}
607 607
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
608 608
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -620,67 +620,67 @@  discard block
 block discarded – undo
620 620
 			    */
621 621
 			}
622 622
 
623
-		    } else if ($globalDebug && $timediff > 30) {
623
+			} else if ($globalDebug && $timediff > 30) {
624 624
 			$this->tmd = $this->tmd + 1;
625 625
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
626 626
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
627 627
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
628 628
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
629
-		    }
629
+			}
630 630
 		}
631 631
 		if (isset($line['last_update']) && $line['last_update'] != '') {
632
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
632
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
634 634
 		}
635 635
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
637
-		    //$dataFound = true;
636
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
637
+			//$dataFound = true;
638 638
 		}
639 639
 		if (isset($line['format_source']) && $line['format_source'] != '') {
640
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
640
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
641 641
 		}
642 642
 		if (isset($line['source_name']) && $line['source_name'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
643
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
644 644
 		}
645 645
 		if (isset($line['emergency']) && $line['emergency'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
647
-		    //$dataFound = true;
646
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
647
+			//$dataFound = true;
648 648
 		}
649 649
 		if (isset($line['ground']) && $line['ground'] != '') {
650
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
650
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
651 651
 			// Here we force archive of flight because after ground it's a new one (or should be)
652 652
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
653 653
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
654 654
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
655
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
655
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
656 656
 			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']));
657
-		    }
658
-		    if ($line['ground'] != 1) $line['ground'] = 0;
659
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
660
-		    //$dataFound = true;
657
+			}
658
+			if ($line['ground'] != 1) $line['ground'] = 0;
659
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
660
+			//$dataFound = true;
661 661
 		}
662 662
 		if (isset($line['squawk']) && $line['squawk'] != '') {
663
-		    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'])) {
664
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
666
-			    $highlight = '';
667
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
669
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
670
-			    if ($highlight != '') {
663
+			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'])) {
664
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
666
+				$highlight = '';
667
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
669
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
670
+				if ($highlight != '') {
671 671
 				$timeelapsed = microtime(true);
672 672
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
673
-				    $Spotter = new Spotter($this->db);
674
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
675
-				    $Spotter->db = null;
676
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
673
+					$Spotter = new Spotter($this->db);
674
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
675
+					$Spotter->db = null;
676
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
677 677
 				}
678 678
 				//$putinarchive = true;
679 679
 				//$highlight = '';
680
-			    }
680
+				}
681 681
 			    
682
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
683
-		    //$dataFound = true;
682
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
683
+			//$dataFound = true;
684 684
 		}
685 685
 
686 686
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
 					$line['altitude'] = $line['altitude'] + $geoid;
692 692
 				}
693 693
 			}
694
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
694
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
695 695
 			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;
696 696
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
697 697
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
698 698
 			//$dataFound = true;
699
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
699
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
701 701
 			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) {
702 702
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
703 703
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -706,27 +706,27 @@  discard block
 block discarded – undo
706 706
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
707 707
 				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']));
708 708
 			}
709
-		    }
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
709
+			}
710
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
711 711
 		}
712 712
 
713 713
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
714
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
714
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
715 715
 		}
716 716
 		
717 717
 		if (isset($line['heading']) && $line['heading'] != '') {
718
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
-		    //$dataFound = true;
718
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
+			//$dataFound = true;
722 722
   		} 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']) {
723
-  		    $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']);
724
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
723
+  			$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']);
724
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
727 727
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
728
-  		    // If not enough messages and ACARS set heading to 0
729
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
728
+  			// If not enough messages and ACARS set heading to 0
729
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
730 730
   		}
731 731
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732 732
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -739,125 +739,125 @@  discard block
 block discarded – undo
739 739
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
740 740
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
741 741
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
742
-		    $this->all_flights[$id]['lastupdate'] = time();
743
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
-		        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'])) {
745
-			    //print_r($this->all_flights);
746
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
748
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
742
+			$this->all_flights[$id]['lastupdate'] = time();
743
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
+				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'])) {
745
+				//print_r($this->all_flights);
746
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
748
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
749 749
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
750
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
751
-				    $timeelapsed = microtime(true);
752
-				    $SpotterLive = new SpotterLive($this->db);
753
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
750
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
751
+					$timeelapsed = microtime(true);
752
+					$SpotterLive = new SpotterLive($this->db);
753
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
754 754
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
755 755
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
756
-				    } elseif (isset($line['id'])) {
756
+					} elseif (isset($line['id'])) {
757 757
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
758 758
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
759
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
759
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
760 760
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
761 761
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
762
-				    } else $recent_ident = '';
763
-				    $SpotterLive->db=null;
764
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
762
+					} else $recent_ident = '';
763
+					$SpotterLive->db=null;
764
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
766 766
 				} else $recent_ident = '';
767
-			    } else {
767
+				} else {
768 768
 				$recent_ident = '';
769 769
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
770
-			    }
771
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
-			    if($recent_ident == "")
773
-			    {
770
+				}
771
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
+				if($recent_ident == "")
773
+				{
774 774
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
775 775
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
776 776
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
777 777
 				//adds the spotter data for the archive
778 778
 				$ignoreImport = false;
779 779
 				foreach($globalAirportIgnore as $airportIgnore) {
780
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
780
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
781 781
 					$ignoreImport = true;
782
-				    }
782
+					}
783 783
 				}
784 784
 				if (count($globalAirportAccept) > 0) {
785
-				    $ignoreImport = true;
786
-				    foreach($globalAirportIgnore as $airportIgnore) {
785
+					$ignoreImport = true;
786
+					foreach($globalAirportIgnore as $airportIgnore) {
787 787
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788
-					    $ignoreImport = false;
788
+						$ignoreImport = false;
789
+					}
789 790
 					}
790
-				    }
791 791
 				}
792 792
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
793
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
793
+					foreach($globalAirlineIgnore as $airlineIgnore) {
794 794
 					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)) {
795
-					    $ignoreImport = true;
795
+						$ignoreImport = true;
796
+					}
796 797
 					}
797
-				    }
798 798
 				}
799 799
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
800
-				    $ignoreImport = true;
801
-				    foreach($globalAirlineAccept as $airlineAccept) {
800
+					$ignoreImport = true;
801
+					foreach($globalAirlineAccept as $airlineAccept) {
802 802
 					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)) {
803
-					    $ignoreImport = false;
803
+						$ignoreImport = false;
804
+					}
804 805
 					}
805
-				    }
806 806
 				}
807 807
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
808
-				    $ignoreImport = true;
809
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
808
+					$ignoreImport = true;
809
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
810 810
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
811
-					    $ignoreImport = false;
811
+						$ignoreImport = false;
812
+					}
812 813
 					}
813
-				    }
814 814
 				}
815 815
 				
816 816
 				if (!$ignoreImport) {
817
-				    $highlight = '';
818
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
-				    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')));
822
-				    $timeelapsed = microtime(true);
823
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
817
+					$highlight = '';
818
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
+					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')));
822
+					$timeelapsed = microtime(true);
823
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
824 824
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
825
-					    $Spotter = new Spotter($this->db);
826
-					    $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']);
827
-					    $Spotter->db = null;
828
-					    if ($globalDebug && isset($result)) echo $result."\n";
825
+						$Spotter = new Spotter($this->db);
826
+						$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']);
827
+						$Spotter->db = null;
828
+						if ($globalDebug && isset($result)) echo $result."\n";
829 829
 					}
830
-				    }
831
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
830
+					}
831
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833 833
 
834
-				    // Add source stat in DB
835
-				    $Stats = new Stats($this->db);
836
-				    if (!empty($this->stats)) {
834
+					// Add source stat in DB
835
+					$Stats = new Stats($this->db);
836
+					if (!empty($this->stats)) {
837 837
 					if ($globalDebug) echo 'Add source stats : ';
838
-				        foreach($this->stats as $date => $data) {
839
-					    foreach($data as $source => $sourced) {
840
-					        //print_r($sourced);
841
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
-				    		if (isset($sourced['msg'])) {
844
-				    		    if (time() - $sourced['msg']['date'] > 10) {
845
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
847
-			    			        unset($this->stats[$date][$source]['msg']);
848
-			    			    }
849
-			    			}
850
-			    		    }
851
-			    		    if ($date != date('Y-m-d')) {
852
-			    			unset($this->stats[$date]);
853
-			    		    }
854
-				    	}
855
-				    	if ($globalDebug) echo 'Done'."\n";
838
+						foreach($this->stats as $date => $data) {
839
+						foreach($data as $source => $sourced) {
840
+							//print_r($sourced);
841
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
+							if (isset($sourced['msg'])) {
844
+								if (time() - $sourced['msg']['date'] > 10) {
845
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
847
+									unset($this->stats[$date][$source]['msg']);
848
+								}
849
+							}
850
+							}
851
+							if ($date != date('Y-m-d')) {
852
+							unset($this->stats[$date]);
853
+							}
854
+						}
855
+						if ($globalDebug) echo 'Done'."\n";
856 856
 
857
-				    }
858
-				    $Stats->db = null;
859
-				    }
860
-				    $this->del();
857
+					}
858
+					$Stats->db = null;
859
+					}
860
+					$this->del();
861 861
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
862 862
 				//$ignoreImport = false;
863 863
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -875,41 +875,41 @@  discard block
 block discarded – undo
875 875
 			*/
876 876
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
877 877
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
878
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
879
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
880
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
878
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
879
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
880
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
881 881
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
882
-					    $SpotterLive = new SpotterLive($this->db);
883
-					    $SpotterLive->deleteLiveSpotterData();
884
-					    $SpotterLive->db=null;
882
+						$SpotterLive = new SpotterLive($this->db);
883
+						$SpotterLive->deleteLiveSpotterData();
884
+						$SpotterLive->db=null;
885 885
 					}
886
-				    }
887
-				    if ($globalDebug) echo " Done\n";
888
-				    $this->last_delete = time();
886
+					}
887
+					if ($globalDebug) echo " Done\n";
888
+					$this->last_delete = time();
889 889
 				}
890
-			    } else {
890
+				} else {
891 891
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
892
-				    $this->all_flights[$id]['id'] = $recent_ident;
893
-				    $this->all_flights[$id]['addedSpotter'] = 1;
892
+					$this->all_flights[$id]['id'] = $recent_ident;
893
+					$this->all_flights[$id]['addedSpotter'] = 1;
894 894
 				}
895 895
 				if (isset($globalDaemon) && !$globalDaemon) {
896
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
896
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897 897
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
898
-					    $Spotter = new Spotter($this->db);
899
-					    $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']);
900
-					    $Spotter->db = null;
898
+						$Spotter = new Spotter($this->db);
899
+						$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']);
900
+						$Spotter->db = null;
901
+					}
901 902
 					}
902
-				    }
903 903
 				}
904 904
 				
905
-			    }
905
+				}
906 906
 			}
907
-		    }
908
-		    //adds the spotter LIVE data
909
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
910
-		    //echo "\nAdd in Live !! \n";
911
-		    //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";
912
-		    if ($globalDebug) {
907
+			}
908
+			//adds the spotter LIVE data
909
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
910
+			//echo "\nAdd in Live !! \n";
911
+			//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";
912
+			if ($globalDebug) {
913 913
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
914 914
 				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";
915 915
 				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";
@@ -917,60 +917,60 @@  discard block
 block discarded – undo
917 917
 				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";
918 918
 				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";
919 919
 			}
920
-		    }
921
-		    $ignoreImport = false;
922
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
920
+			}
921
+			$ignoreImport = false;
922
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
924 924
 
925
-		    foreach($globalAirportIgnore as $airportIgnore) {
926
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927
-			    $ignoreImport = true;
925
+			foreach($globalAirportIgnore as $airportIgnore) {
926
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927
+				$ignoreImport = true;
928
+			}
928 929
 			}
929
-		    }
930
-		    if (count($globalAirportAccept) > 0) {
931
-		        $ignoreImport = true;
932
-		        foreach($globalAirportIgnore as $airportIgnore) {
933
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930
+			if (count($globalAirportAccept) > 0) {
931
+				$ignoreImport = true;
932
+				foreach($globalAirportIgnore as $airportIgnore) {
933
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
934 934
 				$ignoreImport = false;
935
-			    }
935
+				}
936 936
 			}
937
-		    }
938
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
937
+			}
938
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
939 939
 			foreach($globalAirlineIgnore as $airlineIgnore) {
940
-			    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)) {
940
+				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)) {
941 941
 				$ignoreImport = true;
942
-			    }
942
+				}
943 943
 			}
944
-		    }
945
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
944
+			}
945
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
946 946
 			$ignoreImport = true;
947 947
 			foreach($globalAirlineAccept as $airlineAccept) {
948
-			    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)) {
948
+				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)) {
949 949
 				$ignoreImport = false;
950
-			    }
950
+				}
951
+			}
951 952
 			}
952
-		    }
953
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
953
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
954 954
 			$ignoreImport = true;
955 955
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
956
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957
-			        $ignoreImport = false;
958
-			    }
956
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957
+					$ignoreImport = false;
958
+				}
959
+			}
959 960
 			}
960
-		    }
961 961
 
962
-		    if (!$ignoreImport) {
962
+			if (!$ignoreImport) {
963 963
 			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'])) {
964 964
 				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')));
965 965
 				$timeelapsed = microtime(true);
966 966
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
967
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
967
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
968 968
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
969 969
 					$SpotterLive = new SpotterLive($this->db);
970 970
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['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']);
971 971
 					$SpotterLive->db = null;
972 972
 					if ($globalDebug) echo $result."\n";
973
-				    }
973
+					}
974 974
 				}
975 975
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
976 976
 					$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']);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 				//if ($line['format_source'] != 'aprs') {
983 983
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
984 984
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
985
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
985
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
986 986
 					$source = $this->all_flights[$id]['source_name'];
987 987
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
988 988
 					if (!isset($this->source_location[$source])) {
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 					if ($stats_heading == 16) $stats_heading = 0;
1009 1009
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1010 1010
 						for ($i=0;$i<=15;$i++) {
1011
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1011
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1012 1012
 						}
1013 1013
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1014 1014
 					} else {
@@ -1021,17 +1021,17 @@  discard block
 block discarded – undo
1021 1021
 					//var_dump($this->stats);
1022 1022
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1023 1023
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1024
-						    end($this->stats[$current_date][$source]['hist']);
1025
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1024
+							end($this->stats[$current_date][$source]['hist']);
1025
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1026 1026
 						} else $mini = 0;
1027 1027
 						for ($i=$mini;$i<=$distance;$i+=10) {
1028
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1028
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1029 1029
 						}
1030 1030
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1031 1031
 					} else {
1032 1032
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1033 1033
 					}
1034
-				    }
1034
+					}
1035 1035
 				}
1036 1036
 
1037 1037
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 			//$this->del();
1042 1042
 			
1043 1043
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1044
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1044
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1045 1045
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1046 1046
 				$SpotterLive = new SpotterLive($this->db);
1047 1047
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1049,19 +1049,19 @@  discard block
 block discarded – undo
1049 1049
 				//SpotterLive->deleteLiveSpotterData();
1050 1050
 				if ($globalDebug) echo " Done\n";
1051 1051
 				$this->last_delete_hourly = time();
1052
-			    } else {
1052
+				} else {
1053 1053
 				$this->del();
1054 1054
 				$this->last_delete_hourly = time();
1055
-			    }
1055
+				}
1056 1056
 			}
1057 1057
 			
1058
-		    }
1059
-		    //$ignoreImport = false;
1058
+			}
1059
+			//$ignoreImport = false;
1060 1060
 		}
1061 1061
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1062 1062
 		if ($send) return $this->all_flights[$id];
1063
-	    }
1063
+		}
1064
+	}
1064 1065
 	}
1065
-    }
1066 1066
 }
1067 1067
 ?>
Please login to merge, or discard this patch.
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid : $e \n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $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']);
107
+		    $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']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$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']));
115
+		$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']));
116 116
        }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 140
     		    $Spotter = new Spotter($this->db);
141 141
         	    $real_arrival = $this->arrival($key);
142
-        	    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']);
142
+        	    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']);
143 143
         	}
144 144
 	    }
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $airport_time = '';
154 154
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
156
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
157 157
     	    if (isset($closestAirports[0])) {
158 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 159
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         		    break;
169 169
         		}
170 170
         	    }
171
-        	} 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))) {
171
+        	} 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))) {
172 172
         		$airport_icao = $closestAirports[0]['icao'];
173 173
         		$airport_time = $this->all_flights[$key]['datetime'];
174 174
         	} else {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         } else {
182 182
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183 183
         }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
184
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
185 185
     }
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194 194
 	    if (isset($flight['lastupdate'])) {
195
-		if ($flight['lastupdate'] < (time()-5900)) {
195
+		if ($flight['lastupdate'] < (time() - 5900)) {
196 196
 		    $this->delKey($key);
197 197
 		}
198 198
 	    }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$real_arrival = $this->arrival($key);
209 209
 			$Spotter = new Spotter($this->db);
210 210
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211
-				$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']);
211
+				$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']);
212 212
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213 213
 			}
214 214
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$send = false;
242 242
 	
243 243
 	// SBS format is CSV format
244
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
244
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 245
 	    //print_r($line);
246 246
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247 247
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
 		if (!isset($this->all_flights[$id])) {
278 278
 		    if ($globalDebug) echo 'New flight...'."\n";
279 279
 		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $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' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
281
+		    $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' => ''));
282
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
283 283
 		    if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			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')));
286 286
 //			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')));
287
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
287
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
288 288
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
289
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
290 290
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
298
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
299 299
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 301
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -304,27 +304,27 @@  discard block
 block discarded – undo
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 			    $Spotter = new Spotter($this->db);
306 306
 			    if (isset($this->all_flights[$id]['source_type'])) {
307
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
307
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
308 308
 			    } else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 310
 			    }
311 311
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
312
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
313
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315 315
 		    }
316 316
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
317 317
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319 319
 	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
321 321
 	        }
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
324 324
 			$Spotter = new Spotter($this->db);
325 325
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
326 326
 			$Spotter->db = null;
327
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
327
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
328 328
 		}
329 329
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
330 330
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				$Spotter = new Spotter($this->db);
333 333
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
334 334
 				$Spotter->db = null;
335
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
335
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
336 336
 			}
337 337
 		}
338 338
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
341 341
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
342 342
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
343
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
343
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
344 344
 		}
345 345
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
346
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
346
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
347 347
 		}
348 348
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
349
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
349
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
350 350
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
351
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
352 352
 		    } else {
353 353
 				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";
354 354
 				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";
@@ -359,31 +359,31 @@  discard block
 block discarded – undo
359 359
 				*/
360 360
 				return '';
361 361
 		    }
362
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
362
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
363 363
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
364 364
 			return '';
365
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
365
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
366 366
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
367 367
 			return '';
368 368
 		} elseif (!isset($line['datetime'])) {
369 369
 			date_default_timezone_set('UTC');
370
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
370
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
371 371
 		} else {
372 372
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
373 373
 			return '';
374 374
 		}
375 375
 
376 376
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
377
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
377
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
378 378
 		}
379 379
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
380
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
380
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
381 381
 		}
382 382
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
383
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
383
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
384 384
 		}
385 385
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
386
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
386
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
387 387
 		}
388 388
  
389 389
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
392 392
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
393 393
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
394
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
395
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
396
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
397
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
398
-				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']));
394
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
395
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
396
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
397
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
398
+				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']));
399 399
 			} else {
400
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
400
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
401 401
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402 402
 				$timeelapsed = microtime(true);
403 403
             			$Spotter = new Spotter($this->db);
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
408 408
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
409 409
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
410
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
410
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
411 411
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
412 412
 				$Spotter->db = null;
413
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
413
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
414 414
 			    }
415 415
 			}
416
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
416
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
417 417
 		    
418 418
 /*
419 419
 		    if (!isset($line['id'])) {
@@ -423,25 +423,25 @@  discard block
 block discarded – undo
423 423
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
424 424
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
425 425
   */
426
-		    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']));
426
+		    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']));
427 427
 
428 428
 		    //$putinarchive = true;
429 429
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
430
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
430
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
431 431
 		    }
432 432
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
433
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
433
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
434 434
 		    }
435 435
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
436
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
437 437
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
438 438
 			$timeelapsed = microtime(true);
439 439
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
440 440
 				$Spotter = new Spotter($this->db);
441 441
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
442 442
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
443
-		    		$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' => ''));
444
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
443
+		    		$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' => ''));
444
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
445 445
                         }
446 446
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447 447
 			$timeelapsed = microtime(true);
@@ -455,35 +455,35 @@  discard block
 block discarded – undo
455 455
 				$Translation->db = null;
456 456
 			    }
457 457
 			    $Spotter->db = null;
458
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
458
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
459 459
                     	}
460 460
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
461 461
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462 462
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
463 463
 				//    $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']));
464
-		    		$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']));
464
+		    		$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']));
465 465
 		    	    }
466 466
 			}
467 467
 			if (!isset($globalFork)) $globalFork = TRUE;
468 468
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
469
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
469
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
470 470
 			}
471 471
 		    }
472 472
 		}
473 473
 
474 474
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
475 475
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
476
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
476
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
477
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
478 478
 		    //$dataFound = true;
479 479
 		} 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'])) {
480
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
480
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
481 481
 		    if ($distance > 1000 && $distance < 10000) {
482 482
 		    // use datetime
483 483
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
484 484
 			$speed = $speed*3.6;
485 485
 			if ($speed < 1000) {
486
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
486
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
487 487
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
488 488
 	  		} else {
489 489
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499 499
 	    	    	return false;
500 500
 	    	    }
501
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
501
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
502 502
 	    	    else unset($timediff);
503
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
503
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
504 504
 	    	    else unset($timediff_archive);
505 505
 	    	    if ($this->tmd > 5
506 506
 	    	        || (isset($line['format_source']) 
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 	    	    	|| ($timediff > 30 
525 525
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
526 526
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
527
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
527
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
528 528
 	    	    	    )
529 529
 	    	    	) {
530 530
 
531 531
 			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']))) {
532 532
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
533 533
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
534
-				|| !$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'])) {
534
+				|| !$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'])) {
535 535
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
536 536
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 				    $timeelapsed = microtime(true);
542 542
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543 543
 					$Spotter = new Spotter($this->db);
544
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
544
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
545 545
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
546 546
 					else $this->all_flights[$id]['over_country'] = '';
547 547
 					$Spotter->db = null;
548
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
548
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
549 549
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
550 550
 				    }
551 551
 				}
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 					$this->all_flights[$id]['time_last_coord'] = time();
572 572
 				}
573 573
 				//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)) {
574
-				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)) {
574
+				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)) {
575 575
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576 576
 				    $dataFound = true;
577 577
 				    $this->all_flights[$id]['time_last_coord'] = time();
578 578
 				}
579 579
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
580
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
580
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
581 581
 				/*
582 582
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
583 583
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				//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)) {
602
-				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)) {
602
+				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)) {
603 603
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604 604
 				    $dataFound = true;
605 605
 				    $this->all_flights[$id]['time_last_coord'] = time();
606 606
 				}
607 607
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
608
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
608
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
609 609
 				/*
610 610
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
611 611
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -623,46 +623,46 @@  discard block
 block discarded – undo
623 623
 		    } else if ($globalDebug && $timediff > 30) {
624 624
 			$this->tmd = $this->tmd + 1;
625 625
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
626
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
627
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
626
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
627
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
628 628
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
629 629
 		    }
630 630
 		}
631 631
 		if (isset($line['last_update']) && $line['last_update'] != '') {
632 632
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
633
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
634 634
 		}
635 635
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
637 637
 		    //$dataFound = true;
638 638
 		}
639 639
 		if (isset($line['format_source']) && $line['format_source'] != '') {
640
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
640
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
641 641
 		}
642 642
 		if (isset($line['source_name']) && $line['source_name'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
643
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
644 644
 		}
645 645
 		if (isset($line['emergency']) && $line['emergency'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
646
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
647 647
 		    //$dataFound = true;
648 648
 		}
649 649
 		if (isset($line['ground']) && $line['ground'] != '') {
650 650
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
651 651
 			// Here we force archive of flight because after ground it's a new one (or should be)
652
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
653
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
654
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
655
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
656
-			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']));
652
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
653
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
654
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
655
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
656
+			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']));
657 657
 		    }
658 658
 		    if ($line['ground'] != 1) $line['ground'] = 0;
659
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
659
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
660 660
 		    //$dataFound = true;
661 661
 		}
662 662
 		if (isset($line['squawk']) && $line['squawk'] != '') {
663 663
 		    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'])) {
664 664
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
665
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
666 666
 			    $highlight = '';
667 667
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668 668
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -671,66 +671,66 @@  discard block
 block discarded – undo
671 671
 				$timeelapsed = microtime(true);
672 672
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
673 673
 				    $Spotter = new Spotter($this->db);
674
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
674
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
675 675
 				    $Spotter->db = null;
676
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
676
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
677 677
 				}
678 678
 				//$putinarchive = true;
679 679
 				//$highlight = '';
680 680
 			    }
681 681
 			    
682
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
682
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
683 683
 		    //$dataFound = true;
684 684
 		}
685 685
 
686 686
 		if (isset($line['altitude']) && $line['altitude'] != '') {
687 687
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
688 688
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
689
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
689
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
690 690
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
691 691
 					$line['altitude'] = $line['altitude'] + $geoid;
692 692
 				}
693 693
 			}
694 694
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
695
-			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;
696
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
697
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
695
+			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;
696
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
697
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
698 698
 			//$dataFound = true;
699 699
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700 700
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
701 701
 			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) {
702 702
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
703
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
704
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
705
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
706
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
707
-				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']));
703
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
704
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
705
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
706
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
707
+				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']));
708 708
 			}
709 709
 		    }
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
710
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
711 711
 		}
712 712
 
713 713
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
714
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
714
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
715 715
 		}
716 716
 		
717 717
 		if (isset($line['heading']) && $line['heading'] != '') {
718
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
718
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
720
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
721 721
 		    //$dataFound = true;
722 722
   		} 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']) {
723
-  		    $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']);
724
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
723
+  		    $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']);
724
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
725
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726 726
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
727 727
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
728 728
   		    // If not enough messages and ACARS set heading to 0
729
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
729
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
730 730
   		}
731
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
733
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
731
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
733
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
734 734
 
735 735
 //		print_r($this->all_flights[$id]);
736 736
 		//gets the callsign from the last hour
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
742 742
 		    $this->all_flights[$id]['lastupdate'] = time();
743 743
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
-		        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'])) {
744
+		        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'])) {
745 745
 			    //print_r($this->all_flights);
746 746
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747 747
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -752,61 +752,61 @@  discard block
 block discarded – undo
752 752
 				    $SpotterLive = new SpotterLive($this->db);
753 753
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
754 754
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
755
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
755
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
756 756
 				    } elseif (isset($line['id'])) {
757 757
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
758
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
759 759
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
760 760
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
761
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
762 762
 				    } else $recent_ident = '';
763
-				    $SpotterLive->db=null;
763
+				    $SpotterLive->db = null;
764 764
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765 765
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
766 766
 				} else $recent_ident = '';
767 767
 			    } else {
768 768
 				$recent_ident = '';
769
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
769
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
770 770
 			    }
771 771
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
-			    if($recent_ident == "")
772
+			    if ($recent_ident == "")
773 773
 			    {
774 774
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
775 775
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
776 776
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
777 777
 				//adds the spotter data for the archive
778 778
 				$ignoreImport = false;
779
-				foreach($globalAirportIgnore as $airportIgnore) {
779
+				foreach ($globalAirportIgnore as $airportIgnore) {
780 780
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
781 781
 					$ignoreImport = true;
782 782
 				    }
783 783
 				}
784 784
 				if (count($globalAirportAccept) > 0) {
785 785
 				    $ignoreImport = true;
786
-				    foreach($globalAirportIgnore as $airportIgnore) {
786
+				    foreach ($globalAirportIgnore as $airportIgnore) {
787 787
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788 788
 					    $ignoreImport = false;
789 789
 					}
790 790
 				    }
791 791
 				}
792 792
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
793
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
794
-					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)) {
793
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
794
+					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)) {
795 795
 					    $ignoreImport = true;
796 796
 					}
797 797
 				    }
798 798
 				}
799 799
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
800 800
 				    $ignoreImport = true;
801
-				    foreach($globalAirlineAccept as $airlineAccept) {
802
-					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)) {
801
+				    foreach ($globalAirlineAccept as $airlineAccept) {
802
+					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)) {
803 803
 					    $ignoreImport = false;
804 804
 					}
805 805
 				    }
806 806
 				}
807 807
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
808 808
 				    $ignoreImport = true;
809
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
809
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
810 810
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
811 811
 					    $ignoreImport = false;
812 812
 					}
@@ -818,32 +818,32 @@  discard block
 block discarded – undo
818 818
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819 819
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820 820
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
-				    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')));
821
+				    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')));
822 822
 				    $timeelapsed = microtime(true);
823 823
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
824 824
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
825 825
 					    $Spotter = new Spotter($this->db);
826
-					    $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']);
826
+					    $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']);
827 827
 					    $Spotter->db = null;
828 828
 					    if ($globalDebug && isset($result)) echo $result."\n";
829 829
 					}
830 830
 				    }
831
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
831
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
832 832
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833 833
 
834 834
 				    // Add source stat in DB
835 835
 				    $Stats = new Stats($this->db);
836 836
 				    if (!empty($this->stats)) {
837 837
 					if ($globalDebug) echo 'Add source stats : ';
838
-				        foreach($this->stats as $date => $data) {
839
-					    foreach($data as $source => $sourced) {
838
+				        foreach ($this->stats as $date => $data) {
839
+					    foreach ($data as $source => $sourced) {
840 840
 					        //print_r($sourced);
841
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
841
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
842
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
843 843
 				    		if (isset($sourced['msg'])) {
844 844
 				    		    if (time() - $sourced['msg']['date'] > 10) {
845 845
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
846
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
847 847
 			    			        unset($this->stats[$date][$source]['msg']);
848 848
 			    			    }
849 849
 			    			}
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
882 882
 					    $SpotterLive = new SpotterLive($this->db);
883 883
 					    $SpotterLive->deleteLiveSpotterData();
884
-					    $SpotterLive->db=null;
884
+					    $SpotterLive->db = null;
885 885
 					}
886 886
 				    }
887 887
 				    if ($globalDebug) echo " Done\n";
888 888
 				    $this->last_delete = time();
889 889
 				}
890 890
 			    } else {
891
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
891
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
892 892
 				    $this->all_flights[$id]['id'] = $recent_ident;
893 893
 				    $this->all_flights[$id]['addedSpotter'] = 1;
894 894
 				}
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897 897
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
898 898
 					    $Spotter = new Spotter($this->db);
899
-					    $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']);
899
+					    $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']);
900 900
 					    $Spotter->db = null;
901 901
 					}
902 902
 				    }
@@ -922,37 +922,37 @@  discard block
 block discarded – undo
922 922
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923 923
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
924 924
 
925
-		    foreach($globalAirportIgnore as $airportIgnore) {
925
+		    foreach ($globalAirportIgnore as $airportIgnore) {
926 926
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927 927
 			    $ignoreImport = true;
928 928
 			}
929 929
 		    }
930 930
 		    if (count($globalAirportAccept) > 0) {
931 931
 		        $ignoreImport = true;
932
-		        foreach($globalAirportIgnore as $airportIgnore) {
932
+		        foreach ($globalAirportIgnore as $airportIgnore) {
933 933
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
934 934
 				$ignoreImport = false;
935 935
 			    }
936 936
 			}
937 937
 		    }
938 938
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
939
-			foreach($globalAirlineIgnore as $airlineIgnore) {
940
-			    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)) {
939
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
940
+			    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)) {
941 941
 				$ignoreImport = true;
942 942
 			    }
943 943
 			}
944 944
 		    }
945 945
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
946 946
 			$ignoreImport = true;
947
-			foreach($globalAirlineAccept as $airlineAccept) {
948
-			    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)) {
947
+			foreach ($globalAirlineAccept as $airlineAccept) {
948
+			    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)) {
949 949
 				$ignoreImport = false;
950 950
 			    }
951 951
 			}
952 952
 		    }
953 953
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
954 954
 			$ignoreImport = true;
955
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
955
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
956 956
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957 957
 			        $ignoreImport = false;
958 958
 			    }
@@ -960,23 +960,23 @@  discard block
 block discarded – undo
960 960
 		    }
961 961
 
962 962
 		    if (!$ignoreImport) {
963
-			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'])) {
964
-				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')));
963
+			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'])) {
964
+				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')));
965 965
 				$timeelapsed = microtime(true);
966 966
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
967 967
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
968 968
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
969 969
 					$SpotterLive = new SpotterLive($this->db);
970
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['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']);
970
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['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']);
971 971
 					$SpotterLive->db = null;
972 972
 					if ($globalDebug) echo $result."\n";
973 973
 				    }
974 974
 				}
975 975
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
976
-					$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']);
976
+					$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']);
977 977
 				}
978 978
 				$this->all_flights[$id]['putinarchive'] = false;
979
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
979
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
980 980
 
981 981
 				// Put statistics in $this->stats variable
982 982
 				//if ($line['format_source'] != 'aprs') {
@@ -995,19 +995,19 @@  discard block
 block discarded – undo
995 995
 							$latitude = $globalCenterLatitude;
996 996
 							$longitude = $globalCenterLongitude;
997 997
 						}
998
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
998
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
999 999
 					} else {
1000 1000
 						$latitude = $this->source_location[$source]['latitude'];
1001 1001
 						$longitude = $this->source_location[$source]['longitude'];
1002 1002
 					}
1003
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1003
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1004 1004
 					//$stats_heading = $stats_heading%22.5;
1005 1005
 					$stats_heading = round($stats_heading/22.5);
1006
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1006
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1007 1007
 					$current_date = date('Y-m-d');
1008 1008
 					if ($stats_heading == 16) $stats_heading = 0;
1009 1009
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1010
-						for ($i=0;$i<=15;$i++) {
1010
+						for ($i = 0; $i <= 15; $i++) {
1011 1011
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1012 1012
 						}
1013 1013
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1023 1023
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1024 1024
 						    end($this->stats[$current_date][$source]['hist']);
1025
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1025
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1026 1026
 						} else $mini = 0;
1027
-						for ($i=$mini;$i<=$distance;$i+=10) {
1027
+						for ($i = $mini; $i <= $distance; $i += 10) {
1028 1028
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1029 1029
 						}
1030 1030
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 				$this->all_flights[$id]['lastupdate'] = time();
1038 1038
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1039 1039
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1040
-			} 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";
1040
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1041 1041
 			//$this->del();
1042 1042
 			
1043 1043
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +401 added lines, -143 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid : $e \n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid : $e \n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,17 +108,25 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $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']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$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']));
116 132
        }
@@ -132,14 +148,18 @@  discard block
 block discarded – undo
132 148
 
133 149
     public function checkAll() {
134 150
 	global $globalDebug, $globalNoImport;
135
-	if ($globalDebug) echo "Update last seen flights data...\n";
151
+	if ($globalDebug) {
152
+		echo "Update last seen flights data...\n";
153
+	}
136 154
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137 155
 	    foreach ($this->all_flights as $key => $flight) {
138 156
 		if (isset($this->all_flights[$key]['id'])) {
139 157
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 158
     		    $Spotter = new Spotter($this->db);
141 159
         	    $real_arrival = $this->arrival($key);
142
-        	    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']);
160
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
161
+        	    	$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']);
162
+        	    }
143 163
         	}
144 164
 	    }
145 165
 	}
@@ -147,24 +167,32 @@  discard block
 block discarded – undo
147 167
 
148 168
     public function arrival($key) {
149 169
 	global $globalClosestMinDist, $globalDebug;
150
-	if ($globalDebug) echo 'Update arrival...'."\n";
170
+	if ($globalDebug) {
171
+		echo 'Update arrival...'."\n";
172
+	}
151 173
 	$Spotter = new Spotter($this->db);
152 174
         $airport_icao = '';
153 175
         $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
176
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
177
+        	$globalClosestMinDist = 50;
178
+        }
155 179
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156 180
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157 181
     	    if (isset($closestAirports[0])) {
158 182
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 183
         	    $airport_icao = $closestAirports[0]['icao'];
160 184
         	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        	    if ($globalDebug) {
186
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
187
+        	    }
162 188
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163 189
         	    foreach ($closestAirports as $airport) {
164 190
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165 191
         		    $airport_icao = $airport['icao'];
166 192
         		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
193
+        		    if ($globalDebug) {
194
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        		    }
168 196
         		    break;
169 197
         		}
170 198
         	    }
@@ -172,14 +200,20 @@  discard block
 block discarded – undo
172 200
         		$airport_icao = $closestAirports[0]['icao'];
173 201
         		$airport_time = $this->all_flights[$key]['datetime'];
174 202
         	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
203
+        		if ($globalDebug) {
204
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
205
+        		}
176 206
         	}
177 207
     	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
208
+    		    if ($globalDebug) {
209
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
210
+    		    }
179 211
     	    }
180 212
 
181 213
         } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
214
+        	if ($globalDebug) {
215
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
216
+        	}
183 217
         }
184 218
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185 219
     }
@@ -189,7 +223,9 @@  discard block
 block discarded – undo
189 223
     public function del() {
190 224
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 225
 	// Delete old infos
192
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
226
+	if ($globalDebug) {
227
+		echo 'Delete old values and update latest data...'."\n";
228
+	}
193 229
 	foreach ($this->all_flights as $key => $flight) {
194 230
 	    if (isset($flight['lastupdate'])) {
195 231
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -203,13 +239,17 @@  discard block
 block discarded – undo
203 239
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 240
 	// Delete old infos
205 241
 	if (isset($this->all_flights[$key]['id'])) {
206
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
242
+		if ($globalDebug) {
243
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
244
+		}
207 245
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
208 246
 			$real_arrival = $this->arrival($key);
209 247
 			$Spotter = new Spotter($this->db);
210 248
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211 249
 				$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']);
212
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250
+				if ($globalDebug && $result != 'success') {
251
+					echo '!!! ERROR : '.$result."\n";
252
+				}
213 253
 			}
214 254
 		}
215 255
 	}
@@ -219,9 +259,13 @@  discard block
 block discarded – undo
219 259
     public function add($line) {
220 260
 	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;
221 261
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
223
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
224
-/*
262
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
263
+		$globalCoordMinChange = '0.02';
264
+	}
265
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
266
+		$globalAircraftMaxUpdate = 3000;
267
+	}
268
+	/*
225 269
 	$Spotter = new Spotter();
226 270
 	$dbc = $Spotter->db;
227 271
 	$SpotterLive = new SpotterLive($dbc);
@@ -243,19 +287,28 @@  discard block
 block discarded – undo
243 287
 	// SBS format is CSV format
244 288
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 289
 	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
290
+	    if (isset($line['hex'])) {
291
+	    	$line['hex'] = strtoupper($line['hex']);
292
+	    }
247 293
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 294
 
249 295
 		// Increment message number
250 296
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251 297
 		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
298
+		    if (isset($line['source_name'])) {
299
+		    	$source = $line['source_name'];
300
+		    } else {
301
+		    	$source = '';
302
+		    }
303
+		    if ($source == '' || $line['format_source'] == 'aprs') {
304
+		    	$source = $line['format_source'];
305
+		    }
255 306
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256 307
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257 308
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
309
+		    } else {
310
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
311
+		    }
259 312
 		}
260 313
 		
261 314
 		/*
@@ -271,23 +324,38 @@  discard block
 block discarded – undo
271 324
 		//$this->db = $dbc;
272 325
 
273 326
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
327
+	        if (!isset($line['id'])) {
328
+	        	$id = trim($line['hex']);
329
+	        } else {
330
+	        	$id = trim($line['id']);
331
+	        }
276 332
 		
277 333
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
334
+		    if ($globalDebug) {
335
+		    	echo 'New flight...'."\n";
336
+		    }
279 337
 		    $this->all_flights[$id] = array();
280 338
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281 339
 		    $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' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
340
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
341
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
342
+		    }
283 343
 		    if (!isset($line['id'])) {
284
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285
-//			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')));
344
+			if (!isset($globalDaemon)) {
345
+				$globalDaemon = TRUE;
346
+			}
347
+			//			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')));
286 348
 //			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')));
287
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
349
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
350
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
351
+			}
288 352
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
353
+		     } else {
354
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
355
+		     }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
291 359
 		}
292 360
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -309,12 +377,20 @@  discard block
 block discarded – undo
309 377
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 378
 			    }
311 379
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
380
+			    if ($globalDebugTimeElapsed) {
381
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+			    }
383
+			    if ($aircraft_icao != '') {
384
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
385
+			    }
314 386
 			}
315 387
 		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
388
+		    if ($globalAllFlights !== FALSE) {
389
+		    	$dataFound = true;
390
+		    }
391
+		    if ($globalDebug) {
392
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
393
+		    }
318 394
 		}
319 395
 	        if (isset($line['id']) && !isset($line['hex'])) {
320 396
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -322,7 +398,9 @@  discard block
 block discarded – undo
322 398
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 399
 			$icao = $line['aircraft_icao'];
324 400
 			$Spotter = new Spotter($this->db);
325
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
401
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
402
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
403
+			}
326 404
 			$Spotter->db = null;
327 405
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
328 406
 		}
@@ -332,15 +410,24 @@  discard block
 block discarded – undo
332 410
 				$Spotter = new Spotter($this->db);
333 411
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
334 412
 				$Spotter->db = null;
335
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
413
+				if ($aircraft_icao != '') {
414
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
415
+				}
336 416
 			}
337 417
 		}
338 418
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
339
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
340
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
341
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
342
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
343
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
419
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
420
+				$aircraft_icao = 'GLID';
421
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
422
+				$aircraft_icao = 'UHEL';
423
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
424
+				$aircraft_icao = 'TOWPLANE';
425
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
426
+				$aircraft_icao = 'POWAIRC';
427
+			}
428
+			if (isset($aircraft_icao)) {
429
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
430
+			}
344 431
 		}
345 432
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
346 433
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -350,8 +437,11 @@  discard block
 block discarded – undo
350 437
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
351 438
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
352 439
 		    } else {
353
-				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";
354
-				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";
440
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
441
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
442
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
443
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
444
+				}
355 445
 				/*
356 446
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
357 447
 				print_r($this->all_flights[$id]);
@@ -360,16 +450,22 @@  discard block
 block discarded – undo
360 450
 				return '';
361 451
 		    }
362 452
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
363
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
453
+			if ($globalDebug) {
454
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
455
+			}
364 456
 			return '';
365 457
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
366
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
458
+			if ($globalDebug) {
459
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
460
+			}
367 461
 			return '';
368 462
 		} elseif (!isset($line['datetime'])) {
369 463
 			date_default_timezone_set('UTC');
370 464
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
371 465
 		} else {
372
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
466
+			if ($globalDebug) {
467
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
468
+			}
373 469
 			return '';
374 470
 		}
375 471
 
@@ -390,30 +486,48 @@  discard block
 block discarded – undo
390 486
 
391 487
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
392 488
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
393
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
489
+				if ($globalDebug) {
490
+					echo '---!!!! New ident, reset aircraft data...'."\n";
491
+				}
394 492
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
395 493
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
396
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
397
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
398
-				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']));
494
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
495
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
496
+				} elseif (isset($line['id'])) {
497
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
498
+				} elseif (isset($this->all_flights[$id]['ident'])) {
499
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
500
+				}
399 501
 			} else {
400 502
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401 503
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402 504
 				$timeelapsed = microtime(true);
403 505
             			$Spotter = new Spotter($this->db);
404 506
             			$fromsource = NULL;
405
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
406
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
407
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
408
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
409
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
507
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
508
+            				$fromsource = $globalAirlinesSource;
509
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
510
+            				$fromsource = 'vatsim';
511
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
512
+					$fromsource = 'ivao';
513
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
514
+					$fromsource = 'vatsim';
515
+				} elseif (isset($globalIVAO) && $globalIVAO) {
516
+					$fromsource = 'ivao';
517
+				}
410 518
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
411
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
519
+				if ($globalDebug && $result != 'success') {
520
+					echo '!!! ERROR : '.$result."\n";
521
+				}
412 522
 				$Spotter->db = null;
413
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
523
+				if ($globalDebugTimeElapsed) {
524
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+				}
414 526
 			    }
415 527
 			}
416
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
528
+		    } else {
529
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
530
+		    }
417 531
 		    
418 532
 /*
419 533
 		    if (!isset($line['id'])) {
@@ -423,7 +537,9 @@  discard block
 block discarded – undo
423 537
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
424 538
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
425 539
   */
426
-		    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']));
540
+		    if (!isset($this->all_flights[$id]['id'])) {
541
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
542
+		    }
427 543
 
428 544
 		    //$putinarchive = true;
429 545
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -441,7 +557,9 @@  discard block
 block discarded – undo
441 557
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
442 558
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
443 559
 		    		$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' => ''));
444
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
560
+				if ($globalDebugTimeElapsed) {
561
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
562
+				}
445 563
                         }
446 564
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447 565
 			$timeelapsed = microtime(true);
@@ -455,7 +573,9 @@  discard block
 block discarded – undo
455 573
 				$Translation->db = null;
456 574
 			    }
457 575
 			    $Spotter->db = null;
458
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
576
+			    if ($globalDebugTimeElapsed) {
577
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+			    }
459 579
                     	}
460 580
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
461 581
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -464,9 +584,13 @@  discard block
 block discarded – undo
464 584
 		    		$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']));
465 585
 		    	    }
466 586
 			}
467
-			if (!isset($globalFork)) $globalFork = TRUE;
587
+			if (!isset($globalFork)) {
588
+				$globalFork = TRUE;
589
+			}
468 590
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
469
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
591
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
592
+					$this->get_Schedule($id,trim($line['ident']));
593
+				}
470 594
 			}
471 595
 		    }
472 596
 		}
@@ -484,9 +608,13 @@  discard block
 block discarded – undo
484 608
 			$speed = $speed*3.6;
485 609
 			if ($speed < 1000) {
486 610
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
487
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
611
+	  			if ($globalDebug) {
612
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
613
+	  			}
488 614
 	  		} else {
489
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
615
+	  			if ($globalDebug) {
616
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
617
+	  			}
490 618
 	  		}
491 619
 		    }
492 620
 		}
@@ -495,13 +623,21 @@  discard block
 block discarded – undo
495 623
 
496 624
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
497 625
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
498
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
626
+	    	    	if ($globalDebug) {
627
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
628
+	    	    	}
499 629
 	    	    	return false;
500 630
 	    	    }
501
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
-	    	    else unset($timediff);
503
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
-	    	    else unset($timediff_archive);
631
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
632
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
633
+	    	    } else {
634
+	    	    	unset($timediff);
635
+	    	    }
636
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
637
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
638
+	    	    } else {
639
+	    	    	unset($timediff_archive);
640
+	    	    }
505 641
 	    	    if ($this->tmd > 5
506 642
 	    	        || (isset($line['format_source']) 
507 643
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -537,16 +673,25 @@  discard block
 block discarded – undo
537 673
 				$this->all_flights[$id]['putinarchive'] = true;
538 674
 				$this->tmd = 0;
539 675
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
540
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
676
+				    if ($globalDebug) {
677
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
678
+				    }
541 679
 				    $timeelapsed = microtime(true);
542 680
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543 681
 					$Spotter = new Spotter($this->db);
544 682
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
545
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
546
-					else $this->all_flights[$id]['over_country'] = '';
683
+					if (!empty($all_country)) {
684
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
685
+					} else {
686
+						$this->all_flights[$id]['over_country'] = '';
687
+					}
547 688
 					$Spotter->db = null;
548
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
549
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
689
+					if ($globalDebugTimeElapsed) {
690
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
691
+					}
692
+					if ($globalDebug) {
693
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
694
+					}
550 695
 				    }
551 696
 				}
552 697
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -592,7 +737,9 @@  discard block
 block discarded – undo
592 737
 			    */
593 738
 			}
594 739
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
595
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
740
+			    if ($line['longitude'] > 180) {
741
+			    	$line['longitude'] = $line['longitude'] - 360;
742
+			    }
596 743
 			    //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) {
597 744
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
598 745
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -629,7 +776,9 @@  discard block
 block discarded – undo
629 776
 		    }
630 777
 		}
631 778
 		if (isset($line['last_update']) && $line['last_update'] != '') {
632
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
779
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
780
+		    	$dataFound = true;
781
+		    }
633 782
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
634 783
 		}
635 784
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -651,35 +800,53 @@  discard block
 block discarded – undo
651 800
 			// Here we force archive of flight because after ground it's a new one (or should be)
652 801
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
653 802
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
654
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
655
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
656
-			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']));
803
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
804
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
805
+			} elseif (isset($line['id'])) {
806
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
807
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
808
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
809
+			}
810
+		    }
811
+		    if ($line['ground'] != 1) {
812
+		    	$line['ground'] = 0;
657 813
 		    }
658
-		    if ($line['ground'] != 1) $line['ground'] = 0;
659 814
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
660 815
 		    //$dataFound = true;
661 816
 		}
662 817
 		if (isset($line['squawk']) && $line['squawk'] != '') {
663 818
 		    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'])) {
664
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
819
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
820
+			    	$this->all_flights[$id]['putinarchive'] = true;
821
+			    }
665 822
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
666 823
 			    $highlight = '';
667
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
669
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
824
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
825
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
826
+			    }
827
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
828
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
829
+			    }
830
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
831
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
832
+			    }
670 833
 			    if ($highlight != '') {
671 834
 				$timeelapsed = microtime(true);
672 835
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
673 836
 				    $Spotter = new Spotter($this->db);
674 837
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
675 838
 				    $Spotter->db = null;
676
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
839
+				    if ($globalDebugTimeElapsed) {
840
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
841
+				    }
677 842
 				}
678 843
 				//$putinarchive = true;
679 844
 				//$highlight = '';
680 845
 			    }
681 846
 			    
682
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
847
+		    } else {
848
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
849
+		    }
683 850
 		    //$dataFound = true;
684 851
 		}
685 852
 
@@ -692,19 +859,27 @@  discard block
 block discarded – undo
692 859
 				}
693 860
 			}
694 861
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
695
-			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;
862
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
863
+				$this->all_flights[$id]['putinarchive'] = true;
864
+			}
696 865
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
697 866
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
698 867
 			//$dataFound = true;
699 868
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700 869
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
701 870
 			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) {
702
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
871
+				if ($globalDebug) {
872
+					echo '--- Reset because of altitude'."\n";
873
+				}
703 874
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
704 875
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
705
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
706
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
707
-				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']));
876
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
877
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
878
+				} elseif (isset($line['id'])) {
879
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
880
+				} elseif (isset($this->all_flights[$id]['ident'])) {
881
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
882
+				}
708 883
 			}
709 884
 		    }
710 885
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -715,22 +890,32 @@  discard block
 block discarded – undo
715 890
 		}
716 891
 		
717 892
 		if (isset($line['heading']) && $line['heading'] != '') {
718
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
893
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
894
+		    	$this->all_flights[$id]['putinarchive'] = true;
895
+		    }
719 896
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720 897
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721 898
 		    //$dataFound = true;
722 899
   		} 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']) {
723 900
   		    $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']);
724 901
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
902
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
903
+		    	$this->all_flights[$id]['putinarchive'] = true;
904
+		    }
905
+  		    if ($globalDebug) {
906
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
907
+  		    }
727 908
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
728 909
   		    // If not enough messages and ACARS set heading to 0
729 910
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
730 911
   		}
731
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
733
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
912
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
913
+			$dataFound = false;
914
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
915
+			$dataFound = false;
916
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) {
917
+			$dataFound = false;
918
+		}
734 919
 
735 920
 //		print_r($this->all_flights[$id]);
736 921
 		//gets the callsign from the last hour
@@ -747,23 +932,38 @@  discard block
 block discarded – undo
747 932
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
748 933
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
749 934
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
750
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
935
+				    if ($globalDebug) {
936
+				    	echo "Check if aircraft is already in DB...";
937
+				    }
751 938
 				    $timeelapsed = microtime(true);
752 939
 				    $SpotterLive = new SpotterLive($this->db);
753 940
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
754 941
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
755
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
942
+					if ($globalDebugTimeElapsed) {
943
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
944
+					}
756 945
 				    } elseif (isset($line['id'])) {
757 946
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
947
+					if ($globalDebugTimeElapsed) {
948
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					}
759 950
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
760 951
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
762
-				    } else $recent_ident = '';
952
+					if ($globalDebugTimeElapsed) {
953
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
954
+					}
955
+				    } else {
956
+				    	$recent_ident = '';
957
+				    }
763 958
 				    $SpotterLive->db=null;
764
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
766
-				} else $recent_ident = '';
959
+				    if ($globalDebug && $recent_ident == '') {
960
+				    	echo " Not in DB.\n";
961
+				    } elseif ($globalDebug && $recent_ident != '') {
962
+				    	echo " Already in DB.\n";
963
+				    }
964
+				} else {
965
+					$recent_ident = '';
966
+				}
767 967
 			    } else {
768 968
 				$recent_ident = '';
769 969
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -771,7 +971,9 @@  discard block
 block discarded – undo
771 971
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
772 972
 			    if($recent_ident == "")
773 973
 			    {
774
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
974
+				if ($globalDebug) {
975
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
976
+				}
775 977
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
776 978
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
777 979
 				//adds the spotter data for the archive
@@ -815,31 +1017,49 @@  discard block
 block discarded – undo
815 1017
 				
816 1018
 				if (!$ignoreImport) {
817 1019
 				    $highlight = '';
818
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
-				    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')));
1020
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1021
+				    	$highlight = 'Squawk 7500 : Hijack';
1022
+				    }
1023
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1024
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1025
+				    }
1026
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1027
+				    	$highlight = 'Squawk 7700 : Emergency';
1028
+				    }
1029
+				    if (!isset($this->all_flights[$id]['id'])) {
1030
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1031
+				    }
822 1032
 				    $timeelapsed = microtime(true);
823 1033
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
824 1034
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
825 1035
 					    $Spotter = new Spotter($this->db);
826 1036
 					    $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']);
827 1037
 					    $Spotter->db = null;
828
-					    if ($globalDebug && isset($result)) echo $result."\n";
1038
+					    if ($globalDebug && isset($result)) {
1039
+					    	echo $result."\n";
1040
+					    }
829 1041
 					}
830 1042
 				    }
831
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1043
+				    if ($globalDebugTimeElapsed) {
1044
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1045
+				    }
832 1046
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833 1047
 
834 1048
 				    // Add source stat in DB
835 1049
 				    $Stats = new Stats($this->db);
836 1050
 				    if (!empty($this->stats)) {
837
-					if ($globalDebug) echo 'Add source stats : ';
1051
+					if ($globalDebug) {
1052
+						echo 'Add source stats : ';
1053
+					}
838 1054
 				        foreach($this->stats as $date => $data) {
839 1055
 					    foreach($data as $source => $sourced) {
840 1056
 					        //print_r($sourced);
841
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1057
+				    	        if (isset($sourced['polar'])) {
1058
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1059
+				    	        }
1060
+				    	        if (isset($sourced['hist'])) {
1061
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1062
+				    	        }
843 1063
 				    		if (isset($sourced['msg'])) {
844 1064
 				    		    if (time() - $sourced['msg']['date'] > 10) {
845 1065
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -852,13 +1072,17 @@  discard block
 block discarded – undo
852 1072
 			    			unset($this->stats[$date]);
853 1073
 			    		    }
854 1074
 				    	}
855
-				    	if ($globalDebug) echo 'Done'."\n";
1075
+				    	if ($globalDebug) {
1076
+				    		echo 'Done'."\n";
1077
+				    	}
856 1078
 
857 1079
 				    }
858 1080
 				    $Stats->db = null;
859 1081
 				    }
860 1082
 				    $this->del();
861
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1083
+				} elseif ($globalDebug) {
1084
+					echo 'Ignore data'."\n";
1085
+				}
862 1086
 				//$ignoreImport = false;
863 1087
 				$this->all_flights[$id]['addedSpotter'] = 1;
864 1088
 				//print_r($this->all_flights[$id]);
@@ -875,7 +1099,9 @@  discard block
 block discarded – undo
875 1099
 			*/
876 1100
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
877 1101
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
878
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1102
+				    if ($globalDebug) {
1103
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1104
+				    }
879 1105
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
880 1106
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
881 1107
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -884,7 +1110,9 @@  discard block
 block discarded – undo
884 1110
 					    $SpotterLive->db=null;
885 1111
 					}
886 1112
 				    }
887
-				    if ($globalDebug) echo " Done\n";
1113
+				    if ($globalDebug) {
1114
+				    	echo " Done\n";
1115
+				    }
888 1116
 				    $this->last_delete = time();
889 1117
 				}
890 1118
 			    } else {
@@ -911,11 +1139,17 @@  discard block
 block discarded – undo
911 1139
 		    //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";
912 1140
 		    if ($globalDebug) {
913 1141
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
914
-				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";
915
-				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";
1142
+				if (isset($this->all_flights[$id]['source_name'])) {
1143
+					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";
1144
+				} else {
1145
+					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";
1146
+				}
916 1147
 			} else {
917
-				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";
918
-				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";
1148
+				if (isset($this->all_flights[$id]['source_name'])) {
1149
+					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";
1150
+				} else {
1151
+					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";
1152
+				}
919 1153
 			}
920 1154
 		    }
921 1155
 		    $ignoreImport = false;
@@ -961,22 +1195,30 @@  discard block
 block discarded – undo
961 1195
 
962 1196
 		    if (!$ignoreImport) {
963 1197
 			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'])) {
964
-				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')));
1198
+				if (!isset($this->all_flights[$id]['id'])) {
1199
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1200
+				}
965 1201
 				$timeelapsed = microtime(true);
966 1202
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
967 1203
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
968
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1204
+					if ($globalDebug) {
1205
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1206
+					}
969 1207
 					$SpotterLive = new SpotterLive($this->db);
970 1208
 					$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']);
971 1209
 					$SpotterLive->db = null;
972
-					if ($globalDebug) echo $result."\n";
1210
+					if ($globalDebug) {
1211
+						echo $result."\n";
1212
+					}
973 1213
 				    }
974 1214
 				}
975 1215
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
976 1216
 					$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']);
977 1217
 				}
978 1218
 				$this->all_flights[$id]['putinarchive'] = false;
979
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1219
+				if ($globalDebugTimeElapsed) {
1220
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1221
+				}
980 1222
 
981 1223
 				// Put statistics in $this->stats variable
982 1224
 				//if ($line['format_source'] != 'aprs') {
@@ -984,7 +1226,9 @@  discard block
 block discarded – undo
984 1226
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
985 1227
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
986 1228
 					$source = $this->all_flights[$id]['source_name'];
987
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1229
+					if ($source == '') {
1230
+						$source = $this->all_flights[$id]['format_source'];
1231
+					}
988 1232
 					if (!isset($this->source_location[$source])) {
989 1233
 						$Location = new Source();
990 1234
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1005,7 +1249,9 @@  discard block
 block discarded – undo
1005 1249
 					$stats_heading = round($stats_heading/22.5);
1006 1250
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1007 1251
 					$current_date = date('Y-m-d');
1008
-					if ($stats_heading == 16) $stats_heading = 0;
1252
+					if ($stats_heading == 16) {
1253
+						$stats_heading = 0;
1254
+					}
1009 1255
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1010 1256
 						for ($i=0;$i<=15;$i++) {
1011 1257
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1023,7 +1269,9 @@  discard block
 block discarded – undo
1023 1269
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1024 1270
 						    end($this->stats[$current_date][$source]['hist']);
1025 1271
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1026
-						} else $mini = 0;
1272
+						} else {
1273
+							$mini = 0;
1274
+						}
1027 1275
 						for ($i=$mini;$i<=$distance;$i+=10) {
1028 1276
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1029 1277
 						}
@@ -1035,19 +1283,27 @@  discard block
 block discarded – undo
1035 1283
 				}
1036 1284
 
1037 1285
 				$this->all_flights[$id]['lastupdate'] = time();
1038
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1286
+				if ($this->all_flights[$id]['putinarchive']) {
1287
+					$send = true;
1288
+				}
1039 1289
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1040
-			} 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";
1290
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1291
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1292
+			}
1041 1293
 			//$this->del();
1042 1294
 			
1043 1295
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1044 1296
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1045
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1297
+				if ($globalDebug) {
1298
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1299
+				}
1046 1300
 				$SpotterLive = new SpotterLive($this->db);
1047 1301
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1048 1302
 				$SpotterLive->db = null;
1049 1303
 				//SpotterLive->deleteLiveSpotterData();
1050
-				if ($globalDebug) echo " Done\n";
1304
+				if ($globalDebug) {
1305
+					echo " Done\n";
1306
+				}
1051 1307
 				$this->last_delete_hourly = time();
1052 1308
 			    } else {
1053 1309
 				$this->del();
@@ -1059,7 +1315,9 @@  discard block
 block discarded – undo
1059 1315
 		    //$ignoreImport = false;
1060 1316
 		}
1061 1317
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1062
-		if ($send) return $this->all_flights[$id];
1318
+		if ($send) {
1319
+			return $this->all_flights[$id];
1320
+		}
1063 1321
 	    }
1064 1322
 	}
1065 1323
     }
Please login to merge, or discard this patch.
require/class.GeoidHeight.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -91,6 +91,10 @@
 block discarded – undo
91 91
 		$this->rlatres = (($this->height - 1) / 180.0);
92 92
 	}
93 93
 
94
+	/**
95
+	 * @param integer $ix
96
+	 * @param integer $iy
97
+	 */
94 98
 	private function _rawval($ix,$iy) {
95 99
 		if (($iy < 0)) {
96 100
 			$iy = -$iy;
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * Translated to PHP of GeographicLib/src/Geoid.cpp
12 12
 * by Ycarus <[email protected]> in 2017
13 13
 */
14
-class GeoidHeight  {
14
+class GeoidHeight {
15 15
 	private $c0 = 240;
16 16
 	private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]];
17 17
 	private $c0n = 372;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	private $iy = null;
31 31
 	private $t = null;
32 32
 
33
-	public function __construct($name='') {
33
+	public function __construct($name = '') {
34 34
 		global $globalGeoidSource;
35 35
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
36 36
 		if ($name == '') {
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
 			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
39 39
 		}
40 40
 
41
-		$f = @fopen($name,"r");
41
+		$f = @fopen($name, "r");
42 42
 		if ($f === FALSE) {
43 43
 			throw new Exception("Can't open ".$name);
44 44
 		}
45
-		$line = fgets($f,4096);
45
+		$line = fgets($f, 4096);
46 46
 		if (trim($line) != 'P5') {
47 47
 			throw new Exception('No PGM header');
48 48
 		}
49 49
 		$headerlen = strlen($line);
50 50
 		while (true) {
51
-			$line = fgets($f,4096);
51
+			$line = fgets($f, 4096);
52 52
 			if ((strlen($line) == 0)) {
53 53
 				throw new Exception('EOF before end of file header');
54 54
 			}
55 55
 			$headerlen += strlen($line);
56
-			if (strpos($line,'# Offset ') !== FALSE) {
56
+			if (strpos($line, '# Offset ') !== FALSE) {
57 57
 				$this->offset = substr($line, 9);
58
-			} else if (strpos($line,'# Scale ') !== FALSE) {
58
+			} else if (strpos($line, '# Scale ') !== FALSE) {
59 59
 				$this->scale = substr($line, 8);
60
-			} else if ((strpos($line,'#') === FALSE)) {
61
-				list($this->width, $this->height) = preg_split('/\s+/',$line);
60
+			} else if ((strpos($line, '#') === FALSE)) {
61
+				list($this->width, $this->height) = preg_split('/\s+/', $line);
62 62
 				break;
63 63
 			}
64 64
 		}
65
-		$line = fgets($f,4096);
65
+		$line = fgets($f, 4096);
66 66
 		$headerlen += strlen($line);
67
-		$levels = (int)$line;
68
-		$this->width = (int)$this->width;
69
-		$this->height = (int)$this->height;
67
+		$levels = (int) $line;
68
+		$this->width = (int) $this->width;
69
+		$this->height = (int) $this->height;
70 70
 		if (($levels != 65535)) {
71 71
 			throw new Exception('PGM file must have 65535 gray levels ('.$levels.')');
72 72
 		}
@@ -81,42 +81,42 @@  discard block
 block discarded – undo
81 81
 		}
82 82
 
83 83
 		$fullsize = filesize($name);
84
-		if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) {
84
+		if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) {
85 85
 			throw new Exception('File has the wrong length');
86 86
 		}
87 87
 
88 88
 		$this->headerlen = $headerlen;
89
-		$this->raw= $f;
90
-		$this->rlonres = ($this->width / 360.0);
91
-		$this->rlatres = (($this->height - 1) / 180.0);
89
+		$this->raw = $f;
90
+		$this->rlonres = ($this->width/360.0);
91
+		$this->rlatres = (($this->height - 1)/180.0);
92 92
 	}
93 93
 
94
-	private function _rawval($ix,$iy) {
94
+	private function _rawval($ix, $iy) {
95 95
 		if (($iy < 0)) {
96 96
 			$iy = -$iy;
97
-			$ix += ($this->width / 2);
97
+			$ix += ($this->width/2);
98 98
 		} else if (($iy >= $this->height)) {
99
-			$iy = ((2 * ($this->height - 1)) - $iy);
100
-			$ix += ($this->width / 2);
99
+			$iy = ((2*($this->height - 1)) - $iy);
100
+			$ix += ($this->width/2);
101 101
 		}
102 102
 		if (($ix < 0)) {
103 103
 			$ix += $this->width;
104 104
 		} else if (($ix >= $this->width)) {
105 105
 			$ix -= $this->width;
106 106
 		}
107
-		$k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen;
108
-		fseek($this->raw,$k);
109
-		return unpack('n',fread($this->raw,2))[1];
107
+		$k = ((($iy*$this->width) + $ix)*2) + $this->headerlen;
108
+		fseek($this->raw, $k);
109
+		return unpack('n', fread($this->raw, 2))[1];
110 110
 	}
111 111
 
112
-	public function get($lat,$lon,$cubic=true) {
112
+	public function get($lat, $lon, $cubic = true) {
113 113
 		if (($lon < 0)) {
114 114
 			$lon += 360;
115 115
 		}
116
-		$fy = ((90 - $lat) * $this->rlatres);
117
-		$fx = ($lon * $this->rlonres);
118
-		$iy = (int)$fy;
119
-		$ix = (int)$fx;
116
+		$fy = ((90 - $lat)*$this->rlatres);
117
+		$fx = ($lon*$this->rlonres);
118
+		$iy = (int) $fy;
119
+		$ix = (int) $fx;
120 120
 		$fx -= $ix;
121 121
 		$fy -= $iy;
122 122
 		if (($iy == ($this->height - 1))) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 					$c3x = $this->c3;
143 143
 					$c0x = $this->c0;
144 144
 				}
145
-				for ($i = 0; $i < 10;++$i) {
145
+				for ($i = 0; $i < 10; ++$i) {
146 146
 					$t[$i] = 0;
147 147
 					for ($j = 0; $j < 12; ++$j) {
148 148
 						$t[$i] += $v[$j]*$c3x[$j][$i];
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 			$this->t = $t;
154 154
 		}
155 155
 		if (!($cubic)) {
156
-			$a = (((1 - $fx) * $v00) + ($fx * $v01));
157
-			$b = (((1 - $fx) * $v10) + ($fx * $v11));
158
-			$h = (((1 - $fy) * $a) + ($fy * $b));
156
+			$a = (((1 - $fx)*$v00) + ($fx*$v01));
157
+			$b = (((1 - $fx)*$v10) + ($fx*$v11));
158
+			$h = (((1 - $fy)*$a) + ($fy*$b));
159 159
 		} else {
160 160
 			$t = $this->t;
161
-			$h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9]))))));
161
+			$h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9]))))));
162 162
 		}
163
-		return ((float)$this->offset + ((float)$this->scale * (float)$h));
163
+		return ((float) $this->offset + ((float) $this->scale*(float) $h));
164 164
 	}
165 165
 }
166 166
 /*
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,11 @@
 block discarded – undo
34 34
 		global $globalGeoidSource;
35 35
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
36 36
 		if ($name == '') {
37
-			if (isset($globalGeoidSource) && $globalGeoidSource != '') $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
38
-			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
37
+			if (isset($globalGeoidSource) && $globalGeoidSource != '') {
38
+				$name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
39
+			} else {
40
+				$name = dirname(__FILE__).'/../data/egm96-15.pgm';
41
+			}
39 42
 		}
40 43
 
41 44
 		$f = @fopen($name,"r");
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +903 added lines, -903 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->latest() === false) {
28
-    echo "You MUST update to latest schema. Run install/index.php";
29
-    exit();
28
+	echo "You MUST update to latest schema. Run install/index.php";
29
+	exit();
30 30
 }
31 31
 if (PHP_SAPI != 'cli') {
32
-    echo "This script MUST be called from console, not a web browser.";
32
+	echo "This script MUST be called from console, not a web browser.";
33 33
 //    exit();
34 34
 }
35 35
 
36 36
 // This is to be compatible with old version of settings.php
37 37
 if (!isset($globalSources)) {
38
-    if (isset($globalSBS1Hosts)) {
39
-        //$hosts = $globalSBS1Hosts;
40
-        foreach ($globalSBS1Hosts as $host) {
41
-	    $globalSources[] = array('host' => $host);
42
-    	}
43
-    } else {
44
-        if (!isset($globalSBS1Host)) {
45
-	    echo '$globalSources MUST be defined !';
46
-	    die;
38
+	if (isset($globalSBS1Hosts)) {
39
+		//$hosts = $globalSBS1Hosts;
40
+		foreach ($globalSBS1Hosts as $host) {
41
+		$globalSources[] = array('host' => $host);
42
+		}
43
+	} else {
44
+		if (!isset($globalSBS1Host)) {
45
+		echo '$globalSources MUST be defined !';
46
+		die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49 49
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
50
-    }
50
+	}
51 51
 }
52 52
 
53 53
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57
-    $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
57
+	$globalSources = array();
58
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
+	else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
66 66
 	$globalServerAPRS = TRUE;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 if (isset($options['idsource'])) $id_source = $options['idsource'];
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
78
+	if ($globalDebug) echo "Using Server Mode\n";
79
+	$SI=new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 } else $SI=new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88
-    $AIS = new AIS();
89
-    $MI = new MarineImport($Connection->db);
88
+	$AIS = new AIS();
89
+	$MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92 92
 $SBS=new SBS();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
101
-        global $sockets;
102
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
-        die("Bye!\n");
104
-    });
105
-    pcntl_signal_dispatch();
100
+	pcntl_signal(SIGINT,  function() {
101
+		global $sockets;
102
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
+		die("Bye!\n");
104
+	});
105
+	pcntl_signal_dispatch();
106 106
 }
107 107
 
108 108
 // let's try and connect
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
 $reset = 0;
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    /*
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			/*
145 145
     	    // Disabled for now, site change source format
146 146
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
147 147
         	//$formats[$id] = 'radarvirtueljson';
@@ -153,118 +153,118 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
-        	//$formats[$id] = 'planeupdatefaa';
158
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
159
-        	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
-        	    exit(0);
164
-        	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'phpvmacars';
168
-        	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
171
-        	//$formats[$id] = 'phpvmacars';
172
-        	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
175
-        	//$formats[$id] = 'whazzup';
176
-        	$globalSources[$id]['format'] = 'whazzup';
177
-        	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
180
-        	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
183
-        	//$formats[$id] = 'pirepsjson';
184
-        	$globalSources[$id]['format'] = 'pirepsjson';
185
-        	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
-        	//$formats[$id] = 'fr24json';
189
-        	$globalSources[$id]['format'] = 'fr24json';
190
-        	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
-        	    exit(0);
195
-        	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
197
-        	//$formats[$id] = 'fr24json';
198
-        	$globalSources[$id]['format'] = 'myshiptracking';
199
-        	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
-        	    exit(0);
204
-        	}
205
-            //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
-        	//$formats[$id] = 'tsv';
208
-        	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
-            }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
-    		    if ($idf !== false) {
215
-    			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
-    		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
222
-	    if (isset($hostport[1])) {
156
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
+			//$formats[$id] = 'planeupdatefaa';
158
+			$globalSources[$id]['format'] = 'planeupdatefaa';
159
+			//$last_exec['planeupdatefaa'] = 0;
160
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
+				exit(0);
164
+			}
165
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'phpvmacars';
168
+			//$last_exec['phpvmacars'] = 0;
169
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
171
+			//$formats[$id] = 'phpvmacars';
172
+			$globalSources[$id]['format'] = 'vam';
173
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
+			} else if (preg_match('/whazzup/i',$host)) {
175
+			//$formats[$id] = 'whazzup';
176
+			$globalSources[$id]['format'] = 'whazzup';
177
+			//$last_exec['whazzup'] = 0;
178
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
+			} else if (preg_match('/airwhere/i',$host)) {
180
+			$globalSources[$id]['format'] = 'airwhere';
181
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
+			} else if (preg_match('/recentpireps/i',$host)) {
183
+			//$formats[$id] = 'pirepsjson';
184
+			$globalSources[$id]['format'] = 'pirepsjson';
185
+			//$last_exec['pirepsjson'] = 0;
186
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
+			//$formats[$id] = 'fr24json';
189
+			$globalSources[$id]['format'] = 'fr24json';
190
+			//$last_exec['fr24json'] = 0;
191
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
+				exit(0);
195
+			}
196
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
197
+			//$formats[$id] = 'fr24json';
198
+			$globalSources[$id]['format'] = 'myshiptracking';
199
+			//$last_exec['fr24json'] = 0;
200
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
+				exit(0);
204
+			}
205
+			//} else if (preg_match('/10001/',$host)) {
206
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
+			//$formats[$id] = 'tsv';
208
+			$globalSources[$id]['format'] = 'tsv';
209
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
+			}
211
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
+				if ($idf !== false) {
215
+				$httpfeeds[$id] = $idf;
216
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
+				}
218
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
+		$hostport = explode(':',$host);
222
+		if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
225
-	    } else {
225
+		} else {
226 226
 		$port = $globalSources[$id]['port'];
227 227
 		$hostn = $globalSources[$id]['host'];
228
-	    }
229
-	    $Common = new Common();
230
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
-    	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
-	    }
235
-	    if ($s) {
236
-    	        $sockets[$id] = $s;
237
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
228
+		}
229
+		$Common = new Common();
230
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
+			} else {
233
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
+		}
235
+		if ($s) {
236
+				$sockets[$id] = $s;
237
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245
-    		    } elseif ($port == '10001') {
246
-        		//$formats[$id] = 'tsv';
247
-        		$globalSources[$id]['format'] = 'tsv';
248
-		    } elseif ($port == '30002') {
249
-        		//$formats[$id] = 'raw';
250
-        		$globalSources[$id]['format'] = 'raw';
251
-		    } elseif ($port == '5001') {
252
-        		//$formats[$id] = 'raw';
253
-        		$globalSources[$id]['format'] = 'flightgearmp';
254
-		    } elseif ($port == '30005') {
245
+				} elseif ($port == '10001') {
246
+				//$formats[$id] = 'tsv';
247
+				$globalSources[$id]['format'] = 'tsv';
248
+			} elseif ($port == '30002') {
249
+				//$formats[$id] = 'raw';
250
+				$globalSources[$id]['format'] = 'raw';
251
+			} elseif ($port == '5001') {
252
+				//$formats[$id] = 'raw';
253
+				$globalSources[$id]['format'] = 'flightgearmp';
254
+			} elseif ($port == '30005') {
255 255
 			// Not yet supported
256
-        		//$formats[$id] = 'beast';
257
-        		$globalSources[$id]['format'] = 'beast';
258
-		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
260
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256
+				//$formats[$id] = 'beast';
257
+				$globalSources[$id]['format'] = 'beast';
258
+			//} else $formats[$id] = 'sbs';
259
+			} else $globalSources[$id]['format'] = 'sbs';
260
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 261
 		}
262 262
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
263
-            } else {
263
+			} else {
264 264
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
265
-    	    }
266
-        }
267
-    }
265
+			}
266
+		}
267
+	}
268 268
 }
269 269
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
270 270
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
291 291
 } else {
292
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
292
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
294 294
 
295 295
 // APRS Configuration
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 	die;
299 299
 }
300 300
 foreach ($globalSources as $key => $source) {
301
-    if (!isset($source['format'])) {
302
-        $globalSources[$key]['format'] = 'auto';
303
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304 304
 }
305 305
 connect_all($globalSources);
306 306
 foreach ($globalSources as $key => $source) {
307
-    if (isset($source['format']) && $source['format'] == 'aprs') {
307
+	if (isset($source['format']) && $source['format'] == 'aprs') {
308 308
 	$aprs_connect = 0;
309 309
 	$use_aprs = true;
310 310
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
311 311
 	break;
312
-    }
312
+	}
313 313
 }
314 314
 
315 315
 if ($use_aprs) {
@@ -350,115 +350,115 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
354
-    // Delete old ATC
355
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
353
+	if (!$globalDaemon) $i = $endtime-time();
354
+	// Delete old ATC
355
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
357
-        $ATC->deleteOldATC();
358
-    }
357
+		$ATC->deleteOldATC();
358
+	}
359 359
     
360
-    if (count($last_exec) == count($globalSources)) {
360
+	if (count($last_exec) == count($globalSources)) {
361 361
 	$max = $globalMinFetch;
362 362
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
363
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
366
+		if ($globalDebug) echo 'Sleeping...'."\n";
367
+		sleep($globalMinFetch-$max+2);
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
     
372
-    //foreach ($formats as $id => $value) {
373
-    foreach ($globalSources as $id => $value) {
372
+	//foreach ($formats as $id => $value) {
373
+	foreach ($globalSources as $id => $value) {
374 374
 	date_default_timezone_set('UTC');
375 375
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
376 376
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377
-	    //$buffer = $Common->getData($hosts[$id]);
378
-	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
382
-	    foreach ($buffer as $line) {
383
-    		if ($line != '' && count($line) > 7) {
384
-    		    $line = explode(',', $line);
385
-	            $data = array();
386
-	            $data['hex'] = $line[1]; // hex
387
-	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
-	            $data['verticalrate'] = ''; // vertical rate
394
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
-	            $data['emergency'] = ''; // emergency
396
-		    $data['datetime'] = date('Y-m-d H:i:s');
397
-		    $data['format_source'] = 'deltadbtxt';
398
-    		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
-    		    $SI->add($data);
403
-		    unset($data);
404
-    		}
405
-    	    }
406
-    	    $last_exec[$id]['last'] = time();
377
+		//$buffer = $Common->getData($hosts[$id]);
378
+		$buffer = $Common->getData($value['host']);
379
+		if ($buffer != '') $reset = 0;
380
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
+		$buffer = explode('\n',$buffer);
382
+		foreach ($buffer as $line) {
383
+			if ($line != '' && count($line) > 7) {
384
+				$line = explode(',', $line);
385
+				$data = array();
386
+				$data['hex'] = $line[1]; // hex
387
+				$data['ident'] = $line[2]; // ident
388
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
+				$data['verticalrate'] = ''; // vertical rate
394
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
+				$data['emergency'] = ''; // emergency
396
+			$data['datetime'] = date('Y-m-d H:i:s');
397
+			$data['format_source'] = 'deltadbtxt';
398
+				$data['id_source'] = $id_source;
399
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
+				$SI->add($data);
403
+			unset($data);
404
+			}
405
+			}
406
+			$last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408
-	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
-	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
414
-	    foreach ($buffer as $line) {
408
+		date_default_timezone_set('CET');
409
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
+		date_default_timezone_set('UTC');
411
+		if ($buffer != '') $reset = 0;
412
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
+		$buffer = explode('\n',$buffer);
414
+		foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416
-		    //echo "'".$line."'\n";
417
-		    $add = false;
418
-		    $ais_data = $AIS->parse_line(trim($line));
419
-		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
-		    if (isset($ais_data['timestamp'])) {
416
+			//echo "'".$line."'\n";
417
+			$add = false;
418
+			$ais_data = $AIS->parse_line(trim($line));
419
+			$data = array();
420
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
+			if (isset($ais_data['timestamp'])) {
431 431
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
-			    $add = true;
433
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
+				$add = true;
435 435
 			}
436
-		    } else {
436
+			} else {
437 437
 			$data['datetime'] = date('Y-m-d H:i:s');
438 438
 			$add = true;
439
-		    }
440
-		    $data['format_source'] = 'aisnmeatxt';
441
-    		    $data['id_source'] = $id_source;
442
-		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
-		    unset($data);
439
+			}
440
+			$data['format_source'] = 'aisnmeatxt';
441
+				$data['id_source'] = $id_source;
442
+			//print_r($data);
443
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
+			unset($data);
446 446
 		}
447
-    	    }
448
-    	    $last_exec[$id]['last'] = time();
447
+			}
448
+			$last_exec[$id]['last'] = time();
449 449
 	} elseif ($value['format'] == 'aisnmeahttp') {
450
-	    $arr = $httpfeeds;
451
-	    $w = $e = null;
450
+		$arr = $httpfeeds;
451
+		$w = $e = null;
452 452
 	    
453
-	    if (isset($arr[$id])) {
453
+		if (isset($arr[$id])) {
454 454
 		$nn = stream_select($arr,$w,$e,$timeout);
455 455
 		if ($nn > 0) {
456
-		    foreach ($httpfeeds as $feed) {
456
+			foreach ($httpfeeds as $feed) {
457 457
 			$buffer = stream_get_line($feed,2000,"\n");
458 458
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459 459
 			$buffer = explode('\n',$buffer);
460 460
 			foreach ($buffer as $line) {
461
-			    if ($line != '') {
461
+				if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
463 463
 				$data = array();
464 464
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -476,96 +476,96 @@  discard block
 block discarded – undo
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477 477
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 480
 				} else {
481
-				    $data['datetime'] = date('Y-m-d H:i:s');
481
+					$data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
483 483
 				$data['format_source'] = 'aisnmeahttp';
484 484
 				$data['id_source'] = $id_source;
485 485
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486 486
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
487 487
 				unset($data);
488
-			    }
488
+				}
489
+			}
489 490
 			}
490
-		    }
491 491
 		} else {
492
-		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
495
-		    if ($tt[$format] > 30) {
492
+			$format = $value['format'];
493
+			if (isset($tt[$format])) $tt[$format]++;
494
+			else $tt[$format] = 0;
495
+			if ($tt[$format] > 30) {
496 496
 			if ($globalDebug) echo 'Reconnect...'."\n";
497 497
 			sleep(2);
498 498
 			$sourceeen[] = $value;
499 499
 			connect_all($sourceeen);
500 500
 			$sourceeen = array();
501
-		    }
501
+			}
502
+		}
502 503
 		}
503
-	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
506
-	    if ($buffer != '') {
505
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
506
+		if ($buffer != '') {
507 507
 		//echo $buffer;
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511
-		    foreach ($all_data[0]['DATA'] as $line) {
511
+			foreach ($all_data[0]['DATA'] as $line) {
512 512
 			if ($line != '') {
513
-			    $data = array();
514
-			    $data['ident'] = $line['NAME'];
515
-			    $data['mmsi'] = $line['MMSI'];
516
-			    $data['speed'] = $line['SOG'];
517
-			    $data['heading'] = $line['COG'];
518
-			    $data['latitude'] = $line['LAT'];
519
-			    $data['longitude'] = $line['LNG'];
520
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
-			    $data['imo'] = $line['IMO'];
522
-			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
-			    $data['format_source'] = 'myshiptracking';
525
-			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
-			    $MI->add($data);
528
-			    unset($data);
513
+				$data = array();
514
+				$data['ident'] = $line['NAME'];
515
+				$data['mmsi'] = $line['MMSI'];
516
+				$data['speed'] = $line['SOG'];
517
+				$data['heading'] = $line['COG'];
518
+				$data['latitude'] = $line['LAT'];
519
+				$data['longitude'] = $line['LNG'];
520
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
+				$data['imo'] = $line['IMO'];
522
+				//$data['arrival_code'] = $ais_data['destination'];
523
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
+				$data['format_source'] = 'myshiptracking';
525
+				$data['id_source'] = $id_source;
526
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
+				$MI->add($data);
528
+				unset($data);
529
+			}
529 530
 			}
530
-		    }
531 531
 		}
532
-	    }
533
-	    $last_exec[$id]['last'] = time();
532
+		}
533
+		$last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
-	    if ($buffer != '') {
535
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
+		if ($buffer != '') {
537 537
 		$all_data = json_decode($buffer,true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539
-		    foreach ($all_data as $line) {
539
+			foreach ($all_data as $line) {
540 540
 			if ($line != '') {
541
-			    $data = array();
542
-			    $data['ident'] = $line['shipname'];
543
-			    $data['callsign'] = $line['callsign'];
544
-			    $data['mmsi'] = $line['mmsi'];
545
-			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
-			    $data['latitude'] = $line['latitude'];
548
-			    $data['longitude'] = $line['longitude'];
549
-			    $data['type_id'] = $line['shiptype'];
550
-			    $data['arrival_code'] = $line['destination'];
551
-			    $data['datetime'] = $line['time'];
552
-			    $data['format_source'] = 'boatbeaconapp';
553
-			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
-			    $MI->add($data);
556
-			    unset($data);
541
+				$data = array();
542
+				$data['ident'] = $line['shipname'];
543
+				$data['callsign'] = $line['callsign'];
544
+				$data['mmsi'] = $line['mmsi'];
545
+				$data['speed'] = $line['sog'];
546
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
+				$data['latitude'] = $line['latitude'];
548
+				$data['longitude'] = $line['longitude'];
549
+				$data['type_id'] = $line['shiptype'];
550
+				$data['arrival_code'] = $line['destination'];
551
+				$data['datetime'] = $line['time'];
552
+				$data['format_source'] = 'boatbeaconapp';
553
+				$data['id_source'] = $id_source;
554
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
+				$MI->add($data);
556
+				unset($data);
557
+			}
557 558
 			}
558
-		    }
559 559
 		}
560 560
 		
561
-	    }
562
-    	    $last_exec[$id]['last'] = time();
561
+		}
562
+			$last_exec[$id]['last'] = time();
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564
-	    $buffer = $Common->getData($value['host']);
565
-	    if ($buffer != '') {
564
+		$buffer = $Common->getData($value['host']);
565
+		if ($buffer != '') {
566 566
 		$all_data = json_decode($buffer,true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568
-		    foreach ($all_data['features'] as $line) {
568
+			foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
570 570
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571 571
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -584,59 +584,59 @@  discard block
 block discarded – undo
584 584
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585 585
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
586 586
 			unset($data);
587
-		    }
587
+			}
588 588
 		}
589 589
 		
590
-	    }
591
-    	    $last_exec[$id]['last'] = time();
590
+		}
591
+			$last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593
-	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
-	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    foreach ($buffer as $line) {
593
+		echo 'download...';
594
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
+		echo 'done !'."\n";
596
+		if ($buffer != '') $reset = 0;
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601
-		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
-		    //$data['status'] = substr($line,21,2);
605
-		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
609
-		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
611
-		    //$data['draft'] = substr($line,67,4);
612
-		    //$data['length'] = substr($line,72,3);
613
-		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
-		    //$data['callsign'] = trim(substr($line,100,7);
616
-		    //$data['dest'] = substr($line,108,20);
617
-		    //$data['etaDate'] = substr($line,129,5);
618
-		    //$data['etaTime'] = substr($line,135,5);
619
-		    $data['format_source'] = 'shipplotter';
620
-    		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-		    //print_r($data);
623
-		    echo 'Add...'."\n";
624
-		    $MI->add($data);
625
-		    unset($data);
601
+			$data = array();
602
+			$data['mmsi'] = (int)substr($line,0,9);
603
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
+			//$data['status'] = substr($line,21,2);
605
+			//$data['type'] = substr($line,24,3);
606
+			$data['latitude'] = substr($line,29,9);
607
+			$data['longitude'] = substr($line,41,9);
608
+			$data['speed'] = round(substr($line,51,5));
609
+			//$data['course'] = substr($line,57,5);
610
+			$data['heading'] = round(substr($line,63,3));
611
+			//$data['draft'] = substr($line,67,4);
612
+			//$data['length'] = substr($line,72,3);
613
+			//$data['beam'] = substr($line,76,2);
614
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
+			//$data['callsign'] = trim(substr($line,100,7);
616
+			//$data['dest'] = substr($line,108,20);
617
+			//$data['etaDate'] = substr($line,129,5);
618
+			//$data['etaTime'] = substr($line,135,5);
619
+			$data['format_source'] = 'shipplotter';
620
+				$data['id_source'] = $id_source;
621
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+			//print_r($data);
623
+			echo 'Add...'."\n";
624
+			$MI->add($data);
625
+			unset($data);
626 626
 		}
627
-    	    }
628
-    	    $last_exec[$id]['last'] = time();
627
+			}
628
+			$last_exec[$id]['last'] = time();
629 629
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
635
-	    $reset = 0;
636
-	    foreach ($buffer as $line) {
637
-    		if ($line != '') {
638
-    		    $line = explode(':', $line);
639
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host']);
633
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
+		$buffer = explode('\n',$buffer);
635
+		$reset = 0;
636
+		foreach ($buffer as $line) {
637
+			if ($line != '') {
638
+				$line = explode(':', $line);
639
+				if (count($line) > 30 && $line[0] != 'callsign') {
640 640
 			$data = array();
641 641
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -649,37 +649,37 @@  discard block
 block discarded – undo
649 649
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650 650
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
651 651
 			$data['latitude'] = $line[5]; // lat
652
-	        	$data['longitude'] = $line[6]; // long
653
-	        	$data['verticalrate'] = ''; // vertical rate
654
-	        	$data['squawk'] = ''; // squawk
655
-	        	$data['emergency'] = ''; // emergency
656
-	        	$data['waypoints'] = $line[30];
652
+				$data['longitude'] = $line[6]; // long
653
+				$data['verticalrate'] = ''; // vertical rate
654
+				$data['squawk'] = ''; // squawk
655
+				$data['emergency'] = ''; // emergency
656
+				$data['waypoints'] = $line[30];
657 657
 			$data['datetime'] = date('Y-m-d H:i:s');
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660
-		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
-		        $data['arrival_airport_icao'] = $line[13];
660
+				$data['departure_airport_icao'] = $line[11];
661
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
+				$data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
665 665
 			$data['range'] = $line[19];
666 666
 			if (isset($line[35])) $data['info'] = $line[35];
667
-    			$data['id_source'] = $id_source;
668
-	    		//$data['arrival_airport_time'] = ;
669
-	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
671
-	    		    if (isset($aircraft_data[1])) {
672
-	    			$data['aircraft_icao'] = $aircraft_data[1];
673
-	    		    }
674
-        		}
675
-	    		/*
667
+				$data['id_source'] = $id_source;
668
+				//$data['arrival_airport_time'] = ;
669
+				if ($line[9] != '') {
670
+					$aircraft_data = explode('/',$line[9]);
671
+					if (isset($aircraft_data[1])) {
672
+					$data['aircraft_icao'] = $aircraft_data[1];
673
+					}
674
+				}
675
+				/*
676 676
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
677 677
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 678
 	    		*/
679
-	    		$data['format_source'] = $value['format'];
679
+				$data['format_source'] = $value['format'];
680 680
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681 681
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
682
+				if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685 685
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -700,16 +700,16 @@  discard block
 block discarded – undo
700 700
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
701 701
 				}
702 702
 			}
703
-    			unset($data);
704
-    		    }
705
-    		}
706
-    	    }
707
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
-    	    $last_exec[$id]['last'] = time();
710
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
-	    if ($buffer != '') {
703
+				unset($data);
704
+				}
705
+			}
706
+			}
707
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
+			$last_exec[$id]['last'] = time();
710
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
+		if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714 714
 		foreach($all_data->children() as $childdata) {
715 715
 			$data = array();
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 			$SI->add($data);
732 732
 			unset($data);
733 733
 		}
734
-	    }
735
-	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
-	    if ($buffer != '') {
734
+		}
735
+		$Source->deleteOldLocationByType('gs');
736
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
+		if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739 739
 		foreach($all_data->children() as $childdata) {
740 740
 			$data = array();
@@ -752,249 +752,249 @@  discard block
 block discarded – undo
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755
-	    }
756
-	    $last_exec[$id]['last'] = time();
755
+		}
756
+		$last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
759
-	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
761
-	    if (isset($all_data['acList'])) {
758
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
759
+		if ($buffer != '') {
760
+		$all_data = json_decode($buffer,true);
761
+		if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
764
-		    $data = array();
765
-		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
-		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
-		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
764
+			$data = array();
765
+			$data['hex'] = $line['Icao']; // hex
766
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
+			//$data['verticalrate'] = $line['']; // verticale rate
773
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
+			$data['emergency'] = ''; // emergency
775
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
777
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
+			else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780
-		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
-	    	    $data['format_source'] = 'aircraftlistjson';
783
-		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
787
-		    unset($data);
780
+			//$data['datetime'] = date('Y-m-d H:i:s');
781
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
+				$data['format_source'] = 'aircraftlistjson';
783
+			$data['id_source'] = $id_source;
784
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
+			if (isset($data['latitude'])) $SI->add($data);
787
+			unset($data);
788 788
 		}
789
-	    } elseif (is_array($all_data)) {
789
+		} elseif (is_array($all_data)) {
790 790
 		$reset = 0;
791 791
 		foreach ($all_data as $line) {
792
-		    $data = array();
793
-		    $data['hex'] = $line['hex']; // hex
794
-		    $data['ident'] = $line['flight']; // ident
795
-		    $data['altitude'] = $line['altitude']; // altitude
796
-		    $data['speed'] = $line['speed']; // speed
797
-		    $data['heading'] = $line['track']; // heading
798
-		    $data['latitude'] = $line['lat']; // lat
799
-		    $data['longitude'] = $line['lon']; // long
800
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
801
-		    $data['squawk'] = $line['squawk']; // squawk
802
-		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
805
-	    	    $data['format_source'] = 'aircraftlistjson';
806
-    		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
-		    $SI->add($data);
810
-		    unset($data);
792
+			$data = array();
793
+			$data['hex'] = $line['hex']; // hex
794
+			$data['ident'] = $line['flight']; // ident
795
+			$data['altitude'] = $line['altitude']; // altitude
796
+			$data['speed'] = $line['speed']; // speed
797
+			$data['heading'] = $line['track']; // heading
798
+			$data['latitude'] = $line['lat']; // lat
799
+			$data['longitude'] = $line['lon']; // long
800
+			$data['verticalrate'] = $line['vrt']; // verticale rate
801
+			$data['squawk'] = $line['squawk']; // squawk
802
+			$data['emergency'] = ''; // emergency
803
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
+			else $data['datetime'] = date('Y-m-d H:i:s');
805
+				$data['format_source'] = 'aircraftlistjson';
806
+				$data['id_source'] = $id_source;
807
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
+			$SI->add($data);
810
+			unset($data);
811
+		}
811 812
 		}
812
-	    }
813
-	    }
814
-    	    //$last_exec['aircraftlistjson'] = time();
815
-    	    $last_exec[$id]['last'] = time();
816
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
-	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
820
-	    if (isset($all_data['planes'])) {
813
+		}
814
+			//$last_exec['aircraftlistjson'] = time();
815
+			$last_exec[$id]['last'] = time();
816
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
+		$buffer = $Common->getData($value['host']);
819
+		$all_data = json_decode($buffer,true);
820
+		if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
823
-		    $data = array();
824
-		    $data['hex'] = $key; // hex
825
-		    $data['ident'] = $line[3]; // ident
826
-		    $data['altitude'] = $line[6]; // altitude
827
-		    $data['speed'] = $line[8]; // speed
828
-		    $data['heading'] = $line[7]; // heading
829
-		    $data['latitude'] = $line[4]; // lat
830
-		    $data['longitude'] = $line[5]; // long
831
-		    //$data['verticalrate'] = $line[]; // verticale rate
832
-		    $data['squawk'] = $line[10]; // squawk
833
-		    $data['emergency'] = ''; // emergency
834
-		    $data['registration'] = $line[2];
835
-		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
837
-		    if (count($deparr) == 2) {
823
+			$data = array();
824
+			$data['hex'] = $key; // hex
825
+			$data['ident'] = $line[3]; // ident
826
+			$data['altitude'] = $line[6]; // altitude
827
+			$data['speed'] = $line[8]; // speed
828
+			$data['heading'] = $line[7]; // heading
829
+			$data['latitude'] = $line[4]; // lat
830
+			$data['longitude'] = $line[5]; // long
831
+			//$data['verticalrate'] = $line[]; // verticale rate
832
+			$data['squawk'] = $line[10]; // squawk
833
+			$data['emergency'] = ''; // emergency
834
+			$data['registration'] = $line[2];
835
+			$data['aircraft_icao'] = $line[0];
836
+			$deparr = explode('-',$line[1]);
837
+			if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840
-		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
-	    	    $data['format_source'] = 'planeupdatefaa';
843
-    		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
-		    $SI->add($data);
847
-		    unset($data);
840
+			}
841
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
+				$data['format_source'] = 'planeupdatefaa';
843
+				$data['id_source'] = $id_source;
844
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
+			$SI->add($data);
847
+			unset($data);
848 848
 		}
849
-	    }
850
-    	    //$last_exec['planeupdatefaa'] = time();
851
-    	    $last_exec[$id]['last'] = time();
852
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
-	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
855
-	    if (isset($all_data['states'])) {
849
+		}
850
+			//$last_exec['planeupdatefaa'] = time();
851
+			$last_exec[$id]['last'] = time();
852
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
+		$buffer = $Common->getData($value['host']);
854
+		$all_data = json_decode($buffer,true);
855
+		if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
858
-		    $data = array();
859
-		    $data['hex'] = $line[0]; // hex
860
-		    $data['ident'] = trim($line[1]); // ident
861
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
862
-		    $data['speed'] = round($line[9]*1.94384); // speed
863
-		    $data['heading'] = round($line[10]); // heading
864
-		    $data['latitude'] = $line[6]; // lat
865
-		    $data['longitude'] = $line[5]; // long
866
-		    $data['verticalrate'] = $line[11]; // verticale rate
867
-		    //$data['squawk'] = $line[10]; // squawk
868
-		    //$data['emergency'] = ''; // emergency
869
-		    //$data['registration'] = $line[2];
870
-		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
-	    	    $data['format_source'] = 'opensky';
873
-    		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
-		    $SI->add($data);
876
-		    unset($data);
858
+			$data = array();
859
+			$data['hex'] = $line[0]; // hex
860
+			$data['ident'] = trim($line[1]); // ident
861
+			$data['altitude'] = round($line[7]*3.28084); // altitude
862
+			$data['speed'] = round($line[9]*1.94384); // speed
863
+			$data['heading'] = round($line[10]); // heading
864
+			$data['latitude'] = $line[6]; // lat
865
+			$data['longitude'] = $line[5]; // long
866
+			$data['verticalrate'] = $line[11]; // verticale rate
867
+			//$data['squawk'] = $line[10]; // squawk
868
+			//$data['emergency'] = ''; // emergency
869
+			//$data['registration'] = $line[2];
870
+			//$data['aircraft_icao'] = $line[0];
871
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
+				$data['format_source'] = 'opensky';
873
+				$data['id_source'] = $id_source;
874
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
+			$SI->add($data);
876
+			unset($data);
877
+		}
877 878
 		}
878
-	    }
879
-    	    //$last_exec['planeupdatefaa'] = time();
880
-    	    $last_exec[$id]['last'] = time();
881
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
-	    //$buffer = $Common->getData($hosts[$id]);
884
-	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
887
-	    foreach ($all_data as $key => $line) {
879
+			//$last_exec['planeupdatefaa'] = time();
880
+			$last_exec[$id]['last'] = time();
881
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
+		//$buffer = $Common->getData($hosts[$id]);
884
+		$buffer = $Common->getData($value['host']);
885
+		$all_data = json_decode($buffer,true);
886
+		if (!empty($all_data)) $reset = 0;
887
+		foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889
-		    $data = array();
890
-		    $data['hex'] = $line[0];
891
-		    $data['ident'] = $line[16]; //$line[13]
892
-	    	    $data['altitude'] = $line[4]; // altitude
893
-	    	    $data['speed'] = $line[5]; // speed
894
-	    	    $data['heading'] = $line[3]; // heading
895
-	    	    $data['latitude'] = $line[1]; // lat
896
-	    	    $data['longitude'] = $line[2]; // long
897
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
898
-	    	    $data['squawk'] = $line[6]; // squawk
899
-	    	    $data['aircraft_icao'] = $line[8];
900
-	    	    $data['registration'] = $line[9];
901
-		    $data['departure_airport_iata'] = $line[11];
902
-		    $data['arrival_airport_iata'] = $line[12];
903
-	    	    $data['emergency'] = ''; // emergency
904
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
-	    	    $data['format_source'] = 'fr24json';
906
-    		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
-		    $SI->add($data);
910
-		    unset($data);
889
+			$data = array();
890
+			$data['hex'] = $line[0];
891
+			$data['ident'] = $line[16]; //$line[13]
892
+				$data['altitude'] = $line[4]; // altitude
893
+				$data['speed'] = $line[5]; // speed
894
+				$data['heading'] = $line[3]; // heading
895
+				$data['latitude'] = $line[1]; // lat
896
+				$data['longitude'] = $line[2]; // long
897
+				$data['verticalrate'] = $line[15]; // verticale rate
898
+				$data['squawk'] = $line[6]; // squawk
899
+				$data['aircraft_icao'] = $line[8];
900
+				$data['registration'] = $line[9];
901
+			$data['departure_airport_iata'] = $line[11];
902
+			$data['arrival_airport_iata'] = $line[12];
903
+				$data['emergency'] = ''; // emergency
904
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
+				$data['format_source'] = 'fr24json';
906
+				$data['id_source'] = $id_source;
907
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
+			$SI->add($data);
910
+			unset($data);
911 911
 		}
912
-	    }
913
-    	    //$last_exec['fr24json'] = time();
914
-    	    $last_exec[$id]['last'] = time();
915
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
919
-	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
923
-	    if (json_last_error() != JSON_ERROR_NONE) {
912
+		}
913
+			//$last_exec['fr24json'] = time();
914
+			$last_exec[$id]['last'] = time();
915
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
919
+		//echo $buffer;
920
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
921
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
+		$all_data = json_decode($buffer,true);
923
+		if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925
-	    }
926
-	    if (isset($all_data['mrkrs'])) {
925
+		}
926
+		if (isset($all_data['mrkrs'])) {
927 927
 		$reset = 0;
928 928
 		foreach ($all_data['mrkrs'] as $key => $line) {
929
-		    if (isset($line['inf'])) {
929
+			if (isset($line['inf'])) {
930 930
 			$data = array();
931 931
 			$data['hex'] = $line['inf']['ia'];
932 932
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
933
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
-	    		$data['latitude'] = $line['pt'][0]; // lat
937
-	    		$data['longitude'] = $line['pt'][1]; // long
938
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
-	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
933
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
+				$data['latitude'] = $line['pt'][0]; // lat
937
+				$data['longitude'] = $line['pt'][1]; // long
938
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
+				//$data['aircraft_icao'] = $line[8];
941
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944
-	    		//$data['emergency'] = ''; // emergency
944
+				//$data['emergency'] = ''; // emergency
945 945
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946
-	    		$data['format_source'] = 'radarvirtueljson';
947
-    			$data['id_source'] = $id_source;
946
+				$data['format_source'] = 'radarvirtueljson';
947
+				$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949 949
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
950 950
 			$SI->add($data);
951 951
 			unset($data);
952
-		    }
952
+			}
953
+		}
953 954
 		}
954
-	    }
955
-    	    //$last_exec['radarvirtueljson'] = time();
956
-    	    $last_exec[$id]['last'] = time();
957
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
-	    //$buffer = $Common->getData($hosts[$id]);
960
-	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
955
+			//$last_exec['radarvirtueljson'] = time();
956
+			$last_exec[$id]['last'] = time();
957
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
+		//$buffer = $Common->getData($hosts[$id]);
960
+		$buffer = $Common->getData($value['host'].'?'.time());
961
+		$all_data = json_decode(utf8_encode($buffer),true);
962 962
 	    
963
-	    if (isset($all_data['pireps'])) {
963
+		if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965
-	        foreach ($all_data['pireps'] as $line) {
966
-		    $data = array();
967
-		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
-		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
-		    $data['latitude'] = $line['lat']; // lat
977
-		    $data['longitude'] = $line['lon']; // long
978
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979
-		    //$data['squawk'] = $line['squawk']; // squawk
980
-		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
-		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
989
-		    $data['format_source'] = 'pireps';
990
-    		    $data['id_source'] = $id_source;
991
-		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
-		    if ($line['icon'] == 'plane') {
965
+			foreach ($all_data['pireps'] as $line) {
966
+			$data = array();
967
+			$data['id'] = $line['id'];
968
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
+			$data['ident'] = $line['callsign']; // ident
970
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
+			$data['latitude'] = $line['lat']; // lat
977
+			$data['longitude'] = $line['lon']; // long
978
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
979
+			//$data['squawk'] = $line['squawk']; // squawk
980
+			//$data['emergency'] = ''; // emergency
981
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
+			//$data['arrival_airport_time'] = $line['arrtime'];
985
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
988
+			else $data['info'] = '';
989
+			$data['format_source'] = 'pireps';
990
+				$data['id_source'] = $id_source;
991
+			$data['datetime'] = date('Y-m-d H:i:s');
992
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
+			if ($line['icon'] == 'plane') {
995 995
 			$SI->add($data);
996
-		    //    print_r($data);
997
-    		    } elseif ($line['icon'] == 'ct') {
996
+			//    print_r($data);
997
+				} elseif ($line['icon'] == 'ct') {
998 998
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999 999
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1000
 			$typec = substr($data['ident'],-3);
@@ -1009,203 +1009,203 @@  discard block
 block discarded – undo
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011 1011
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1012
-		    }
1013
-		    unset($data);
1012
+			}
1013
+			unset($data);
1014
+		}
1014 1015
 		}
1015
-	    }
1016
-    	    //$last_exec['pirepsjson'] = time();
1017
-    	    $last_exec[$id]['last'] = time();
1018
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
-	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1022
-	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1024
-	    if ($buffer != '' && is_array($all_data)) {
1016
+			//$last_exec['pirepsjson'] = time();
1017
+			$last_exec[$id]['last'] = time();
1018
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
+		//$buffer = $Common->getData($hosts[$id]);
1021
+		if ($globalDebug) echo 'Get Data...'."\n";
1022
+		$buffer = $Common->getData($value['host']);
1023
+		$all_data = json_decode($buffer,true);
1024
+		if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027
-	    	    $data = array();
1028
-	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
-	    	    $data['ident'] = $line['flightnum']; // ident
1034
-	    	    $data['altitude'] = $line['alt']; // altitude
1035
-	    	    $data['speed'] = $line['gs']; // speed
1036
-	    	    $data['heading'] = $line['heading']; // heading
1037
-	    	    $data['latitude'] = $line['lat']; // lat
1038
-	    	    $data['longitude'] = $line['lng']; // long
1039
-	    	    $data['verticalrate'] = ''; // verticale rate
1040
-	    	    $data['squawk'] = ''; // squawk
1041
-	    	    $data['emergency'] = ''; // emergency
1042
-	    	    //$data['datetime'] = $line['lastupdate'];
1043
-	    	    //$data['last_update'] = $line['lastupdate'];
1044
-	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1049
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1050
-	    	    $data['departure_airport_time'] = $line['deptime'];
1051
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1053
-    		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
-		    if (isset($line['aircraftname'])) {
1027
+				$data = array();
1028
+				//$data['id'] = $line['id']; // id not usable
1029
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
+				$data['ident'] = $line['flightnum']; // ident
1034
+				$data['altitude'] = $line['alt']; // altitude
1035
+				$data['speed'] = $line['gs']; // speed
1036
+				$data['heading'] = $line['heading']; // heading
1037
+				$data['latitude'] = $line['lat']; // lat
1038
+				$data['longitude'] = $line['lng']; // long
1039
+				$data['verticalrate'] = ''; // verticale rate
1040
+				$data['squawk'] = ''; // squawk
1041
+				$data['emergency'] = ''; // emergency
1042
+				//$data['datetime'] = $line['lastupdate'];
1043
+				//$data['last_update'] = $line['lastupdate'];
1044
+				if (isset($value['timezone'])) {
1045
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1049
+				$data['departure_airport_icao'] = $line['depicao'];
1050
+				$data['departure_airport_time'] = $line['deptime'];
1051
+				$data['arrival_airport_icao'] = $line['arricao'];
1052
+				$data['arrival_airport_time'] = $line['arrtime'];
1053
+				$data['registration'] = $line['aircraft'];
1054
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
+			if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1058
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
-	    		}
1067
-	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
-    		    $data['id_source'] = $id_source;
1070
-	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
-		    $SI->add($data);
1073
-		    unset($data);
1059
+				$aircraft_data = explode('-',$line['aircraftname']);
1060
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
+				else {
1063
+					$aircraft_data = explode(' ',$line['aircraftname']);
1064
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
+				}
1067
+				}
1068
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
+				$data['id_source'] = $id_source;
1070
+				$data['format_source'] = 'phpvmacars';
1071
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
+			$SI->add($data);
1073
+			unset($data);
1074 1074
 		}
1075 1075
 		if ($globalDebug) echo 'No more data...'."\n";
1076 1076
 		unset($buffer);
1077 1077
 		unset($all_data);
1078
-	    }
1079
-    	    //$last_exec['phpvmacars'] = time();
1080
-    	    $last_exec[$id]['last'] = time();
1081
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
-	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1084
-	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1086
-	    if ($buffer != '' && is_array($all_data)) {
1078
+		}
1079
+			//$last_exec['phpvmacars'] = time();
1080
+			$last_exec[$id]['last'] = time();
1081
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
+		//$buffer = $Common->getData($hosts[$id]);
1083
+		if ($globalDebug) echo 'Get Data...'."\n";
1084
+		$buffer = $Common->getData($value['host']);
1085
+		$all_data = json_decode($buffer,true);
1086
+		if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089
-	    	    $data = array();
1090
-	    	    //$data['id'] = $line['id']; // id not usable
1091
-	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
-	    	    $data['pilot_name'] = $line['pilot_name'];
1094
-	    	    $data['pilot_id'] = $line['pilot_id'];
1095
-	    	    $data['ident'] = trim($line['callsign']); // ident
1096
-	    	    $data['altitude'] = $line['altitude']; // altitude
1097
-	    	    $data['speed'] = $line['gs']; // speed
1098
-	    	    $data['heading'] = $line['heading']; // heading
1099
-	    	    $data['latitude'] = $line['latitude']; // lat
1100
-	    	    $data['longitude'] = $line['longitude']; // long
1101
-	    	    $data['verticalrate'] = ''; // verticale rate
1102
-	    	    $data['squawk'] = ''; // squawk
1103
-	    	    $data['emergency'] = ''; // emergency
1104
-	    	    //$data['datetime'] = $line['lastupdate'];
1105
-	    	    $data['last_update'] = $line['last_update'];
1106
-		    $data['datetime'] = date('Y-m-d H:i:s');
1107
-	    	    $data['departure_airport_icao'] = $line['departure'];
1108
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1109
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111
-    		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1114
-    		    $data['id_source'] = $id_source;
1115
-	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
-		    $SI->add($data);
1119
-		    unset($data);
1089
+				$data = array();
1090
+				//$data['id'] = $line['id']; // id not usable
1091
+				$data['id'] = trim($line['flight_id']);
1092
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
+				$data['pilot_name'] = $line['pilot_name'];
1094
+				$data['pilot_id'] = $line['pilot_id'];
1095
+				$data['ident'] = trim($line['callsign']); // ident
1096
+				$data['altitude'] = $line['altitude']; // altitude
1097
+				$data['speed'] = $line['gs']; // speed
1098
+				$data['heading'] = $line['heading']; // heading
1099
+				$data['latitude'] = $line['latitude']; // lat
1100
+				$data['longitude'] = $line['longitude']; // long
1101
+				$data['verticalrate'] = ''; // verticale rate
1102
+				$data['squawk'] = ''; // squawk
1103
+				$data['emergency'] = ''; // emergency
1104
+				//$data['datetime'] = $line['lastupdate'];
1105
+				$data['last_update'] = $line['last_update'];
1106
+			$data['datetime'] = date('Y-m-d H:i:s');
1107
+				$data['departure_airport_icao'] = $line['departure'];
1108
+				//$data['departure_airport_time'] = $line['departure_time'];
1109
+				$data['arrival_airport_icao'] = $line['arrival'];
1110
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1111
+				//$data['registration'] = $line['aircraft'];
1112
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
+				$data['aircraft_icao'] = $line['plane_type'];
1114
+				$data['id_source'] = $id_source;
1115
+				$data['format_source'] = 'vam';
1116
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
+			$SI->add($data);
1119
+			unset($data);
1120 1120
 		}
1121 1121
 		if ($globalDebug) echo 'No more data...'."\n";
1122 1122
 		unset($buffer);
1123 1123
 		unset($all_data);
1124
-	    }
1125
-    	    //$last_exec['phpvmacars'] = time();
1126
-    	    $last_exec[$id]['last'] = time();
1124
+		}
1125
+			//$last_exec['phpvmacars'] = time();
1126
+			$last_exec[$id]['last'] = time();
1127 1127
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1128
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
-    	    //$last_exec[$id]['last'] = time();
1129
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
+			//$last_exec[$id]['last'] = time();
1131 1131
 
1132
-	    //$read = array( $sockets[$id] );
1133
-	    $read = $sockets;
1134
-	    $write = NULL;
1135
-	    $e = NULL;
1136
-	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1138
-	    if ($n > 0) {
1132
+		//$read = array( $sockets[$id] );
1133
+		$read = $sockets;
1134
+		$write = NULL;
1135
+		$e = NULL;
1136
+		$n = socket_select($read, $write, $e, $timeout);
1137
+		if ($e != NULL) var_dump($e);
1138
+		if ($n > 0) {
1139 1139
 		$reset = 0;
1140 1140
 		foreach ($read as $nb => $r) {
1141
-		    //$value = $formats[$nb];
1142
-		    $format = $globalSources[$nb]['format'];
1143
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1141
+			//$value = $formats[$nb];
1142
+			$format = $globalSources[$nb]['format'];
1143
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144 1144
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1145
-		    } elseif ($format == 'vrstcp') {
1145
+			} elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147
-		    } else {
1147
+			} else {
1148 1148
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1149
-		    }
1150
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
-		    //echo $buffer."\n";
1152
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1153
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
-		    $error = false;
1155
-		    //$SI::del();
1156
-		    if ($format == 'vrstcp') {
1149
+			}
1150
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
+			//echo $buffer."\n";
1152
+			// lets play nice and handle signals such as ctrl-c/kill properly
1153
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
+			$error = false;
1155
+			//$SI::del();
1156
+			if ($format == 'vrstcp') {
1157 1157
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
-		    // SBS format is CSV format
1160
-		    if ($buffer !== FALSE && $buffer != '') {
1158
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
+			// SBS format is CSV format
1160
+			if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
1162 1162
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
-			    $ACARS->add(trim($buffer));
1165
-			    $ACARS->deleteLiveAcarsData();
1163
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
+				$ACARS->add(trim($buffer));
1165
+				$ACARS->deleteLiveAcarsData();
1166 1166
 			} elseif ($format == 'raw') {
1167
-			    // AVR format
1168
-			    $data = $SBS->parse($buffer);
1169
-			    if (is_array($data)) {
1167
+				// AVR format
1168
+				$data = $SBS->parse($buffer);
1169
+				if (is_array($data)) {
1170 1170
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1171
 				$data['format_source'] = 'raw';
1172 1172
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173 1173
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174 1174
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175 1175
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1176
-			    }
1176
+				}
1177 1177
 			} elseif ($format == 'ais') {
1178
-			    $ais_data = $AIS->parse_line(trim($buffer));
1179
-			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1178
+				$ais_data = $AIS->parse_line(trim($buffer));
1179
+				$data = array();
1180
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197
-			    if (isset($ais_data['timestamp'])) {
1197
+				if (isset($ais_data['timestamp'])) {
1198 1198
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1199
-			    } else {
1199
+				} else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201
-			    }
1202
-			    $data['format_source'] = 'aisnmea';
1203
-    			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
-			    unset($data);
1206
-                        } elseif ($format == 'flightgearsp') {
1207
-                    	    //echo $buffer."\n";
1208
-                    	    if (strlen($buffer) > 5) {
1201
+				}
1202
+				$data['format_source'] = 'aisnmea';
1203
+					$data['id_source'] = $id_source;
1204
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
+				unset($data);
1206
+						} elseif ($format == 'flightgearsp') {
1207
+							//echo $buffer."\n";
1208
+							if (strlen($buffer) > 5) {
1209 1209
 				$line = explode(',',$buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1222,38 +1222,38 @@  discard block
 block discarded – undo
1222 1222
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223 1223
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1224 1224
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225
-			    }
1226
-                        } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
-			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
-			    $ACARS->deleteLiveAcarsData();
1225
+				}
1226
+						} elseif ($format == 'acars') {
1227
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
+				$ACARS->add(trim($buffer));
1229
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
+				$ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+				if (substr($buffer,0,1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235 1235
 				$line = explode(' ',$buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
-				    $data['ident'] = $userserver[0];
1240
-				    $data['registration'] = $userserver[0];
1241
-				    $data['latitude'] = $line[4];
1242
-				    $data['longitude'] = $line[5];
1243
-				    $data['altitude'] = $line[6];
1244
-				    $data['datetime'] = date('Y-m-d H:i:s');
1245
-				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1237
+					$userserver = explode('@',$line[0]);
1238
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
+					$data['ident'] = $userserver[0];
1240
+					$data['registration'] = $userserver[0];
1241
+					$data['latitude'] = $line[4];
1242
+					$data['longitude'] = $line[5];
1243
+					$data['altitude'] = $line[6];
1244
+					$data['datetime'] = date('Y-m-d H:i:s');
1245
+					$aircraft_type = $line[10];
1246
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1247
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250
+				}
1250 1251
 				}
1251
-			    }
1252 1252
 			} elseif ($format == 'beast') {
1253
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
-			    die;
1253
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
+				die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1256
+				foreach($buffer as $all_data) {
1257 1257
 				$line = json_decode('{'.$all_data.'}',true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1273,115 +1273,115 @@  discard block
 block discarded – undo
1273 1273
 				*/
1274 1274
 				$data['datetime'] = date('Y-m-d H:i:s');
1275 1275
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1276
-		    		$data['format_source'] = 'vrstcp';
1276
+					$data['format_source'] = 'vrstcp';
1277 1277
 				$data['id_source'] = $id_source;
1278 1278
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279 1279
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282
-			    }
1282
+				}
1283 1283
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1284
-			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1284
+				$line = explode("\t", $buffer);
1285
+				for($k = 0; $k < count($line); $k=$k+2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1288
-			    }
1289
-    			    if (count($lined) > 3) {
1290
-    				$data['hex'] = $lined['hexid'];
1291
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
-    				$data['id_source'] = $id_source;
1301
-    				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1287
+					$lined[$key] = $line[$k+1];
1288
+				}
1289
+					if (count($lined) > 3) {
1290
+					$data['hex'] = $lined['hexid'];
1291
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
+					$data['datetime'] = date('Y-m-d H:i:s');;
1293
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
+					$data['id_source'] = $id_source;
1301
+					$data['format_source'] = 'tsv';
1302
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304 1304
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
-    				unset($lined);
1307
-    				unset($data);
1308
-    			    } else $error = true;
1305
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
+					unset($lined);
1307
+					unset($data);
1308
+					} else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310
-			    if ($aprs_connect == 0) {
1310
+				if ($aprs_connect == 0) {
1311 1311
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1312 1312
 				$aprs_connect = 1;
1313
-			    }
1313
+				}
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318 1318
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1319
-			    }
1319
+				}
1320 1320
 			    
1321
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
-			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1325
-			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1321
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
+				//echo 'APRS data : '.$buffer."\n";
1323
+				$buffer = str_replace('APRS <- ','',$buffer);
1324
+				$buffer = str_replace('APRS -> ','',$buffer);
1325
+				//echo $buffer."\n";
1326
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1330
-				    $aprs_last_tx = time();
1331
-				    $data = array();
1332
-				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1343
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
-				    $data['latitude'] = $line['latitude'];
1346
-				    $data['longitude'] = $line['longitude'];
1347
-				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
-				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
-				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
-    				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1364
-				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
-				    $currentdate = date('Y-m-d H:i:s');
1369
-				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
-				    // Accept data if time <= system time + 20s
1372
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1330
+					$aprs_last_tx = time();
1331
+					$data = array();
1332
+					//print_r($line);
1333
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1334
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
+					else $data['datetime'] = date('Y-m-d H:i:s');
1343
+					//$data['datetime'] = date('Y-m-d H:i:s');
1344
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
+					$data['latitude'] = $line['latitude'];
1346
+					$data['longitude'] = $line['longitude'];
1347
+					//$data['verticalrate'] = $line[16];
1348
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
+					//else $data['speed'] = 0;
1350
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
+					//else $data['heading'] = 0;
1355
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
+						$data['id_source'] = $id_source;
1362
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
+					else $data['format_source'] = 'aprs';
1364
+					$data['source_name'] = $line['source'];
1365
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
+					else $data['source_type'] = 'flarm';
1367
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
+					$currentdate = date('Y-m-d H:i:s');
1369
+					$aprsdate = strtotime($data['datetime']);
1370
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
+					// Accept data if time <= system time + 20s
1372
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1374
 					$send = $SI->add($data);
1375
-				    } elseif ($data['source_type'] == 'ais') {
1375
+					} elseif ($data['source_type'] == 'ais') {
1376 1376
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1377
-				    } elseif (isset($line['stealth'])) {
1377
+					} elseif (isset($line['stealth'])) {
1378 1378
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379 1379
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1380
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1380
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1382 1382
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1383 1383
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1384
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1384
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1385 1385
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1386 1386
 					$Source->deleteOldLocationByType('gs');
1387 1387
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
@@ -1389,11 +1389,11 @@  discard block
 block discarded – undo
1389 1389
 					} else {
1390 1390
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1391 1391
 					}
1392
-				    } else {
1393
-				    	echo '/!\ Not added'."\n";
1394
-				    	print_r($line);
1395
-				    }
1396
-				    unset($data);
1392
+					} else {
1393
+						echo '/!\ Not added'."\n";
1394
+						print_r($line);
1395
+					}
1396
+					unset($data);
1397 1397
 				} 
1398 1398
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1399 1399
 					echo '!! Weather Station not yet supported'."\n";
@@ -1409,12 +1409,12 @@  discard block
 block discarded – undo
1409 1409
 				*/
1410 1410
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1411 1411
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1412
-			    }
1412
+				}
1413 1413
 			} else {
1414
-			    $line = explode(',', $buffer);
1415
-    			    if (count($line) > 20) {
1416
-    			    	$data['hex'] = $line[4];
1417
-    				/*
1414
+				$line = explode(',', $buffer);
1415
+					if (count($line) > 20) {
1416
+						$data['hex'] = $line[4];
1417
+					/*
1418 1418
     				$data['datetime'] = $line[6].' '.$line[7];
1419 1419
     					date_default_timezone_set($globalTimezone);
1420 1420
     					$datetime = new DateTime($data['datetime']);
@@ -1422,30 +1422,30 @@  discard block
 block discarded – undo
1422 1422
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1423 1423
     					date_default_timezone_set('UTC');
1424 1424
     				*/
1425
-    				// Force datetime to current UTC datetime
1426
-    				date_default_timezone_set('UTC');
1427
-    				$data['datetime'] = date('Y-m-d H:i:s');
1428
-    				$data['ident'] = trim($line[10]);
1429
-    				$data['latitude'] = $line[14];
1430
-    				$data['longitude'] = $line[15];
1431
-    				$data['verticalrate'] = $line[16];
1432
-    				$data['emergency'] = $line[20];
1433
-    				$data['speed'] = $line[12];
1434
-    				$data['squawk'] = $line[17];
1435
-    				$data['altitude'] = $line[11];
1436
-    				$data['heading'] = $line[13];
1437
-    				$data['ground'] = $line[21];
1438
-    				$data['emergency'] = $line[19];
1439
-    				$data['format_source'] = 'sbs';
1425
+					// Force datetime to current UTC datetime
1426
+					date_default_timezone_set('UTC');
1427
+					$data['datetime'] = date('Y-m-d H:i:s');
1428
+					$data['ident'] = trim($line[10]);
1429
+					$data['latitude'] = $line[14];
1430
+					$data['longitude'] = $line[15];
1431
+					$data['verticalrate'] = $line[16];
1432
+					$data['emergency'] = $line[20];
1433
+					$data['speed'] = $line[12];
1434
+					$data['squawk'] = $line[17];
1435
+					$data['altitude'] = $line[11];
1436
+					$data['heading'] = $line[13];
1437
+					$data['ground'] = $line[21];
1438
+					$data['emergency'] = $line[19];
1439
+					$data['format_source'] = 'sbs';
1440 1440
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1441
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442 1442
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1443
-    				$data['id_source'] = $id_source;
1444
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1445
-    				else $error = true;
1446
-    				unset($data);
1447
-    			    } else $error = true;
1448
-			    if ($error) {
1443
+					$data['id_source'] = $id_source;
1444
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1445
+					else $error = true;
1446
+					unset($data);
1447
+					} else $error = true;
1448
+				if ($error) {
1449 1449
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1450 1450
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1451 1451
 				} else {
@@ -1461,13 +1461,13 @@  discard block
 block discarded – undo
1461 1461
 					connect_all($sourceer);
1462 1462
 					$sourceer = array();
1463 1463
 				}
1464
-			    }
1464
+				}
1465 1465
 			}
1466 1466
 			// Sleep for xxx microseconds
1467 1467
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1468
-		    } else {
1468
+			} else {
1469 1469
 			if ($format == 'flightgearmp') {
1470
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1470
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1471 1471
 				//@socket_close($r);
1472 1472
 				sleep($globalMinFetch);
1473 1473
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1476,9 +1476,9 @@  discard block
 block discarded – undo
1476 1476
 				break;
1477 1477
 				
1478 1478
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1479
-			    if (isset($tt[$format])) $tt[$format]++;
1480
-			    else $tt[$format] = 0;
1481
-			    if ($tt[$format] > 30) {
1479
+				if (isset($tt[$format])) $tt[$format]++;
1480
+				else $tt[$format] = 0;
1481
+				if ($tt[$format] > 30) {
1482 1482
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1483 1483
 				//@socket_close($r);
1484 1484
 				sleep(2);
@@ -1489,23 +1489,23 @@  discard block
 block discarded – undo
1489 1489
 				//connect_all($globalSources);
1490 1490
 				$tt[$format]=0;
1491 1491
 				break;
1492
-			    }
1492
+				}
1493
+			}
1493 1494
 			}
1494
-		    }
1495 1495
 		}
1496
-	    } else {
1496
+		} else {
1497 1497
 		$error = socket_strerror(socket_last_error());
1498 1498
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1499 1499
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1500 1500
 			if (isset($globalDebug)) echo "Restarting...\n";
1501 1501
 			// Restart the script if possible
1502 1502
 			if (is_array($sockets)) {
1503
-			    if ($globalDebug) echo "Shutdown all sockets...";
1503
+				if ($globalDebug) echo "Shutdown all sockets...";
1504 1504
 			    
1505
-			    foreach ($sockets as $sock) {
1505
+				foreach ($sockets as $sock) {
1506 1506
 				@socket_shutdown($sock,2);
1507 1507
 				@socket_close($sock);
1508
-			    }
1508
+				}
1509 1509
 			    
1510 1510
 			}
1511 1511
 			if ($globalDebug) echo "Waiting...";
@@ -1520,13 +1520,13 @@  discard block
 block discarded – undo
1520 1520
 			if ($globalDebug) echo "Restart all connections...";
1521 1521
 			connect_all($globalSources);
1522 1522
 		}
1523
-	    }
1523
+		}
1524 1524
 	}
1525 1525
 	if ($globalDaemon === false) {
1526
-	    if ($globalDebug) echo 'Check all...'."\n";
1527
-	    $SI->checkAll();
1526
+		if ($globalDebug) echo 'Check all...'."\n";
1527
+		$SI->checkAll();
1528
+	}
1528 1529
 	}
1529
-    }
1530 1530
 }
1531 1531
 
1532 1532
 ?>
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
179
+            } else if (preg_match('/airwhere/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'airwhere';
181 181
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
182
+            } else if (preg_match('/recentpireps/i', $host)) {
183 183
         	//$formats[$id] = 'pirepsjson';
184 184
         	$globalSources[$id]['format'] = 'pirepsjson';
185 185
         	//$last_exec['pirepsjson'] = 0;
186 186
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
187
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
188 188
         	//$formats[$id] = 'fr24json';
189 189
         	$globalSources[$id]['format'] = 'fr24json';
190 190
         	//$last_exec['fr24json'] = 0;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 194
         	    exit(0);
195 195
         	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
196
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
197 197
         	//$formats[$id] = 'fr24json';
198 198
         	$globalSources[$id]['format'] = 'myshiptracking';
199 199
         	//$last_exec['fr24json'] = 0;
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
         	    exit(0);
204 204
         	}
205 205
             //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
206
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 207
         	//$formats[$id] = 'tsv';
208 208
         	$globalSources[$id]['format'] = 'tsv';
209 209
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210 210
             }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
211
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
212 212
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
213
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
214 214
     		    if ($idf !== false) {
215 215
     			$httpfeeds[$id] = $idf;
216 216
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217 217
     		    }
218 218
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219 219
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
220
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
221
+	    $hostport = explode(':', $host);
222 222
 	    if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 	    }
229 229
 	    $Common = new Common();
230 230
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
231
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
232 232
     	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
233
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
234 234
 	    }
235 235
 	    if ($s) {
236 236
     	        $sockets[$id] = $s;
237 237
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
238
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245 245
     		    } elseif ($port == '10001') {
246 246
         		//$formats[$id] = 'tsv';
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280 280
 else $timeout = 20;
281 281
 $errno = '';
282
-$errstr='';
282
+$errstr = '';
283 283
 
284 284
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 /* Initiate connections to all the hosts simultaneously */
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
291 291
 } else {
292 292
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 
315 315
 if ($use_aprs) {
316 316
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
317
-	$APRS=new APRS();
317
+	$APRS = new APRS();
318 318
 	$aprs_connect = 0;
319 319
 	$aprs_keep = 120;
320 320
 	$aprs_last_tx = time();
321 321
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
322
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
323 323
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
324
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
325 325
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
326
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327 327
 	if ($aprs_full) $aprs_filter = '';
328 328
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329 329
 	else $aprs_pass = '-1';
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 sleep(1);
338 338
 if ($globalDebug) echo "SCAN MODE \n\n";
339 339
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
340
-$endtime = time()+$globalCronEnd;
340
+$endtime = time() + $globalCronEnd;
341 341
 $i = 1;
342 342
 $tt = array();
343 343
 // Delete all ATC
344 344
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
345
-	$ATC=new ATC($Connection->db);
345
+	$ATC = new ATC($Connection->db);
346 346
 }
347 347
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	$ATC->deleteAll();
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
353
+    if (!$globalDaemon) $i = $endtime - time();
354 354
     // Delete old ATC
355 355
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366 366
 	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
367
+	    sleep($globalMinFetch - $max + 2);
368 368
 	}
369 369
     }
370 370
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	    //$buffer = $Common->getData($hosts[$id]);
378 378
 	    $buffer = $Common->getData($value['host']);
379 379
 	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
380
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
381
+	    $buffer = explode('\n', $buffer);
382 382
 	    foreach ($buffer as $line) {
383 383
     		if ($line != '' && count($line) > 7) {
384 384
     		    $line = explode(',', $line);
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
     	    $last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408 408
 	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
409
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
410 410
 	    date_default_timezone_set('UTC');
411 411
 	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
412
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
413
+	    $buffer = explode('\n', $buffer);
414 414
 	    foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416 416
 		    //echo "'".$line."'\n";
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429 429
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430 430
 		    if (isset($ais_data['timestamp'])) {
431
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
431
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433 433
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434 434
 			    $add = true;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 	    $w = $e = null;
452 452
 	    
453 453
 	    if (isset($arr[$id])) {
454
-		$nn = stream_select($arr,$w,$e,$timeout);
454
+		$nn = stream_select($arr, $w, $e, $timeout);
455 455
 		if ($nn > 0) {
456 456
 		    foreach ($httpfeeds as $feed) {
457
-			$buffer = stream_get_line($feed,2000,"\n");
458
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459
-			$buffer = explode('\n',$buffer);
457
+			$buffer = stream_get_line($feed, 2000, "\n");
458
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
459
+			$buffer = explode('\n', $buffer);
460 460
 			foreach ($buffer as $line) {
461 461
 			    if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475 475
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
477
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
480 480
 				} else {
481 481
 				    $data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
505
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
506 506
 	    if ($buffer != '') {
507 507
 		//echo $buffer;
508
-		$all_data = json_decode($buffer,true);
508
+		$all_data = json_decode($buffer, true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511 511
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521 521
 			    $data['imo'] = $line['IMO'];
522 522
 			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
523
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
524 524
 			    $data['format_source'] = 'myshiptracking';
525 525
 			    $data['id_source'] = $id_source;
526 526
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	    }
533 533
 	    $last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
536 536
 	    if ($buffer != '') {
537
-		$all_data = json_decode($buffer,true);
537
+		$all_data = json_decode($buffer, true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539 539
 		    foreach ($all_data as $line) {
540 540
 			if ($line != '') {
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564 564
 	    $buffer = $Common->getData($value['host']);
565 565
 	    if ($buffer != '') {
566
-		$all_data = json_decode($buffer,true);
566
+		$all_data = json_decode($buffer, true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568 568
 		    foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
@@ -591,27 +591,27 @@  discard block
 block discarded – undo
591 591
     	    $last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593 593
 	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
594
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
595 595
 	    echo 'done !'."\n";
596 596
 	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
597
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
598
+	    $buffer = explode('\n', $buffer);
599 599
 	    foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601 601
 		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
602
+		    $data['mmsi'] = (int) substr($line, 0, 9);
603
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
604 604
 		    //$data['status'] = substr($line,21,2);
605 605
 		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
606
+		    $data['latitude'] = substr($line, 29, 9);
607
+		    $data['longitude'] = substr($line, 41, 9);
608
+		    $data['speed'] = round(substr($line, 51, 5));
609 609
 		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
610
+		    $data['heading'] = round(substr($line, 63, 3));
611 611
 		    //$data['draft'] = substr($line,67,4);
612 612
 		    //$data['length'] = substr($line,72,3);
613 613
 		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
614
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
615 615
 		    //$data['callsign'] = trim(substr($line,100,7);
616 616
 		    //$data['dest'] = substr($line,108,20);
617 617
 		    //$data['etaDate'] = substr($line,129,5);
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
633
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
634
+	    $buffer = explode('\n', $buffer);
635 635
 	    $reset = 0;
636 636
 	    foreach ($buffer as $line) {
637 637
     		if ($line != '') {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
643 643
 			$data['pilot_id'] = $line[1];
644 644
 			$data['pilot_name'] = $line[2];
645
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
645
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
646 646
 			$data['ident'] = $line[0]; // ident
647 647
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
648 648
 			$data['speed'] = $line[8]; // speed
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660 660
 		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
661
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
662 662
 		        $data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     			$data['id_source'] = $id_source;
668 668
 	    		//$data['arrival_airport_time'] = ;
669 669
 	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
670
+	    		    $aircraft_data = explode('/', $line[9]);
671 671
 	    		    if (isset($aircraft_data[1])) {
672 672
 	    			$data['aircraft_icao'] = $aircraft_data[1];
673 673
 	    		    }
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
     			if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687
-				$typec = substr($data['ident'],-3);
685
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
686
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
687
+				$typec = substr($data['ident'], -3);
688 688
 				if ($typec == 'APP') $data['type'] = 'Approach';
689 689
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690 690
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
697 697
 				if (!isset($data['source_name'])) $data['source_name'] = '';
698 698
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
699
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
700
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
701 701
 				}
702 702
 			}
703 703
     			unset($data);
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
     	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709 709
     	    $last_exec[$id]['last'] = time();
710 710
     	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
711
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
712 712
 	    if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714
-		foreach($all_data->children() as $childdata) {
714
+		foreach ($all_data->children() as $childdata) {
715 715
 			$data = array();
716 716
 			$line = $childdata;
717 717
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
718
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
719
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720
-			$data['latitude'] = (float)$line['pktLatitude'];
721
-			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
724
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
718
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
719
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
720
+			$data['latitude'] = (float) $line['pktLatitude'];
721
+			$data['longitude'] = (float) $line['pktLongitude'];
722
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
723
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
724
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
725 725
 			$data['altitude_relative'] = 'AMSL';
726
-			$data['pilot_id'] = (int)$line['pktPilotID'];
726
+			$data['pilot_id'] = (int) $line['pktPilotID'];
727 727
 			$data['aircraft_icao'] = 'PARAGLIDER';
728
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
728
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729 729
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
730 730
 			$data['format_source'] = $value['format'];
731 731
 			$SI->add($data);
@@ -733,31 +733,31 @@  discard block
 block discarded – undo
733 733
 		}
734 734
 	    }
735 735
 	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
736
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
737 737
 	    if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739
-		foreach($all_data->children() as $childdata) {
739
+		foreach ($all_data->children() as $childdata) {
740 740
 			$data = array();
741 741
 			$line = $childdata;
742
-			$data['id'] = (int)$line['gsID'];
743
-			$data['latitude'] = (float)$line['gsLatitude'];
744
-			$data['longitude'] = (float)$line['gsLongitude'];
745
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
742
+			$data['id'] = (int) $line['gsID'];
743
+			$data['latitude'] = (float) $line['gsLatitude'];
744
+			$data['longitude'] = (float) $line['gsLongitude'];
745
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
746 746
 			$data['altitude_relative'] = 'AMSL';
747
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
747
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
748 748
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
749
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
749
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
750 750
 			} else {
751
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
751
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755 755
 	    }
756 756
 	    $last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
758
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
759 759
 	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
760
+	    $all_data = json_decode($buffer, true);
761 761
 	    if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		    $data['emergency'] = ''; // emergency
775 775
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
777
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
778 778
 		    else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780 780
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 801
 		    $data['squawk'] = $line['squawk']; // squawk
802 802
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
803
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
804 804
 		    else $data['datetime'] = date('Y-m-d H:i:s');
805 805
 	    	    $data['format_source'] = 'aircraftlistjson';
806 806
     		    $data['id_source'] = $id_source;
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817 817
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818 818
 	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
819
+	    $all_data = json_decode($buffer, true);
820 820
 	    if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
 		    $data['emergency'] = ''; // emergency
834 834
 		    $data['registration'] = $line[2];
835 835
 		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
836
+		    $deparr = explode('-', $line[1]);
837 837
 		    if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840 840
 		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
841
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
842 842
 	    	    $data['format_source'] = 'planeupdatefaa';
843 843
     		    $data['id_source'] = $id_source;
844 844
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     	    $last_exec[$id]['last'] = time();
852 852
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853 853
 	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
854
+	    $all_data = json_decode($buffer, true);
855 855
 	    if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 		    //$data['emergency'] = ''; // emergency
869 869
 		    //$data['registration'] = $line[2];
870 870
 		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
871
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
872 872
 	    	    $data['format_source'] = 'opensky';
873 873
     		    $data['id_source'] = $id_source;
874 874
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883 883
 	    //$buffer = $Common->getData($hosts[$id]);
884 884
 	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
885
+	    $all_data = json_decode($buffer, true);
886 886
 	    if (!empty($all_data)) $reset = 0;
887 887
 	    foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916 916
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917 917
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
918
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
919 919
 	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
920
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
921
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
922
+	    $all_data = json_decode($buffer, true);
923 923
 	    if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925 925
 	    }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944 944
 	    		//$data['emergency'] = ''; // emergency
945
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
945
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
946 946
 	    		$data['format_source'] = 'radarvirtueljson';
947 947
     			$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -958,14 +958,14 @@  discard block
 block discarded – undo
958 958
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959 959
 	    //$buffer = $Common->getData($hosts[$id]);
960 960
 	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
961
+	    $all_data = json_decode(utf8_encode($buffer), true);
962 962
 	    
963 963
 	    if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965 965
 	        foreach ($all_data['pireps'] as $line) {
966 966
 		    $data = array();
967 967
 		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
968
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
969 969
 		    $data['ident'] = $line['callsign']; // ident
970 970
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971 971
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -995,9 +995,9 @@  discard block
 block discarded – undo
995 995
 			$SI->add($data);
996 996
 		    //    print_r($data);
997 997
     		    } elseif ($line['icon'] == 'ct') {
998
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000
-			$typec = substr($data['ident'],-3);
998
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
999
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1000
+			$typec = substr($data['ident'], -3);
1001 1001
 			$data['type'] = '';
1002 1002
 			if ($typec == 'APP') $data['type'] = 'Approach';
1003 1003
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1011
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1012 1012
 		    }
1013 1013
 		    unset($data);
1014 1014
 		}
@@ -1020,14 +1020,14 @@  discard block
 block discarded – undo
1020 1020
 	    //$buffer = $Common->getData($hosts[$id]);
1021 1021
 	    if ($globalDebug) echo 'Get Data...'."\n";
1022 1022
 	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1023
+	    $all_data = json_decode($buffer, true);
1024 1024
 	    if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027 1027
 	    	    $data = array();
1028 1028
 	    	    //$data['id'] = $line['id']; // id not usable
1029 1029
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1030
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1031 1031
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032 1032
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033 1033
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	    	    //$data['datetime'] = $line['lastupdate'];
1043 1043
 	    	    //$data['last_update'] = $line['lastupdate'];
1044 1044
 	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1045
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1046 1046
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1047
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048 1048
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056 1056
 		    if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1058
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1059
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1060 1060
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061 1061
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062 1062
 	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1063
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1064
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1065
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1066 1066
 	    		}
1067 1067
 	    	    }
1068 1068
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1082,14 +1082,14 @@  discard block
 block discarded – undo
1082 1082
 	    //$buffer = $Common->getData($hosts[$id]);
1083 1083
 	    if ($globalDebug) echo 'Get Data...'."\n";
1084 1084
 	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1085
+	    $all_data = json_decode($buffer, true);
1086 1086
 	    if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089 1089
 	    	    $data = array();
1090 1090
 	    	    //$data['id'] = $line['id']; // id not usable
1091 1091
 	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1092
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1093 1093
 	    	    $data['pilot_name'] = $line['pilot_name'];
1094 1094
 	    	    $data['pilot_id'] = $line['pilot_id'];
1095 1095
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
 		    //$value = $formats[$nb];
1142 1142
 		    $format = $globalSources[$nb]['format'];
1143 1143
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1144
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1145 1145
 		    } elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147 1147
 		    } else {
1148
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1148
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1149 1149
 		    }
1150 1150
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151 1151
 		    //echo $buffer."\n";
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		    $error = false;
1155 1155
 		    //$SI::del();
1156 1156
 		    if ($format == 'vrstcp') {
1157
-			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1157
+			$buffer = explode('},{', $buffer);
1158
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1159 1159
 		    // SBS format is CSV format
1160 1160
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
@@ -1189,13 +1189,13 @@  discard block
 block discarded – undo
1189 1189
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190 1190
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191 1191
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1192
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1193 1193
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194 1194
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195 1195
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197 1197
 			    if (isset($ais_data['timestamp'])) {
1198
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1198
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1199 1199
 			    } else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201 1201
 			    }
@@ -1206,10 +1206,10 @@  discard block
 block discarded – undo
1206 1206
                         } elseif ($format == 'flightgearsp') {
1207 1207
                     	    //echo $buffer."\n";
1208 1208
                     	    if (strlen($buffer) > 5) {
1209
-				$line = explode(',',$buffer);
1209
+				$line = explode(',', $buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1212
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1212
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1213 1213
 				$data['ident'] = $line[6];
1214 1214
 				$data['aircraft_name'] = $line[7];
1215 1215
 				$data['longitude'] = $line[1];
@@ -1226,16 +1226,16 @@  discard block
 block discarded – undo
1226 1226
                         } elseif ($format == 'acars') {
1227 1227
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228 1228
 			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1229
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1230 1230
 			    $ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+			    if (substr($buffer, 0, 1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235
-				$line = explode(' ',$buffer);
1235
+				$line = explode(' ', $buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1237
+				    $userserver = explode('@', $line[0]);
1238
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1239 1239
 				    $data['ident'] = $userserver[0];
1240 1240
 				    $data['registration'] = $userserver[0];
1241 1241
 				    $data['latitude'] = $line[4];
@@ -1243,8 +1243,8 @@  discard block
 block discarded – undo
1243 1243
 				    $data['altitude'] = $line[6];
1244 1244
 				    $data['datetime'] = date('Y-m-d H:i:s');
1245 1245
 				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1246
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1247
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1248 1248
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249 1249
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250 1250
 				}
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254 1254
 			    die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1257
-				$line = json_decode('{'.$all_data.'}',true);
1256
+			    foreach ($buffer as $all_data) {
1257
+				$line = json_decode('{'.$all_data.'}', true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260 1260
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1280,16 +1280,16 @@  discard block
 block discarded – undo
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282 1282
 			    }
1283
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1283
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1284 1284
 			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1285
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1287
+			        $lined[$key] = $line[$k + 1];
1288 1288
 			    }
1289 1289
     			    if (count($lined) > 3) {
1290 1290
     				$data['hex'] = $lined['hexid'];
1291 1291
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1292
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1293 1293
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294 1294
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295 1295
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1308,22 +1308,22 @@  discard block
 block discarded – undo
1308 1308
     			    } else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1310
 			    if ($aprs_connect == 0) {
1311
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1311
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1312 1312
 				$aprs_connect = 1;
1313 1313
 			    }
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1318
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1319 1319
 			    }
1320 1320
 			    
1321 1321
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322 1322
 			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1323
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1324
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1325 1325
 			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1326
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339 1339
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340 1340
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1341
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1342 1342
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1343 1343
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344 1344
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1385,9 +1385,9 @@  discard block
 block discarded – undo
1385 1385
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1386 1386
 					$Source->deleteOldLocationByType('gs');
1387 1387
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1388
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1388
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1389 1389
 					} else {
1390
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1390
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1391 1391
 					}
1392 1392
 				    } else {
1393 1393
 				    	echo '/!\ Not added'."\n";
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 				}
1401 1401
 				 
1402 1402
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1403
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1403
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1404 1404
 				}
1405 1405
 				/*
1406 1406
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 				connect_all($sourceee);
1488 1488
 				$sourceee = array();
1489 1489
 				//connect_all($globalSources);
1490
-				$tt[$format]=0;
1490
+				$tt[$format] = 0;
1491 1491
 				break;
1492 1492
 			    }
1493 1493
 			}
@@ -1496,14 +1496,14 @@  discard block
 block discarded – undo
1496 1496
 	    } else {
1497 1497
 		$error = socket_strerror(socket_last_error());
1498 1498
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1499
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1499
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1500 1500
 			if (isset($globalDebug)) echo "Restarting...\n";
1501 1501
 			// Restart the script if possible
1502 1502
 			if (is_array($sockets)) {
1503 1503
 			    if ($globalDebug) echo "Shutdown all sockets...";
1504 1504
 			    
1505 1505
 			    foreach ($sockets as $sock) {
1506
-				@socket_shutdown($sock,2);
1506
+				@socket_shutdown($sock, 2);
1507 1507
 				@socket_close($sock);
1508 1508
 			    }
1509 1509
 			    
Please login to merge, or discard this patch.
Braces   +993 added lines, -342 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,29 +211,41 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/airwhere/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to airwhere source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/recentpireps/i',$host)) {
183 236
         	//$formats[$id] = 'pirepsjson';
184 237
         	$globalSources[$id]['format'] = 'pirepsjson';
185 238
         	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to pirepsjson source (".$host.")...\n";
241
+        	}
187 242
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188 243
         	//$formats[$id] = 'fr24json';
189 244
         	$globalSources[$id]['format'] = 'fr24json';
190 245
         	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to fr24 source (".$host.")...\n";
248
+        	}
192 249
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193 250
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 251
         	    exit(0);
@@ -197,7 +254,9 @@  discard block
 block discarded – undo
197 254
         	//$formats[$id] = 'fr24json';
198 255
         	$globalSources[$id]['format'] = 'myshiptracking';
199 256
         	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to myshiptracking source (".$host.")...\n";
259
+        	}
201 260
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202 261
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203 262
         	    exit(0);
@@ -206,17 +265,24 @@  discard block
 block discarded – undo
206 265
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 266
         	//$formats[$id] = 'tsv';
208 267
         	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to tsv source (".$host.")...\n";
270
+        	}
210 271
             }
211 272
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212 273
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213 274
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214 275
     		    if ($idf !== false) {
215 276
     			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+        		if ($globalDebug) {
278
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
279
+        		}
280
+    		    } elseif ($globalDebug) {
281
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
217 282
     		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
283
+    		} elseif ($globalDebug) {
284
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+    		}
220 286
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221 287
 	    $hostport = explode(':',$host);
222 288
 	    if (isset($hostport[1])) {
@@ -256,17 +322,25 @@  discard block
 block discarded – undo
256 322
         		//$formats[$id] = 'beast';
257 323
         		$globalSources[$id]['format'] = 'beast';
258 324
 		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
325
+		    } else {
326
+		    	$globalSources[$id]['format'] = 'sbs';
327
+		    }
260 328
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 329
 		}
262
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
+		if ($globalDebug) {
331
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
332
+		}
263 333
             } else {
264
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
334
+		if ($globalDebug) {
335
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
336
+		}
265 337
     	    }
266 338
         }
267 339
     }
268 340
 }
269
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
341
+if (!isset($globalMinFetch)) {
342
+	$globalMinFetch = 15;
343
+}
270 344
 
271 345
 // Initialize all
272 346
 $status = array();
@@ -275,13 +349,19 @@  discard block
 block discarded – undo
275 349
 $formats = array();
276 350
 $last_exec = array();
277 351
 $time = time();
278
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
279
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280
-else $timeout = 20;
352
+if (isset($globalSourcesTimeout)) {
353
+	$timeout = $globalSourcesTimeOut;
354
+} else if (isset($globalSBS1TimeOut)) {
355
+	$timeout = $globalSBS1TimeOut;
356
+} else {
357
+	$timeout = 20;
358
+}
281 359
 $errno = '';
282 360
 $errstr='';
283 361
 
284
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
362
+if (!isset($globalDaemon)) {
363
+	$globalDaemon = TRUE;
364
+}
285 365
 /* Initiate connections to all the hosts simultaneously */
286 366
 //connect_all($hosts);
287 367
 //connect_all($globalSources);
@@ -307,7 +387,9 @@  discard block
 block discarded – undo
307 387
     if (isset($source['format']) && $source['format'] == 'aprs') {
308 388
 	$aprs_connect = 0;
309 389
 	$use_aprs = true;
310
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
390
+	if (isset($source['port']) && $source['port'] == '10152') {
391
+		$aprs_full = true;
392
+	}
311 393
 	break;
312 394
     }
313 395
 }
@@ -318,25 +400,48 @@  discard block
 block discarded – undo
318 400
 	$aprs_connect = 0;
319 401
 	$aprs_keep = 120;
320 402
 	$aprs_last_tx = time();
321
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
323
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
325
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327
-	if ($aprs_full) $aprs_filter = '';
328
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329
-	else $aprs_pass = '-1';
403
+	if (isset($globalAPRSversion)) {
404
+		$aprs_version = $globalAPRSversion;
405
+	} else {
406
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
407
+	}
408
+	if (isset($globalAPRSssid)) {
409
+		$aprs_ssid = $globalAPRSssid;
410
+	} else {
411
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
412
+	}
413
+	if (isset($globalAPRSfilter)) {
414
+		$aprs_filter = $globalAPRSfilter;
415
+	} else {
416
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
417
+	}
418
+	if ($aprs_full) {
419
+		$aprs_filter = '';
420
+	}
421
+	if (isset($globalAPRSpass)) {
422
+		$aprs_pass = $globalAPRSpass;
423
+	} else {
424
+		$aprs_pass = '-1';
425
+	}
330 426
 
331
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
332
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
333
-}
427
+	if ($aprs_filter != '') {
428
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
429
+	} else {
430
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
431
+	}
432
+	}
334 433
 
335 434
 // connected - lets do some work
336
-if ($globalDebug) echo "Connected!\n";
435
+if ($globalDebug) {
436
+	echo "Connected!\n";
437
+}
337 438
 sleep(1);
338
-if ($globalDebug) echo "SCAN MODE \n\n";
339
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
439
+if ($globalDebug) {
440
+	echo "SCAN MODE \n\n";
441
+}
442
+if (!isset($globalCronEnd)) {
443
+	$globalCronEnd = 60;
444
+}
340 445
 $endtime = time()+$globalCronEnd;
341 446
 $i = 1;
342 447
 $tt = array();
@@ -350,20 +455,28 @@  discard block
 block discarded – undo
350 455
 
351 456
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 457
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
458
+    if (!$globalDaemon) {
459
+    	$i = $endtime-time();
460
+    }
354 461
     // Delete old ATC
355 462
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
463
+	if ($globalDebug) {
464
+		echo 'Delete old ATC...'."\n";
465
+	}
357 466
         $ATC->deleteOldATC();
358 467
     }
359 468
     
360 469
     if (count($last_exec) == count($globalSources)) {
361 470
 	$max = $globalMinFetch;
362 471
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
472
+	    if ((time() - $last['last']) < $max) {
473
+	    	$max = time() - $last['last'];
474
+	    }
364 475
 	}
365 476
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
477
+	    if ($globalDebug) {
478
+	    	echo 'Sleeping...'."\n";
479
+	    }
367 480
 	    sleep($globalMinFetch-$max+2);
368 481
 	}
369 482
     }
@@ -372,11 +485,15 @@  discard block
 block discarded – undo
372 485
     //foreach ($formats as $id => $value) {
373 486
     foreach ($globalSources as $id => $value) {
374 487
 	date_default_timezone_set('UTC');
375
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
488
+	if (!isset($last_exec[$id]['last'])) {
489
+		$last_exec[$id]['last'] = 0;
490
+	}
376 491
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377 492
 	    //$buffer = $Common->getData($hosts[$id]);
378 493
 	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
494
+	    if ($buffer != '') {
495
+	    	$reset = 0;
496
+	    }
380 497
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381 498
 	    $buffer = explode('\n',$buffer);
382 499
 	    foreach ($buffer as $line) {
@@ -385,20 +502,41 @@  discard block
 block discarded – undo
385 502
 	            $data = array();
386 503
 	            $data['hex'] = $line[1]; // hex
387 504
 	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
505
+	            if (isset($line[3])) {
506
+	            	$data['altitude'] = $line[3];
507
+	            }
508
+	            // altitude
509
+	            if (isset($line[4])) {
510
+	            	$data['speed'] = $line[4];
511
+	            }
512
+	            // speed
513
+	            if (isset($line[5])) {
514
+	            	$data['heading'] = $line[5];
515
+	            }
516
+	            // heading
517
+	            if (isset($line[6])) {
518
+	            	$data['latitude'] = $line[6];
519
+	            }
520
+	            // lat
521
+	            if (isset($line[7])) {
522
+	            	$data['longitude'] = $line[7];
523
+	            }
524
+	            // long
393 525
 	            $data['verticalrate'] = ''; // vertical rate
394 526
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395 527
 	            $data['emergency'] = ''; // emergency
396 528
 		    $data['datetime'] = date('Y-m-d H:i:s');
397 529
 		    $data['format_source'] = 'deltadbtxt';
398 530
     		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
531
+		    if (isset($value['name']) && $value['name'] != '') {
532
+		    	$data['source_name'] = $value['name'];
533
+		    }
534
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
535
+		    	$data['noarchive'] = true;
536
+		    }
537
+		    if (isset($value['sourcestats'])) {
538
+		    	$data['sourcestats'] = $value['sourcestats'];
539
+		    }
402 540
     		    $SI->add($data);
403 541
 		    unset($data);
404 542
     		}
@@ -408,7 +546,9 @@  discard block
 block discarded – undo
408 546
 	    date_default_timezone_set('CET');
409 547
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410 548
 	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
549
+	    if ($buffer != '') {
550
+	    	$reset = 0;
551
+	    }
412 552
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413 553
 	    $buffer = explode('\n',$buffer);
414 554
 	    foreach ($buffer as $line) {
@@ -417,16 +557,36 @@  discard block
 block discarded – undo
417 557
 		    $add = false;
418 558
 		    $ais_data = $AIS->parse_line(trim($line));
419 559
 		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
560
+		    if (isset($ais_data['ident'])) {
561
+		    	$data['ident'] = $ais_data['ident'];
562
+		    }
563
+		    if (isset($ais_data['mmsi'])) {
564
+		    	$data['mmsi'] = $ais_data['mmsi'];
565
+		    }
566
+		    if (isset($ais_data['speed'])) {
567
+		    	$data['speed'] = $ais_data['speed'];
568
+		    }
569
+		    if (isset($ais_data['heading'])) {
570
+		    	$data['heading'] = $ais_data['heading'];
571
+		    }
572
+		    if (isset($ais_data['latitude'])) {
573
+		    	$data['latitude'] = $ais_data['latitude'];
574
+		    }
575
+		    if (isset($ais_data['longitude'])) {
576
+		    	$data['longitude'] = $ais_data['longitude'];
577
+		    }
578
+		    if (isset($ais_data['status'])) {
579
+		    	$data['status'] = $ais_data['status'];
580
+		    }
581
+		    if (isset($ais_data['type'])) {
582
+		    	$data['type'] = $ais_data['type'];
583
+		    }
584
+		    if (isset($ais_data['imo'])) {
585
+		    	$data['imo'] = $ais_data['imo'];
586
+		    }
587
+		    if (isset($ais_data['callsign'])) {
588
+		    	$data['callsign'] = $ais_data['callsign'];
589
+		    }
430 590
 		    if (isset($ais_data['timestamp'])) {
431 591
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 592
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -440,8 +600,12 @@  discard block
 block discarded – undo
440 600
 		    $data['format_source'] = 'aisnmeatxt';
441 601
     		    $data['id_source'] = $id_source;
442 602
 		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
603
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
604
+		    	$data['noarchive'] = true;
605
+		    }
606
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
607
+		    	$MI->add($data);
608
+		    }
445 609
 		    unset($data);
446 610
 		}
447 611
     	    }
@@ -461,20 +625,48 @@  discard block
 block discarded – undo
461 625
 			    if ($line != '') {
462 626
 				$ais_data = $AIS->parse_line(trim($line));
463 627
 				$data = array();
464
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
465
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
466
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
467
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
468
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
469
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
470
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
471
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
472
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
473
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
474
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
628
+				if (isset($ais_data['ident'])) {
629
+					$data['ident'] = $ais_data['ident'];
630
+				}
631
+				if (isset($ais_data['mmsi'])) {
632
+					$data['mmsi'] = $ais_data['mmsi'];
633
+				}
634
+				if (isset($ais_data['speed'])) {
635
+					$data['speed'] = $ais_data['speed'];
636
+				}
637
+				if (isset($ais_data['heading'])) {
638
+					$data['heading'] = $ais_data['heading'];
639
+				}
640
+				if (isset($ais_data['latitude'])) {
641
+					$data['latitude'] = $ais_data['latitude'];
642
+				}
643
+				if (isset($ais_data['longitude'])) {
644
+					$data['longitude'] = $ais_data['longitude'];
645
+				}
646
+				if (isset($ais_data['status'])) {
647
+					$data['status'] = $ais_data['status'];
648
+				}
649
+				if (isset($ais_data['statusid'])) {
650
+					$data['status_id'] = $ais_data['statusid'];
651
+				}
652
+				if (isset($ais_data['type'])) {
653
+					$data['type'] = $ais_data['type'];
654
+				}
655
+				if (isset($ais_data['typeid'])) {
656
+					$data['type_id'] = $ais_data['typeid'];
657
+				}
658
+				if (isset($ais_data['imo'])) {
659
+					$data['imo'] = $ais_data['imo'];
660
+				}
661
+				if (isset($ais_data['callsign'])) {
662
+					$data['callsign'] = $ais_data['callsign'];
663
+				}
664
+				if (isset($ais_data['destination'])) {
665
+					$data['arrival_code'] = $ais_data['destination'];
666
+				}
667
+				if (isset($ais_data['eta_ts'])) {
668
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
669
+				}
478 670
 				if (isset($ais_data['timestamp'])) {
479 671
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 672
 				} else {
@@ -482,18 +674,27 @@  discard block
 block discarded – undo
482 674
 				}
483 675
 				$data['format_source'] = 'aisnmeahttp';
484 676
 				$data['id_source'] = $id_source;
485
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
677
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
678
+					$data['noarchive'] = true;
679
+				}
680
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
681
+					$MI->add($data);
682
+				}
487 683
 				unset($data);
488 684
 			    }
489 685
 			}
490 686
 		    }
491 687
 		} else {
492 688
 		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
689
+		    if (isset($tt[$format])) {
690
+		    	$tt[$format]++;
691
+		    } else {
692
+		    	$tt[$format] = 0;
693
+		    }
495 694
 		    if ($tt[$format] > 30) {
496
-			if ($globalDebug) echo 'Reconnect...'."\n";
695
+			if ($globalDebug) {
696
+				echo 'Reconnect...'."\n";
697
+			}
497 698
 			sleep(2);
498 699
 			$sourceeen[] = $value;
499 700
 			connect_all($sourceeen);
@@ -523,7 +724,9 @@  discard block
 block discarded – undo
523 724
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524 725
 			    $data['format_source'] = 'myshiptracking';
525 726
 			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
728
+			    	$data['noarchive'] = true;
729
+			    }
527 730
 			    $MI->add($data);
528 731
 			    unset($data);
529 732
 			}
@@ -543,7 +746,9 @@  discard block
 block discarded – undo
543 746
 			    $data['callsign'] = $line['callsign'];
544 747
 			    $data['mmsi'] = $line['mmsi'];
545 748
 			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
749
+			    if ($line['heading'] != '511') {
750
+			    	$data['heading'] = $line['heading'];
751
+			    }
547 752
 			    $data['latitude'] = $line['latitude'];
548 753
 			    $data['longitude'] = $line['longitude'];
549 754
 			    $data['type_id'] = $line['shiptype'];
@@ -551,7 +756,9 @@  discard block
 block discarded – undo
551 756
 			    $data['datetime'] = $line['time'];
552 757
 			    $data['format_source'] = 'boatbeaconapp';
553 758
 			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
759
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
760
+			    	$data['noarchive'] = true;
761
+			    }
555 762
 			    $MI->add($data);
556 763
 			    unset($data);
557 764
 			}
@@ -567,22 +774,44 @@  discard block
 block discarded – undo
567 774
 		if (isset($all_data['features'][0]['id'])) {
568 775
 		    foreach ($all_data['features'] as $line) {
569 776
 			$data = array();
570
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
572
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
573
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
574
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
575
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
777
+			if (isset($line['properties']['name'])) {
778
+				$data['ident'] = $line['properties']['name'];
779
+			}
780
+			if (isset($line['properties']['callsign'])) {
781
+				$data['callsign'] = $line['properties']['callsign'];
782
+			}
783
+			if (isset($line['properties']['mmsi'])) {
784
+				$data['mmsi'] = $line['properties']['mmsi'];
785
+			}
786
+			if (isset($line['properties']['imo'])) {
787
+				$data['mmsi'] = $line['properties']['imo'];
788
+			}
789
+			if (isset($line['properties']['speed'])) {
790
+				$data['speed'] = $line['properties']['speed'];
791
+			}
792
+			if (isset($line['properties']['heading'])) {
793
+				$data['heading'] = $line['properties']['heading'];
794
+			}
576 795
 			$data['latitude'] = $line['geometry']['coordinates'][1];
577 796
 			$data['longitude'] = $line['geometry']['coordinates'][0];
578
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
579
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
580
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
797
+			if (isset($line['properties']['vesselType'])) {
798
+				$data['type'] = $line['properties']['vesselType'];
799
+			}
800
+			if (isset($line['properties']['destination'])) {
801
+				$data['arrival_code'] = $line['properties']['destination'];
802
+			}
803
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
804
+				$data['arrival_date'] = $line['properties']['eta'];
805
+			}
581 806
 			$data['format_source'] = 'boatnerd';
582 807
 			$data['id_source'] = $id_source;
583 808
 			$data['datetime'] = date('Y-m-d H:i:s');
584
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
809
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
810
+				$data['noarchive'] = true;
811
+			}
812
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
813
+				$MI->add($data);
814
+			}
586 815
 			unset($data);
587 816
 		    }
588 817
 		}
@@ -593,7 +822,9 @@  discard block
 block discarded – undo
593 822
 	    echo 'download...';
594 823
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595 824
 	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
825
+	    if ($buffer != '') {
826
+	    	$reset = 0;
827
+	    }
597 828
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598 829
 	    $buffer = explode('\n',$buffer);
599 830
 	    foreach ($buffer as $line) {
@@ -618,7 +849,9 @@  discard block
 block discarded – undo
618 849
 		    //$data['etaTime'] = substr($line,135,5);
619 850
 		    $data['format_source'] = 'shipplotter';
620 851
     		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
852
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
853
+		    	$data['noarchive'] = true;
854
+		    }
622 855
 		    //print_r($data);
623 856
 		    echo 'Add...'."\n";
624 857
 		    $MI->add($data);
@@ -638,16 +871,28 @@  discard block
 block discarded – undo
638 871
     		    $line = explode(':', $line);
639 872
     		    if (count($line) > 30 && $line[0] != 'callsign') {
640 873
 			$data = array();
641
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
874
+			if (isset($line[37]) && $line[37] != '') {
875
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
876
+			} else {
877
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
878
+			}
643 879
 			$data['pilot_id'] = $line[1];
644 880
 			$data['pilot_name'] = $line[2];
645 881
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
646 882
 			$data['ident'] = $line[0]; // ident
647
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
883
+			if ($line[7] != '' && $line[7] != 0) {
884
+				$data['altitude'] = $line[7];
885
+			}
886
+			// altitude
648 887
 			$data['speed'] = $line[8]; // speed
649
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
888
+			if (isset($line[45])) {
889
+				$data['heading'] = $line[45];
890
+			}
891
+			// heading
892
+			elseif (isset($line[38])) {
893
+				$data['heading'] = $line[38];
894
+			}
895
+			// heading
651 896
 			$data['latitude'] = $line[5]; // lat
652 897
 	        	$data['longitude'] = $line[6]; // long
653 898
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -663,7 +908,9 @@  discard block
 block discarded – undo
663 908
 			$data['frequency'] = $line[4];
664 909
 			$data['type'] = $line[18];
665 910
 			$data['range'] = $line[19];
666
-			if (isset($line[35])) $data['info'] = $line[35];
911
+			if (isset($line[35])) {
912
+				$data['info'] = $line[35];
913
+			}
667 914
     			$data['id_source'] = $id_source;
668 915
 	    		//$data['arrival_airport_time'] = ;
669 916
 	    		if ($line[9] != '') {
@@ -677,27 +924,47 @@  discard block
 block discarded – undo
677 924
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 925
 	    		*/
679 926
 	    		$data['format_source'] = $value['format'];
680
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
683
-			elseif ($line[3] == 'ATC') {
927
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
928
+				$data['noarchive'] = true;
929
+			}
930
+			if (isset($value['name']) && $value['name'] != '') {
931
+				$data['source_name'] = $value['name'];
932
+			}
933
+    			if ($line[3] == 'PILOT') {
934
+    				$SI->add($data);
935
+    			} elseif ($line[3] == 'ATC') {
684 936
 				//print_r($data);
685 937
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686 938
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687 939
 				$typec = substr($data['ident'],-3);
688
-				if ($typec == 'APP') $data['type'] = 'Approach';
689
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
691
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
692
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
693
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
694
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
697
-				if (!isset($data['source_name'])) $data['source_name'] = '';
940
+				if ($typec == 'APP') {
941
+					$data['type'] = 'Approach';
942
+				} elseif ($typec == 'TWR') {
943
+					$data['type'] = 'Tower';
944
+				} elseif ($typec == 'OBS') {
945
+					$data['type'] = 'Observer';
946
+				} elseif ($typec == 'GND') {
947
+					$data['type'] = 'Ground';
948
+				} elseif ($typec == 'DEL') {
949
+					$data['type'] = 'Delivery';
950
+				} elseif ($typec == 'DEP') {
951
+					$data['type'] = 'Departure';
952
+				} elseif ($typec == 'FSS') {
953
+					$data['type'] = 'Flight Service Station';
954
+				} elseif ($typec == 'CTR') {
955
+					$data['type'] = 'Control Radar or Centre';
956
+				} elseif ($data['type'] == '') {
957
+					$data['type'] = 'Observer';
958
+				}
959
+				if (!isset($data['source_name'])) {
960
+					$data['source_name'] = '';
961
+				}
698 962
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
963
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
964
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
965
+					} else {
966
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
967
+					}
701 968
 				}
702 969
 			}
703 970
     			unset($data);
@@ -719,14 +986,20 @@  discard block
 block discarded – undo
719 986
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720 987
 			$data['latitude'] = (float)$line['pktLatitude'];
721 988
 			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
989
+			if ((float)$line['pktTrack'] != 0) {
990
+				$data['heading'] = (float)$line['pktTrack'];
991
+			}
992
+			if ((int)$line['pktSpeed'] != 0) {
993
+				$data['speed'] = (int)$line['pktSpeed'];
994
+			}
724 995
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
725 996
 			$data['altitude_relative'] = 'AMSL';
726 997
 			$data['pilot_id'] = (int)$line['pktPilotID'];
727 998
 			$data['aircraft_icao'] = 'PARAGLIDER';
728 999
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1000
+			if (isset($pilot_data[4])) {
1001
+				$data['pilot_name'] = $pilot_data[4];
1002
+			}
730 1003
 			$data['format_source'] = $value['format'];
731 1004
 			$SI->add($data);
732 1005
 			unset($data);
@@ -763,27 +1036,61 @@  discard block
 block discarded – undo
763 1036
 		foreach ($all_data['acList'] as $line) {
764 1037
 		    $data = array();
765 1038
 		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1039
+		    if (isset($line['Call'])) {
1040
+		    	$data['ident'] = $line['Call'];
1041
+		    }
1042
+		    // ident
1043
+		    if (isset($line['Alt'])) {
1044
+		    	$data['altitude'] = $line['Alt'];
1045
+		    }
1046
+		    // altitude
1047
+		    if (isset($line['Spd'])) {
1048
+		    	$data['speed'] = $line['Spd'];
1049
+		    }
1050
+		    // speed
1051
+		    if (isset($line['Trak'])) {
1052
+		    	$data['heading'] = $line['Trak'];
1053
+		    }
1054
+		    // heading
1055
+		    if (isset($line['Lat'])) {
1056
+		    	$data['latitude'] = $line['Lat'];
1057
+		    }
1058
+		    // lat
1059
+		    if (isset($line['Long'])) {
1060
+		    	$data['longitude'] = $line['Long'];
1061
+		    }
1062
+		    // long
772 1063
 		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1064
+		    if (isset($line['Sqk'])) {
1065
+		    	$data['squawk'] = $line['Sqk'];
1066
+		    }
1067
+		    // squawk
774 1068
 		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1069
+		    if (isset($line['Reg'])) {
1070
+		    	$data['registration'] = $line['Reg'];
1071
+		    }
776 1072
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1073
+		    if (isset($line['PosTime'])) {
1074
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1075
+		    } else {
1076
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1077
+		    }
779 1078
 		    
780 1079
 		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1080
+		    if (isset($line['Type'])) {
1081
+		    	$data['aircraft_icao'] = $line['Type'];
1082
+		    }
782 1083
 	    	    $data['format_source'] = 'aircraftlistjson';
783 1084
 		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
1085
+		    if (isset($value['name']) && $value['name'] != '') {
1086
+		    	$data['source_name'] = $value['name'];
1087
+		    }
1088
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1089
+		    	$data['noarchive'] = true;
1090
+		    }
1091
+		    if (isset($data['latitude'])) {
1092
+		    	$SI->add($data);
1093
+		    }
787 1094
 		    unset($data);
788 1095
 		}
789 1096
 	    } elseif (is_array($all_data)) {
@@ -800,12 +1107,19 @@  discard block
 block discarded – undo
800 1107
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 1108
 		    $data['squawk'] = $line['squawk']; // squawk
802 1109
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1110
+		    if (isset($line['PosTime'])) {
1111
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1112
+		    } else {
1113
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1114
+		    }
805 1115
 	    	    $data['format_source'] = 'aircraftlistjson';
806 1116
     		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1117
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1118
+		    	$data['noarchive'] = true;
1119
+		    }
1120
+		    if (isset($value['name']) && $value['name'] != '') {
1121
+		    	$data['source_name'] = $value['name'];
1122
+		    }
809 1123
 		    $SI->add($data);
810 1124
 		    unset($data);
811 1125
 		}
@@ -841,8 +1155,12 @@  discard block
 block discarded – undo
841 1155
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842 1156
 	    	    $data['format_source'] = 'planeupdatefaa';
843 1157
     		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1158
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1159
+		    	$data['noarchive'] = true;
1160
+		    }
1161
+		    if (isset($value['name']) && $value['name'] != '') {
1162
+		    	$data['source_name'] = $value['name'];
1163
+		    }
846 1164
 		    $SI->add($data);
847 1165
 		    unset($data);
848 1166
 		}
@@ -871,7 +1189,9 @@  discard block
 block discarded – undo
871 1189
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872 1190
 	    	    $data['format_source'] = 'opensky';
873 1191
     		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1193
+		    	$data['noarchive'] = true;
1194
+		    }
875 1195
 		    $SI->add($data);
876 1196
 		    unset($data);
877 1197
 		}
@@ -883,7 +1203,9 @@  discard block
 block discarded – undo
883 1203
 	    //$buffer = $Common->getData($hosts[$id]);
884 1204
 	    $buffer = $Common->getData($value['host']);
885 1205
 	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
1206
+	    if (!empty($all_data)) {
1207
+	    	$reset = 0;
1208
+	    }
887 1209
 	    foreach ($all_data as $key => $line) {
888 1210
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889 1211
 		    $data = array();
@@ -904,8 +1226,12 @@  discard block
 block discarded – undo
904 1226
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905 1227
 	    	    $data['format_source'] = 'fr24json';
906 1228
     		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1229
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1230
+		    	$data['noarchive'] = true;
1231
+		    }
1232
+		    if (isset($value['name']) && $value['name'] != '') {
1233
+		    	$data['source_name'] = $value['name'];
1234
+		    }
909 1235
 		    $SI->add($data);
910 1236
 		    unset($data);
911 1237
 		}
@@ -929,24 +1255,42 @@  discard block
 block discarded – undo
929 1255
 		    if (isset($line['inf'])) {
930 1256
 			$data = array();
931 1257
 			$data['hex'] = $line['inf']['ia'];
932
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1258
+			if (isset($line['inf']['cs'])) {
1259
+				$data['ident'] = $line['inf']['cs'];
1260
+			}
1261
+			//$line[13]
933 1262
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1263
+	    		if (isset($line['inf']['gs'])) {
1264
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1265
+	    		}
1266
+	    		// speed
1267
+	    		if (isset($line['inf']['tr'])) {
1268
+	    			$data['heading'] = $line['inf']['tr'];
1269
+	    		}
1270
+	    		// heading
936 1271
 	    		$data['latitude'] = $line['pt'][0]; // lat
937 1272
 	    		$data['longitude'] = $line['pt'][1]; // long
938 1273
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1274
+	    		if (isset($line['inf']['sq'])) {
1275
+	    			$data['squawk'] = $line['inf']['sq'];
1276
+	    		}
1277
+	    		// squawk
940 1278
 	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1279
+	    		if (isset($line['inf']['rc'])) {
1280
+	    			$data['registration'] = $line['inf']['rc'];
1281
+	    		}
942 1282
 			//$data['departure_airport_iata'] = $line[11];
943 1283
 			//$data['arrival_airport_iata'] = $line[12];
944 1284
 	    		//$data['emergency'] = ''; // emergency
945 1285
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946 1286
 	    		$data['format_source'] = 'radarvirtueljson';
947 1287
     			$data['id_source'] = $id_source;
948
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+				$data['noarchive'] = true;
1290
+			}
1291
+			if (isset($value['name']) && $value['name'] != '') {
1292
+				$data['source_name'] = $value['name'];
1293
+			}
950 1294
 			$SI->add($data);
951 1295
 			unset($data);
952 1296
 		    }
@@ -967,30 +1311,65 @@  discard block
 block discarded – undo
967 1311
 		    $data['id'] = $line['id'];
968 1312
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969 1313
 		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1314
+		    if (isset($line['pilotid'])) {
1315
+		    	$data['pilot_id'] = $line['pilotid'];
1316
+		    }
1317
+		    // pilot id
1318
+		    if (isset($line['name'])) {
1319
+		    	$data['pilot_name'] = $line['name'];
1320
+		    }
1321
+		    // pilot name
1322
+		    if (isset($line['alt'])) {
1323
+		    	$data['altitude'] = $line['alt'];
1324
+		    }
1325
+		    // altitude
1326
+		    if (isset($line['gs'])) {
1327
+		    	$data['speed'] = $line['gs'];
1328
+		    }
1329
+		    // speed
1330
+		    if (isset($line['heading'])) {
1331
+		    	$data['heading'] = $line['heading'];
1332
+		    }
1333
+		    // heading
1334
+		    if (isset($line['route'])) {
1335
+		    	$data['waypoints'] = $line['route'];
1336
+		    }
1337
+		    // route
976 1338
 		    $data['latitude'] = $line['lat']; // lat
977 1339
 		    $data['longitude'] = $line['lon']; // long
978 1340
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979 1341
 		    //$data['squawk'] = $line['squawk']; // squawk
980 1342
 		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1343
+		    if (isset($line['depicao'])) {
1344
+		    	$data['departure_airport_icao'] = $line['depicao'];
1345
+		    }
1346
+		    if (isset($line['deptime'])) {
1347
+		    	$data['departure_airport_time'] = $line['deptime'];
1348
+		    }
1349
+		    if (isset($line['arricao'])) {
1350
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1351
+		    }
984 1352
 		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
1353
+		    if (isset($line['aircraft'])) {
1354
+		    	$data['aircraft_icao'] = $line['aircraft'];
1355
+		    }
1356
+		    if (isset($line['transponder'])) {
1357
+		    	$data['squawk'] = $line['transponder'];
1358
+		    }
1359
+		    if (isset($line['atis'])) {
1360
+		    	$data['info'] = $line['atis'];
1361
+		    } else {
1362
+		    	$data['info'] = '';
1363
+		    }
989 1364
 		    $data['format_source'] = 'pireps';
990 1365
     		    $data['id_source'] = $id_source;
991 1366
 		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1367
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1368
+		    	$data['noarchive'] = true;
1369
+		    }
1370
+		    if (isset($value['name']) && $value['name'] != '') {
1371
+		    	$data['source_name'] = $value['name'];
1372
+		    }
994 1373
 		    if ($line['icon'] == 'plane') {
995 1374
 			$SI->add($data);
996 1375
 		    //    print_r($data);
@@ -999,16 +1378,28 @@  discard block
 block discarded – undo
999 1378
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1379
 			$typec = substr($data['ident'],-3);
1001 1380
 			$data['type'] = '';
1002
-			if ($typec == 'APP') $data['type'] = 'Approach';
1003
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1004
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1005
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1006
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1007
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1008
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010
-			else $data['type'] = 'Observer';
1011
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1381
+			if ($typec == 'APP') {
1382
+				$data['type'] = 'Approach';
1383
+			} elseif ($typec == 'TWR') {
1384
+				$data['type'] = 'Tower';
1385
+			} elseif ($typec == 'OBS') {
1386
+				$data['type'] = 'Observer';
1387
+			} elseif ($typec == 'GND') {
1388
+				$data['type'] = 'Ground';
1389
+			} elseif ($typec == 'DEL') {
1390
+				$data['type'] = 'Delivery';
1391
+			} elseif ($typec == 'DEP') {
1392
+				$data['type'] = 'Departure';
1393
+			} elseif ($typec == 'FSS') {
1394
+				$data['type'] = 'Flight Service Station';
1395
+			} elseif ($typec == 'CTR') {
1396
+				$data['type'] = 'Control Radar or Centre';
1397
+			} else {
1398
+				$data['type'] = 'Observer';
1399
+			}
1400
+			if (isset($ATC)) {
1401
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1402
+			}
1012 1403
 		    }
1013 1404
 		    unset($data);
1014 1405
 		}
@@ -1018,7 +1409,9 @@  discard block
 block discarded – undo
1018 1409
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019 1410
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020 1411
 	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1412
+	    if ($globalDebug) {
1413
+	    	echo 'Get Data...'."\n";
1414
+	    }
1022 1415
 	    $buffer = $Common->getData($value['host']);
1023 1416
 	    $all_data = json_decode($buffer,true);
1024 1417
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1026,10 +1419,16 @@  discard block
 block discarded – undo
1026 1419
 		foreach ($all_data as $line) {
1027 1420
 	    	    $data = array();
1028 1421
 	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1422
+	    	    if (isset($line['pilotid'])) {
1423
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1424
+	    	    }
1030 1425
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1426
+	    	    if (isset($line['pilotname'])) {
1427
+	    	    	$data['pilot_name'] = $line['pilotname'];
1428
+	    	    }
1429
+	    	    if (isset($line['pilotid'])) {
1430
+	    	    	$data['pilot_id'] = $line['pilotid'];
1431
+	    	    }
1033 1432
 	    	    $data['ident'] = $line['flightnum']; // ident
1034 1433
 	    	    $data['altitude'] = $line['alt']; // altitude
1035 1434
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1045,34 +1444,52 @@  discard block
 block discarded – undo
1045 1444
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046 1445
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1446
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1447
+	    	    } else {
1448
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1449
+	    	    }
1049 1450
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1050 1451
 	    	    $data['departure_airport_time'] = $line['deptime'];
1051 1452
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052 1453
     		    $data['arrival_airport_time'] = $line['arrtime'];
1053 1454
     		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1455
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1456
+		    	$data['noarchive'] = true;
1457
+		    }
1458
+		    if (isset($line['route'])) {
1459
+		    	$data['waypoints'] = $line['route'];
1460
+		    }
1461
+		    // route
1056 1462
 		    if (isset($line['aircraftname'])) {
1057 1463
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1464
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059 1465
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1466
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1467
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1468
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1469
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1470
+	    		} else {
1063 1471
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1472
+	    		    if (isset($aircraft_data[1])) {
1473
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1474
+	    		    } else {
1475
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1476
+	    		    }
1066 1477
 	    		}
1067 1478
 	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1479
+    		    if (isset($line['route'])) {
1480
+    		    	$data['waypoints'] = $line['route'];
1481
+    		    }
1069 1482
     		    $data['id_source'] = $id_source;
1070 1483
 	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
+		    if (isset($value['name']) && $value['name'] != '') {
1485
+		    	$data['source_name'] = $value['name'];
1486
+		    }
1072 1487
 		    $SI->add($data);
1073 1488
 		    unset($data);
1074 1489
 		}
1075
-		if ($globalDebug) echo 'No more data...'."\n";
1490
+		if ($globalDebug) {
1491
+			echo 'No more data...'."\n";
1492
+		}
1076 1493
 		unset($buffer);
1077 1494
 		unset($all_data);
1078 1495
 	    }
@@ -1080,7 +1497,9 @@  discard block
 block discarded – undo
1080 1497
     	    $last_exec[$id]['last'] = time();
1081 1498
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082 1499
 	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
+	    if ($globalDebug) {
1501
+	    	echo 'Get Data...'."\n";
1502
+	    }
1084 1503
 	    $buffer = $Common->getData($value['host']);
1085 1504
 	    $all_data = json_decode($buffer,true);
1086 1505
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1109,16 +1528,25 @@  discard block
 block discarded – undo
1109 1528
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110 1529
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111 1530
     		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1531
+		    if (isset($line['route'])) {
1532
+		    	$data['waypoints'] = $line['route'];
1533
+		    }
1534
+		    // route
1113 1535
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1114 1536
     		    $data['id_source'] = $id_source;
1115 1537
 	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1538
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1539
+		    	$data['noarchive'] = true;
1540
+		    }
1541
+		    if (isset($value['name']) && $value['name'] != '') {
1542
+		    	$data['source_name'] = $value['name'];
1543
+		    }
1118 1544
 		    $SI->add($data);
1119 1545
 		    unset($data);
1120 1546
 		}
1121
-		if ($globalDebug) echo 'No more data...'."\n";
1547
+		if ($globalDebug) {
1548
+			echo 'No more data...'."\n";
1549
+		}
1122 1550
 		unset($buffer);
1123 1551
 		unset($all_data);
1124 1552
 	    }
@@ -1126,7 +1554,9 @@  discard block
 block discarded – undo
1126 1554
     	    $last_exec[$id]['last'] = time();
1127 1555
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1556
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1557
+	    if (function_exists('pcntl_fork')) {
1558
+	    	pcntl_signal_dispatch();
1559
+	    }
1130 1560
     	    //$last_exec[$id]['last'] = time();
1131 1561
 
1132 1562
 	    //$read = array( $sockets[$id] );
@@ -1134,7 +1564,9 @@  discard block
 block discarded – undo
1134 1564
 	    $write = NULL;
1135 1565
 	    $e = NULL;
1136 1566
 	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1567
+	    if ($e != NULL) {
1568
+	    	var_dump($e);
1569
+	    }
1138 1570
 	    if ($n > 0) {
1139 1571
 		$reset = 0;
1140 1572
 		foreach ($read as $nb => $r) {
@@ -1155,12 +1587,16 @@  discard block
 block discarded – undo
1155 1587
 		    //$SI::del();
1156 1588
 		    if ($format == 'vrstcp') {
1157 1589
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1590
+		    } else {
1591
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1592
+		    }
1159 1593
 		    // SBS format is CSV format
1160 1594
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1595
 			$tt[$format] = 0;
1162 1596
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1597
+			    if ($globalDebug) {
1598
+			    	echo 'ACARS : '.$buffer."\n";
1599
+			    }
1164 1600
 			    $ACARS->add(trim($buffer));
1165 1601
 			    $ACARS->deleteLiveAcarsData();
1166 1602
 			} elseif ($format == 'raw') {
@@ -1169,30 +1605,70 @@  discard block
 block discarded – undo
1169 1605
 			    if (is_array($data)) {
1170 1606
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1607
 				$data['format_source'] = 'raw';
1172
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1608
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1609
+					$data['source_name'] = $globalSources[$nb]['name'];
1610
+				}
1611
+				if (isset($globalSources[$nb]['sourcestats'])) {
1612
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1613
+				}
1614
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1615
+					$data['noarchive'] = true;
1616
+				}
1617
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1618
+					$SI->add($data);
1619
+				}
1176 1620
 			    }
1177 1621
 			} elseif ($format == 'ais') {
1178 1622
 			    $ais_data = $AIS->parse_line(trim($buffer));
1179 1623
 			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+			    if (isset($ais_data['ident'])) {
1625
+			    	$data['ident'] = $ais_data['ident'];
1626
+			    }
1627
+			    if (isset($ais_data['mmsi'])) {
1628
+			    	$data['mmsi'] = $ais_data['mmsi'];
1629
+			    }
1630
+			    if (isset($ais_data['speed'])) {
1631
+			    	$data['speed'] = $ais_data['speed'];
1632
+			    }
1633
+			    if (isset($ais_data['heading'])) {
1634
+			    	$data['heading'] = $ais_data['heading'];
1635
+			    }
1636
+			    if (isset($ais_data['latitude'])) {
1637
+			    	$data['latitude'] = $ais_data['latitude'];
1638
+			    }
1639
+			    if (isset($ais_data['longitude'])) {
1640
+			    	$data['longitude'] = $ais_data['longitude'];
1641
+			    }
1642
+			    if (isset($ais_data['status'])) {
1643
+			    	$data['status'] = $ais_data['status'];
1644
+			    }
1645
+			    if (isset($ais_data['statusid'])) {
1646
+			    	$data['status_id'] = $ais_data['statusid'];
1647
+			    }
1648
+			    if (isset($ais_data['type'])) {
1649
+			    	$data['type'] = $ais_data['type'];
1650
+			    }
1651
+			    if (isset($ais_data['imo'])) {
1652
+			    	$data['imo'] = $ais_data['imo'];
1653
+			    }
1654
+			    if (isset($ais_data['callsign'])) {
1655
+			    	$data['callsign'] = $ais_data['callsign'];
1656
+			    }
1657
+			    if (isset($ais_data['destination'])) {
1658
+			    	$data['arrival_code'] = $ais_data['destination'];
1659
+			    }
1660
+			    if (isset($ais_data['eta_ts'])) {
1661
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1662
+			    }
1663
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1664
+			    	$data['noarchive'] = true;
1665
+			    }
1666
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1667
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1668
+			    }
1669
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1670
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1671
+			    }
1196 1672
 
1197 1673
 			    if (isset($ais_data['timestamp'])) {
1198 1674
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1201,7 +1677,9 @@  discard block
 block discarded – undo
1201 1677
 			    }
1202 1678
 			    $data['format_source'] = 'aisnmea';
1203 1679
     			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1680
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1681
+			    	$MI->add($data);
1682
+			    }
1205 1683
 			    unset($data);
1206 1684
                         } elseif ($format == 'flightgearsp') {
1207 1685
                     	    //echo $buffer."\n";
@@ -1219,12 +1697,18 @@  discard block
 block discarded – undo
1219 1697
 				$data['speed'] = round($line[5]*1.94384);
1220 1698
 				$data['datetime'] = date('Y-m-d H:i:s');
1221 1699
 				$data['format_source'] = 'flightgearsp';
1222
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1700
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1701
+					$data['noarchive'] = true;
1702
+				}
1703
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1704
+					$SI->add($data);
1705
+				}
1224 1706
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225 1707
 			    }
1226 1708
                         } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
+                    	    if ($globalDebug) {
1710
+                    	    	echo 'ACARS : '.$buffer."\n";
1711
+                    	    }
1228 1712
 			    $ACARS->add(trim($buffer));
1229 1713
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230 1714
 			    $ACARS->deleteLiveAcarsData();
@@ -1245,8 +1729,12 @@  discard block
 block discarded – undo
1245 1729
 				    $aircraft_type = $line[10];
1246 1730
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247 1731
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1732
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1733
+				    	$data['noarchive'] = true;
1734
+				    }
1735
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1736
+				    	$SI->add($data);
1737
+				    }
1250 1738
 				}
1251 1739
 			    }
1252 1740
 			} elseif ($format == 'beast') {
@@ -1256,28 +1744,62 @@  discard block
 block discarded – undo
1256 1744
 			    foreach($buffer as $all_data) {
1257 1745
 				$line = json_decode('{'.$all_data.'}',true);
1258 1746
 				$data = array();
1259
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1261
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1262
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1263
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1264
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1265
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1747
+				if (isset($line['Icao'])) {
1748
+					$data['hex'] = $line['Icao'];
1749
+				}
1750
+				// hex
1751
+				if (isset($line['Call'])) {
1752
+					$data['ident'] = $line['Call'];
1753
+				}
1754
+				// ident
1755
+				if (isset($line['Alt'])) {
1756
+					$data['altitude'] = $line['Alt'];
1757
+				}
1758
+				// altitude
1759
+				if (isset($line['Spd'])) {
1760
+					$data['speed'] = $line['Spd'];
1761
+				}
1762
+				// speed
1763
+				if (isset($line['Trak'])) {
1764
+					$data['heading'] = $line['Trak'];
1765
+				}
1766
+				// heading
1767
+				if (isset($line['Lat'])) {
1768
+					$data['latitude'] = $line['Lat'];
1769
+				}
1770
+				// lat
1771
+				if (isset($line['Long'])) {
1772
+					$data['longitude'] = $line['Long'];
1773
+				}
1774
+				// long
1266 1775
 				//$data['verticalrate'] = $line['']; // verticale rate
1267
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1776
+				if (isset($line['Sqk'])) {
1777
+					$data['squawk'] = $line['Sqk'];
1778
+				}
1779
+				// squawk
1268 1780
 				$data['emergency'] = ''; // emergency
1269
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1781
+				if (isset($line['Reg'])) {
1782
+					$data['registration'] = $line['Reg'];
1783
+				}
1270 1784
 				/*
1271 1785
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1272 1786
 				else $data['datetime'] = date('Y-m-d H:i:s');
1273 1787
 				*/
1274 1788
 				$data['datetime'] = date('Y-m-d H:i:s');
1275
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1789
+				if (isset($line['Type'])) {
1790
+					$data['aircraft_icao'] = $line['Type'];
1791
+				}
1276 1792
 		    		$data['format_source'] = 'vrstcp';
1277 1793
 				$data['id_source'] = $id_source;
1278
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1794
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1795
+					$data['noarchive'] = true;
1796
+				}
1797
+				if (isset($value['name']) && $value['name'] != '') {
1798
+					$data['source_name'] = $value['name'];
1799
+				}
1800
+				if (isset($data['latitude']) && isset($data['hex'])) {
1801
+					$SI->add($data);
1802
+				}
1281 1803
 				unset($data);
1282 1804
 			    }
1283 1805
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1290,22 +1812,46 @@  discard block
 block discarded – undo
1290 1812
     				$data['hex'] = $lined['hexid'];
1291 1813
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292 1814
     				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1815
+    				if (isset($lined['ident'])) {
1816
+    					$data['ident'] = $lined['ident'];
1817
+    				}
1818
+    				if (isset($lined['lat'])) {
1819
+    					$data['latitude'] = $lined['lat'];
1820
+    				}
1821
+    				if (isset($lined['lon'])) {
1822
+    					$data['longitude'] = $lined['lon'];
1823
+    				}
1824
+    				if (isset($lined['speed'])) {
1825
+    					$data['speed'] = $lined['speed'];
1826
+    				}
1827
+    				if (isset($lined['squawk'])) {
1828
+    					$data['squawk'] = $lined['squawk'];
1829
+    				}
1830
+    				if (isset($lined['alt'])) {
1831
+    					$data['altitude'] = $lined['alt'];
1832
+    				}
1833
+    				if (isset($lined['heading'])) {
1834
+    					$data['heading'] = $lined['heading'];
1835
+    				}
1300 1836
     				$data['id_source'] = $id_source;
1301 1837
     				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1838
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1839
+    					$data['source_name'] = $globalSources[$nb]['name'];
1840
+    				}
1841
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1842
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1843
+    				}
1844
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1845
+					$data['noarchive'] = true;
1846
+				}
1847
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1848
+    					$SI->add($data);
1849
+    				}
1306 1850
     				unset($lined);
1307 1851
     				unset($data);
1308
-    			    } else $error = true;
1852
+    			    } else {
1853
+    			    	$error = true;
1854
+    			    }
1309 1855
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1856
 			    if ($aprs_connect == 0) {
1311 1857
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1330,59 +1876,117 @@  discard block
 block discarded – undo
1330 1876
 				    $aprs_last_tx = time();
1331 1877
 				    $data = array();
1332 1878
 				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1879
+				    if (isset($line['address'])) {
1880
+				    	$data['hex'] = $line['address'];
1881
+				    }
1882
+				    if (isset($line['mmsi'])) {
1883
+				    	$data['mmsi'] = $line['mmsi'];
1884
+				    }
1885
+				    if (isset($line['imo'])) {
1886
+				    	$data['imo'] = $line['imo'];
1887
+				    }
1888
+				    if (isset($line['squawk'])) {
1889
+				    	$data['squawk'] = $line['squawk'];
1890
+				    }
1891
+				    if (isset($line['arrival_code'])) {
1892
+				    	$data['arrical_code'] = $line['arrival_code'];
1893
+				    }
1894
+				    if (isset($line['arrival_date'])) {
1895
+				    	$data['arrical_date'] = $line['arrival_date'];
1896
+				    }
1897
+				    if (isset($line['type_id'])) {
1898
+				    	$data['type_id'] = $line['typeid'];
1899
+				    }
1900
+				    if (isset($line['status_id'])) {
1901
+				    	$data['status_id'] = $line['statusid'];
1902
+				    }
1903
+				    if (isset($line['timestamp'])) {
1904
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1905
+				    } else {
1906
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1907
+				    }
1343 1908
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1909
+				    if (isset($line['ident'])) {
1910
+				    	$data['ident'] = $line['ident'];
1911
+				    }
1345 1912
 				    $data['latitude'] = $line['latitude'];
1346 1913
 				    $data['longitude'] = $line['longitude'];
1347 1914
 				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1915
+				    if (isset($line['speed'])) {
1916
+				    	$data['speed'] = $line['speed'];
1917
+				    }
1349 1918
 				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1919
+				    if (isset($line['altitude'])) {
1920
+				    	$data['altitude'] = $line['altitude'];
1921
+				    }
1922
+				    if (isset($line['comment'])) {
1923
+				    	$data['comment'] = $line['comment'];
1924
+				    }
1925
+				    if (isset($line['symbol'])) {
1926
+				    	$data['type'] = $line['symbol'];
1927
+				    }
1928
+				    if (isset($line['heading'])) {
1929
+				    	$data['heading'] = $line['heading'];
1930
+				    }
1354 1931
 				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1932
+				    if (isset($line['stealth'])) {
1933
+				    	$data['aircraft_type'] = $line['stealth'];
1934
+				    }
1356 1935
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1936
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1937
+				    	$data['noarchive'] = true;
1938
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1939
+				    	$data['noarchive'] = false;
1940
+				    }
1941
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1942
+				    	$data['noarchive'] = true;
1943
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1944
+				    	$data['noarchive'] = false;
1945
+				    }
1361 1946
     				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1947
+    				    if (isset($line['format_source'])) {
1948
+    				    	$data['format_source'] = $line['format_source'];
1949
+    				    } else {
1950
+				    	$data['format_source'] = 'aprs';
1951
+				    }
1364 1952
 				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1953
+				    if (isset($line['source_type'])) {
1954
+				    	$data['source_type'] = $line['source_type'];
1955
+				    } else {
1956
+				    	$data['source_type'] = 'flarm';
1957
+				    }
1958
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1959
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1960
+    				    }
1368 1961
 				    $currentdate = date('Y-m-d H:i:s');
1369 1962
 				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1963
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
1964
+				    	$data['altitude_relative'] = 'AMSL';
1965
+				    }
1371 1966
 				    // Accept data if time <= system time + 20s
1372 1967
 				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373 1968
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1969
 					$send = $SI->add($data);
1375 1970
 				    } elseif ($data['source_type'] == 'ais') {
1376
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1971
+					if (isset($globalMarine) && $globalMarine) {
1972
+						$send = $MI->add($data);
1973
+					}
1377 1974
 				    } elseif (isset($line['stealth'])) {
1378
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1975
+					if ($line['stealth'] != 0) {
1976
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1977
+					} else {
1978
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1979
+					}
1380 1980
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381 1981
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1382 1982
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1383
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1983
+					if (isset($globalTracker) && $globalTracker) {
1984
+						$send = $TI->add($data);
1985
+					}
1384 1986
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1385
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
1987
+					if (!isset($data['altitude'])) {
1988
+						$data['altitude'] = 0;
1989
+					}
1386 1990
 					$Source->deleteOldLocationByType('gs');
1387 1991
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1388 1992
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1394,12 +1998,9 @@  discard block
 block discarded – undo
1394 1998
 				    	print_r($line);
1395 1999
 				    }
1396 2000
 				    unset($data);
1397
-				} 
1398
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
2001
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1399 2002
 					echo '!! Weather Station not yet supported'."\n";
1400
-				}
1401
-				 
1402
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2003
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1403 2004
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1404 2005
 				}
1405 2006
 				/*
@@ -1408,7 +2009,9 @@  discard block
 block discarded – undo
1408 2009
 				}
1409 2010
 				*/
1410 2011
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1411
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2012
+				elseif ($line == true && $globalDebug) {
2013
+					echo '!! Failed : '.$buffer."!!\n";
2014
+				}
1412 2015
 			    }
1413 2016
 			} else {
1414 2017
 			    $line = explode(',', $buffer);
@@ -1437,26 +2040,45 @@  discard block
 block discarded – undo
1437 2040
     				$data['ground'] = $line[21];
1438 2041
     				$data['emergency'] = $line[19];
1439 2042
     				$data['format_source'] = 'sbs';
1440
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2043
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2044
+					$data['source_name'] = $globalSources[$nb]['name'];
2045
+				}
2046
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2047
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2048
+    				}
2049
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2050
+					$data['noarchive'] = true;
2051
+				}
1443 2052
     				$data['id_source'] = $id_source;
1444
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1445
-    				else $error = true;
2053
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2054
+    					$send = $SI->add($data);
2055
+    				} else {
2056
+    					$error = true;
2057
+    				}
1446 2058
     				unset($data);
1447
-    			    } else $error = true;
2059
+    			    } else {
2060
+    			    	$error = true;
2061
+    			    }
1448 2062
 			    if ($error) {
1449 2063
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1450
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2064
+					if ($globalDebug) {
2065
+						echo "Not a message. Ignoring... \n";
2066
+					}
1451 2067
 				} else {
1452
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2068
+					if ($globalDebug) {
2069
+						echo "Wrong line format. Ignoring... \n";
2070
+					}
1453 2071
 					if ($globalDebug) {
1454 2072
 						echo $buffer;
1455 2073
 						//print_r($line);
1456 2074
 					}
1457 2075
 					//socket_close($r);
1458
-					if ($globalDebug) echo "Reconnect after an error...\n";
1459
-					if ($format == 'aprs') $aprs_connect = 0;
2076
+					if ($globalDebug) {
2077
+						echo "Reconnect after an error...\n";
2078
+					}
2079
+					if ($format == 'aprs') {
2080
+						$aprs_connect = 0;
2081
+					}
1460 2082
 					$sourceer[$nb] = $globalSources[$nb];
1461 2083
 					connect_all($sourceer);
1462 2084
 					$sourceer = array();
@@ -1464,10 +2086,14 @@  discard block
 block discarded – undo
1464 2086
 			    }
1465 2087
 			}
1466 2088
 			// Sleep for xxx microseconds
1467
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2089
+			if (isset($globalSBSSleep)) {
2090
+				usleep($globalSBSSleep);
2091
+			}
1468 2092
 		    } else {
1469 2093
 			if ($format == 'flightgearmp') {
1470
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2094
+			    	if ($globalDebug) {
2095
+			    		echo "Reconnect FlightGear MP...";
2096
+			    	}
1471 2097
 				//@socket_close($r);
1472 2098
 				sleep($globalMinFetch);
1473 2099
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1476,10 +2102,15 @@  discard block
 block discarded – undo
1476 2102
 				break;
1477 2103
 				
1478 2104
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1479
-			    if (isset($tt[$format])) $tt[$format]++;
1480
-			    else $tt[$format] = 0;
2105
+			    if (isset($tt[$format])) {
2106
+			    	$tt[$format]++;
2107
+			    } else {
2108
+			    	$tt[$format] = 0;
2109
+			    }
1481 2110
 			    if ($tt[$format] > 30) {
1482
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2111
+				if ($globalDebug) {
2112
+					echo "ERROR : Reconnect ".$format."...";
2113
+				}
1483 2114
 				//@socket_close($r);
1484 2115
 				sleep(2);
1485 2116
 				$aprs_connect = 0;
@@ -1496,11 +2127,17 @@  discard block
 block discarded – undo
1496 2127
 	    } else {
1497 2128
 		$error = socket_strerror(socket_last_error());
1498 2129
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1499
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1500
-			if (isset($globalDebug)) echo "Restarting...\n";
2130
+			if ($globalDebug) {
2131
+				echo "ERROR : socket_select give this error ".$error . "\n";
2132
+			}
2133
+			if (isset($globalDebug)) {
2134
+				echo "Restarting...\n";
2135
+			}
1501 2136
 			// Restart the script if possible
1502 2137
 			if (is_array($sockets)) {
1503
-			    if ($globalDebug) echo "Shutdown all sockets...";
2138
+			    if ($globalDebug) {
2139
+			    	echo "Shutdown all sockets...";
2140
+			    }
1504 2141
 			    
1505 2142
 			    foreach ($sockets as $sock) {
1506 2143
 				@socket_shutdown($sock,2);
@@ -1508,22 +2145,36 @@  discard block
 block discarded – undo
1508 2145
 			    }
1509 2146
 			    
1510 2147
 			}
1511
-			if ($globalDebug) echo "Waiting...";
2148
+			if ($globalDebug) {
2149
+				echo "Waiting...";
2150
+			}
1512 2151
 			sleep(2);
1513 2152
 			$time = time();
1514 2153
 			//connect_all($hosts);
1515 2154
 			$aprs_connect = 0;
1516
-			if ($reset%5 == 0) sleep(20);
1517
-			if ($reset%10 == 0) sleep(100);
1518
-			if ($reset%20 == 0) sleep(200);
1519
-			if ($reset > 100) exit('Too many attempts...');
1520
-			if ($globalDebug) echo "Restart all connections...";
2155
+			if ($reset%5 == 0) {
2156
+				sleep(20);
2157
+			}
2158
+			if ($reset%10 == 0) {
2159
+				sleep(100);
2160
+			}
2161
+			if ($reset%20 == 0) {
2162
+				sleep(200);
2163
+			}
2164
+			if ($reset > 100) {
2165
+				exit('Too many attempts...');
2166
+			}
2167
+			if ($globalDebug) {
2168
+				echo "Restart all connections...";
2169
+			}
1521 2170
 			connect_all($globalSources);
1522 2171
 		}
1523 2172
 	    }
1524 2173
 	}
1525 2174
 	if ($globalDaemon === false) {
1526
-	    if ($globalDebug) echo 'Check all...'."\n";
2175
+	    if ($globalDebug) {
2176
+	    	echo 'Check all...'."\n";
2177
+	    }
1527 2178
 	    $SI->checkAll();
1528 2179
 	}
1529 2180
     }
Please login to merge, or discard this patch.
install/index.php 2 patches
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.create_db.php');
11 11
 require_once(dirname(__FILE__).'/class.update_schema.php');
12 12
 require_once(dirname(__FILE__).'/class.settings.php');
13
-$title="Install";
13
+$title = "Install";
14 14
 require(dirname(__FILE__).'/../require/settings.php');
15 15
 require(dirname(__FILE__).'/header.php');
16 16
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 if (!extension_loaded('curl')) {
70 70
 	$error[] = "Curl is not loaded.";
71 71
 }
72
-if(function_exists('apache_get_modules') ){
73
-	if(!in_array('mod_rewrite',apache_get_modules())) {
72
+if (function_exists('apache_get_modules')) {
73
+	if (!in_array('mod_rewrite', apache_get_modules())) {
74 74
 		$error[] = "mod_rewrite is not available.";
75 75
 	}
76 76
 /*
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
87 87
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
88 88
 	if (function_exists('get_headers')) {
89
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
90
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
89
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
90
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
91 91
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
92 92
 		}
93 93
 	}
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460 460
 								    } else {
461
-									$hostport = explode(':',$source['host']);
461
+									$hostport = explode(':', $source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
464 464
 										$port = $hostport[1];
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 									<select name="timezone[]" id="timezone">
504 504
 								<?php
505 505
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
506
-									foreach($timezonelist as $timezone){
506
+									foreach ($timezonelist as $timezone) {
507 507
 										if (isset($source['timezone']) && $source['timezone'] == $timezone) {
508 508
 											print '<option selected>'.$timezone.'</option>';
509 509
 										} elseif (!isset($source['timezone']) && $timezone == 'UTC') {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 									<select name="timezone[]" id="timezone">
554 554
 								<?php
555 555
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
556
-									foreach($timezonelist as $timezone){
556
+									foreach ($timezonelist as $timezone) {
557 557
 										if ($timezone == 'UTC') {
558 558
 											print '<option selected>'.$timezone.'</option>';
559 559
 										} else print '<option>'.$timezone.'</option>';
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 			<br />
866 866
 			<p>
867 867
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
868
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
868
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
869 869
 			</p>
870 870
 			<br />
871 871
 			<p>
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 $error = '';
922 922
 
923 923
 if (isset($_POST['dbtype'])) {
924
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
925
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
926
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
927
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
928
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
929
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
930
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
931
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
924
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
925
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
926
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
927
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
928
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
929
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
930
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
931
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
932 932
 
933 933
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
934 934
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -948,49 +948,49 @@  discard block
 block discarded – undo
948 948
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
949 949
 	*/
950 950
 	
951
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
951
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
952 952
 
953
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
954
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
955
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
956
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
957
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
953
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
954
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
955
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
956
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
957
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
958 958
 
959
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
960
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
961
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
962
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
963
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
964
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
965
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
966
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
967
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
968
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
959
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
960
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
961
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
962
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
963
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
964
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
965
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
966
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
967
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
968
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
969 969
 	
970
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
971
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
972
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
973
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
974
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
975
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
970
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
971
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
972
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
973
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
974
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
975
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
976 976
 
977
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
978
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
977
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
978
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
979 979
 
980
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
981
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
982
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
980
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
981
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
982
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
983 983
 
984
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
984
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
985 985
 	if ($acars == 'acars') {
986
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
986
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
987 987
 	} else {
988
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
988
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
989 989
 	}
990 990
 
991
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
992
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
993
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
991
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
992
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
993
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
994 994
 	
995 995
 	$source_name = $_POST['source_name'];
996 996
 	$source_latitude = $_POST['source_latitude'];
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 	
1005 1005
 	$sources = array();
1006 1006
 	foreach ($source_name as $keys => $name) {
1007
-	    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]);
1008
-	    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]);
1007
+	    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]);
1008
+	    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]);
1009 1009
 	}
1010 1010
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1011 1011
 
@@ -1018,24 +1018,24 @@  discard block
 block discarded – undo
1018 1018
 	$sbsurl = $_POST['sbsurl'];
1019 1019
 	*/
1020 1020
 
1021
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1022
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1023
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1024
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1025
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1026
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1027
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1028
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1021
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1022
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1023
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1024
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1025
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1026
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1027
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1028
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1029 1029
 
1030
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1031
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1032
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1033
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1034
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1035
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1036
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1037
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1038
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1030
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1031
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1032
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1033
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1034
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1035
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1036
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1037
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1038
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1039 1039
 
1040 1040
 /*	
1041 1041
 	$globalSBS1Hosts = array();
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	}
1052 1052
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1053 1053
 */
1054
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1054
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1055 1055
 	$host = $_POST['host'];
1056 1056
 	$port = $_POST['port'];
1057 1057
 	$name = $_POST['name'];
@@ -1068,100 +1068,100 @@  discard block
 block discarded – undo
1068 1068
 		else $cov = 'FALSE';
1069 1069
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1070 1070
 		else $arch = 'FALSE';
1071
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1071
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezone[$key]);
1072 1072
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1073 1073
 	}
1074
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1074
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1075 1075
 
1076 1076
 /*
1077 1077
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1078 1078
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1079 1079
 */
1080
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1081
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1082
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1080
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1081
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1082
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1083 1083
 
1084
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1085
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1084
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1085
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1086 1086
 
1087
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1088
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1087
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1088
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1089 1089
 
1090
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1091
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1092
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1093
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1090
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1091
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1092
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1093
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1094 1094
 
1095
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1096
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1097
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1095
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1096
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1097
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1098 1098
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1099
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1100
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1099
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1100
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1101 1101
 
1102
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1103
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1104
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1105
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1106
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1107
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1108
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1109
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1102
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1103
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1104
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1105
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1106
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1107
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1108
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1109
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1110 1110
 
1111
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1112
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1111
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1112
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1113 1113
 
1114
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1115
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1114
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1115
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1116 1116
 	
1117
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1117
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1118 1118
 	if ($archiveyear == "archiveyear") {
1119
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1119
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1120 1120
 	} else {
1121
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1121
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1122 1122
 	}
1123
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1124
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1125
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1126
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1123
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1124
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1125
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1126
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1127 1127
 
1128
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1129
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1130
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1131
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1128
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1129
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1130
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1131
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1132 1132
 
1133
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1134
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1135
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1133
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1134
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1135
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1136 1136
 
1137 1137
 	// Create in settings.php keys not yet configurable if not already here
1138 1138
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1139
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1139
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1140 1140
 
1141
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1141
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1142 1142
 	if ($resetyearstats == 'resetyearstats') {
1143
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1143
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1144 1144
 	} else {
1145
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1145
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1146 1146
 	}
1147 1147
 
1148
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1148
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1149 1149
 	if ($archive == 'archive') {
1150
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1150
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1151 1151
 	} else {
1152
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1152
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1153 1153
 	}
1154
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1154
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1155 1155
 	if ($daemon == 'daemon') {
1156
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1156
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1157 1157
 	} else {
1158
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1158
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1159 1159
 	}
1160
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1160
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1161 1161
 	if ($schedules == 'schedules') {
1162
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1162
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1163 1163
 	} else {
1164
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1164
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1165 1165
 	}
1166 1166
 
1167 1167
 /*
@@ -1172,227 +1172,227 @@  discard block
 block discarded – undo
1172 1172
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1173 1173
 	}
1174 1174
 */
1175
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1176
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1177
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1178
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1179
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1175
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1176
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1177
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1178
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1179
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1180 1180
 	$va = false;
1181 1181
 	if ($globalivao == 'ivao') {
1182
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1182
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1183 1183
 		$va = true;
1184
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1184
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1185 1185
 	if ($globalvatsim == 'vatsim') {
1186
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1186
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1187 1187
 		$va = true;
1188
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1188
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1189 1189
 	if ($globalphpvms == 'phpvms') {
1190
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1190
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1191 1191
 		$va = true;
1192
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1192
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1193 1193
 	if ($globalvam == 'vam') {
1194
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1194
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1195 1195
 		$va = true;
1196
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1196
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1197 1197
 	if ($va) {
1198
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1199
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1198
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1199
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1200 1200
 	if ($globalva == 'va' || $va) {
1201
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1202
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1201
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1202
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1203 1203
 	} else {
1204
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1205
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1206
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1204
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1205
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1206
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1207 1207
 	}
1208 1208
 	
1209 1209
 	
1210 1210
 
1211
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1211
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1212 1212
 	if ($notam == 'notam') {
1213
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1213
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1214 1214
 	} else {
1215
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1215
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1216 1216
 	}
1217
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1217
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1218 1218
 	if ($owner == 'owner') {
1219
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1219
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1220 1220
 	} else {
1221
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1221
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1222 1222
 	}
1223
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1223
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1224 1224
 	if ($map3d == 'map3d') {
1225
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1225
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1226 1226
 	} else {
1227
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1227
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1228 1228
 	}
1229
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1229
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1230 1230
 	if ($crash == 'crash') {
1231
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1231
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1232 1232
 	} else {
1233
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1233
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1234 1234
 	}
1235
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1235
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1236 1236
 	if ($mapsatellites == 'mapsatellites') {
1237
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1237
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1238 1238
 	} else {
1239
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1239
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1240 1240
 	}
1241
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1241
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1242 1242
 	if ($map3ddefault == 'map3ddefault') {
1243
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1243
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1244 1244
 	} else {
1245
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1245
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1246 1246
 	}
1247
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1247
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1248 1248
 	if ($translate == 'translate') {
1249
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1249
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1250 1250
 	} else {
1251
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1251
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1252 1252
 	}
1253
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1253
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1254 1254
 	if ($realairlines == 'realairlines') {
1255
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1255
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1256 1256
 	} else {
1257
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1257
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1258 1258
 	}
1259
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1259
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1260 1260
 	if ($estimation == 'estimation') {
1261
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1261
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1262 1262
 	} else {
1263
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1263
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1264 1264
 	}
1265
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1265
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1266 1266
 	if ($metar == 'metar') {
1267
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1267
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1268 1268
 	} else {
1269
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1269
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1270 1270
 	}
1271
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1271
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1272 1272
 	if ($metarcycle == 'metarcycle') {
1273
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1273
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1274 1274
 	} else {
1275
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1275
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1276 1276
 	}
1277
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1277
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1278 1278
 	if ($fork == 'fork') {
1279
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1279
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1280 1280
 	} else {
1281
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1281
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1282 1282
 	}
1283 1283
 
1284
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1284
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1285 1285
 	if ($colormap == 'colormap') {
1286
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1286
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1287 1287
 	} else {
1288
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1288
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1289 1289
 	}
1290 1290
 	
1291 1291
 	if (isset($_POST['aircrafticoncolor'])) {
1292
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1293
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1292
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1293
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1294 1294
 	}
1295 1295
 
1296
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1297
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1296
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1297
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1298 1298
 
1299
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1300
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1301
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1302
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1303
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1304
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1299
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1300
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1301
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1302
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1303
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1304
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1305 1305
 
1306
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1306
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1307 1307
 	if ($mappopup == 'mappopup') {
1308
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1308
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1309 1309
 	} else {
1310
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1310
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1311 1311
 	}
1312
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1312
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1313 1313
 	if ($airportpopup == 'airportpopup') {
1314
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1314
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1315 1315
 	} else {
1316
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1316
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1317 1317
 	}
1318
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1318
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1319 1319
 	if ($maphistory == 'maphistory') {
1320
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1320
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1321 1321
 	} else {
1322
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1322
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1323 1323
 	}
1324
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1324
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1325 1325
 	if ($maptooltip == 'maptooltip') {
1326
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1326
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1327 1327
 	} else {
1328
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1328
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1329 1329
 	}
1330
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1330
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1331 1331
 	if ($flightroute == 'flightroute') {
1332
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1332
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1333 1333
 	} else {
1334
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1334
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1335 1335
 	}
1336
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1336
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1337 1337
 	if ($flightremainingroute == 'flightremainingroute') {
1338
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1338
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1339 1339
 	} else {
1340
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1340
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1341 1341
 	}
1342
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1342
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1343 1343
 	if ($allflights == 'allflights') {
1344
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1344
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1345 1345
 	} else {
1346
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1346
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1347 1347
 	}
1348
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1348
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1349 1349
 	if ($bbox == 'bbox') {
1350
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1350
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1351 1351
 	} else {
1352
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1352
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1353 1353
 	}
1354
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1354
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1355 1355
 	if ($groundaltitude == 'groundaltitude') {
1356
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1356
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1357 1357
 	} else {
1358
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1358
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1359 1359
 	}
1360
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1360
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1361 1361
 	if ($waypoints == 'waypoints') {
1362
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1362
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1363 1363
 	} else {
1364
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1364
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1365 1365
 	}
1366
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1366
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1367 1367
 	if ($geoid == 'geoid') {
1368
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1368
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1369 1369
 	} else {
1370
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1370
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1371 1371
 	}
1372
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1373
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1372
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1373
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1374 1374
 
1375
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1375
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1376 1376
 	if ($noairlines == 'noairlines') {
1377
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1377
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1378 1378
 	} else {
1379
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1379
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1380 1380
 	}
1381 1381
 
1382
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1382
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1383 1383
 
1384 1384
 	// Set some defaults values...
1385 1385
 	if (!isset($globalAircraftImageSources)) {
1386
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1387
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1386
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1387
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1388 1388
 	}
1389 1389
 
1390 1390
 	if (!isset($globalSchedulesSources)) {
1391
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1392
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1391
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1392
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1393 1393
     	}
1394 1394
 
1395
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1395
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1396 1396
 
1397 1397
 	if ($error == '') settings::modify_settings($settings);
1398 1398
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +496 added lines, -133 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<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>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<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>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -409,11 +513,17 @@  discard block
 block discarded – undo
409 513
 			<div id="flightaware_data">
410 514
 				<p>
411 515
 					<label for="flightawareusername">FlightAware username</label>
412
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
516
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
517
+	print $globalFlightAwareUsername;
518
+}
519
+?>" />
413 520
 				</p>
414 521
 				<p>
415 522
 					<label for="flightawarepassword">FlightAware password/API key</label>
416
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
523
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
524
+	print $globalFlightAwarePassword;
525
+}
526
+?>" />
417 527
 				</p>
418 528
 			</div>
419 529
 -->
@@ -455,7 +565,10 @@  discard block
 block discarded – undo
455 565
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 566
 								?>
457 567
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458
-								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
568
+								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
569
+	print $source['port'];
570
+}
571
+?>" /></td>
459 572
 								<?php
460 573
 								    } else {
461 574
 									$hostport = explode(':',$source['host']);
@@ -474,31 +587,94 @@  discard block
 block discarded – undo
474 587
 								?>
475 588
 								<td>
476 589
 									<select name="format[]" id="format">
477
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
478
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
479
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
480
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
481
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
482
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
483
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
484
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
485
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
486
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
487
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
488
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
489
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
490
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
491
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
492
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
493
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
494
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
590
+										<option value="auto" <?php if (!isset($source['format'])) {
591
+	print 'selected';
592
+}
593
+?>>Auto</option>
594
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
595
+	print 'selected';
596
+}
597
+?>>SBS</option>
598
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
599
+	print 'selected';
600
+}
601
+?>>TSV</option>
602
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
603
+	print 'selected';
604
+}
605
+?>>Raw</option>
606
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
607
+	print 'selected';
608
+}
609
+?>>APRS</option>
610
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
611
+	print 'selected';
612
+}
613
+?>>Radarcape deltadb.txt</option>
614
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
615
+	print 'selected';
616
+}
617
+?>>Vatsim</option>
618
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
619
+	print 'selected';
620
+}
621
+?>>Virtual Radar Server AircraftList.json</option>
622
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
623
+	print 'selected';
624
+}
625
+?>>Virtual Radar Server TCP</option>
626
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
627
+	print 'selected';
628
+}
629
+?>>phpVMS</option>
630
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
631
+	print 'selected';
632
+}
633
+?>>Virtual Airlines Manager</option>
634
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
635
+	print 'selected';
636
+}
637
+?>>IVAO</option>
638
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
639
+	print 'selected';
640
+}
641
+?>>FlightGear Multiplayer</option>
642
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
643
+	print 'selected';
644
+}
645
+?>>FlightGear Singleplayer</option>
646
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
647
+	print 'selected';
648
+}
649
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
650
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
651
+	print 'selected';
652
+}
653
+?>>ACARS SBS-3 over TCP</option>
654
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
655
+	print 'selected';
656
+}
657
+?>>NMEA AIS over TCP</option>
658
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
659
+	print 'selected';
660
+}
661
+?>>AirWhere website</option>
495 662
 									</select>
496 663
 								</td>
497 664
 								<td>
498
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
665
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
666
+	print $source['name'];
667
+}
668
+?>" />
499 669
 								</td>
500
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
501
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
670
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
671
+	print 'checked';
672
+}
673
+?> /></td>
674
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
675
+	print 'checked';
676
+}
677
+?> /></td>
502 678
 								<td>
503 679
 									<select name="timezone[]" id="timezone">
504 680
 								<?php
@@ -508,7 +684,9 @@  discard block
 block discarded – undo
508 684
 											print '<option selected>'.$timezone.'</option>';
509 685
 										} elseif (!isset($source['timezone']) && $timezone == 'UTC') {
510 686
 											print '<option selected>'.$timezone.'</option>';
511
-										} else print '<option>'.$timezone.'</option>';
687
+										} else {
688
+											print '<option>'.$timezone.'</option>';
689
+										}
512 690
 									}
513 691
 								?>
514 692
 									</select>
@@ -556,7 +734,9 @@  discard block
 block discarded – undo
556 734
 									foreach($timezonelist as $timezone){
557 735
 										if ($timezone == 'UTC') {
558 736
 											print '<option selected>'.$timezone.'</option>';
559
-										} else print '<option>'.$timezone.'</option>';
737
+										} else {
738
+											print '<option>'.$timezone.'</option>';
739
+										}
560 740
 									}
561 741
 								?>
562 742
 									</select>
@@ -577,11 +757,17 @@  discard block
 block discarded – undo
577 757
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
578 758
 					<p>
579 759
 						<label for="acarshost">ACARS UDP host</label>
580
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
760
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
761
+	print $globalACARSHost;
762
+}
763
+?>" />
581 764
 					</p>
582 765
 					<p>
583 766
 						<label for="acarsport">ACARS UDP port</label>
584
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
767
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
768
+	print $globalACARSPort;
769
+}
770
+?>" />
585 771
 					</p>
586 772
 				</fieldset>
587 773
 			</div>
@@ -661,13 +847,19 @@  discard block
 block discarded – undo
661 847
 			<div id="schedules_options">
662 848
 				<p>
663 849
 					<label for="britishairways">British Airways API Key</label>
664
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
850
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
851
+	print $globalBritishAirwaysKey;
852
+}
853
+?>" />
665 854
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
666 855
 				</p>
667 856
 				<!--
668 857
 				<p>
669 858
 					<label for="transavia">Transavia Test API Consumer Key</label>
670
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
859
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
860
+	print $globalTransaviaKey;
861
+}
862
+?>" />
671 863
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
672 864
 				</p>
673 865
 				-->
@@ -676,10 +868,16 @@  discard block
 block discarded – undo
676 868
 						<b>Lufthansa API Key</b>
677 869
 						<p>
678 870
 							<label for="lufthansakey">Key</label>
679
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
871
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
872
+	print $globalLufthansaKey['key'];
873
+}
874
+?>" />
680 875
 						</p><p>
681 876
 							<label for="lufthansasecret">Secret</label>
682
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
877
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
878
+	print $globalLufthansaKey['secret'];
879
+}
880
+?>" />
683 881
 						</p>
684 882
 					</div>
685 883
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -699,7 +897,10 @@  discard block
 block discarded – undo
699 897
 			</p>
700 898
 			<p>
701 899
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
702
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
900
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
901
+	print $globalNOTAMSource;
902
+}
903
+?>" />
703 904
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
704 905
 			</p>
705 906
 			<br />
@@ -715,14 +916,20 @@  discard block
 block discarded – undo
715 916
 			<div id="metarsrc">
716 917
 				<p>
717 918
 					<label for="metarsource">URL of your METAR source</label>
718
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
919
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
920
+	print $globalMETARurl;
921
+}
922
+?>" />
719 923
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
720 924
 				</p>
721 925
 			</div>
722 926
 			<br />
723 927
 			<p>
724 928
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
725
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
929
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
930
+	print $globalBitlyAccessToken;
931
+}
932
+?>" />
726 933
 			</p>
727 934
 			<br />
728 935
 			<p>
@@ -738,11 +945,26 @@  discard block
 block discarded – undo
738 945
 			<p>
739 946
 				<label for="geoid_source">Geoid Source</label>
740 947
 				<select name="geoid_source" id="geoid_source">
741
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
742
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
743
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
744
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
745
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
948
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
949
+	print ' selected="selected"';
950
+}
951
+?>>EGM96 15' (2.1MB)</option>
952
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
953
+	print ' selected="selected"';
954
+}
955
+?>>EGM96 5' (19MB)</option>
956
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
957
+	print ' selected="selected"';
958
+}
959
+?>>EGM2008 5' (19MB)</option>
960
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
961
+	print ' selected="selected"';
962
+}
963
+?>>EGM2008 2.5' (75MB)</option>
964
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM2008 1' (470MB)</option>
746 968
 				</select>
747 969
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
748 970
 			</p>
@@ -759,7 +981,12 @@  discard block
 block discarded – undo
759 981
 			</p>
760 982
 			<p>
761 983
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
762
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
984
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
985
+	print $globalArchiveMonths;
986
+} else {
987
+	echo '0';
988
+}
989
+?>" />
763 990
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
764 991
 			</p>
765 992
 			<p>
@@ -769,12 +996,22 @@  discard block
 block discarded – undo
769 996
 			</p>
770 997
 			<p>
771 998
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
772
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
999
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1000
+	print $globalArchiveKeepMonths;
1001
+} else {
1002
+	echo '0';
1003
+}
1004
+?>" />
773 1005
 				<p class="help-block">0 to disable</p>
774 1006
 			</p>
775 1007
 			<p>
776 1008
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
777
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
1009
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1010
+	print $globalArchiveKeepTrackMonths;
1011
+} else {
1012
+	echo '0';
1013
+}
1014
+?>" />
778 1015
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
779 1016
 			</p>
780 1017
 			<br />
@@ -784,7 +1021,12 @@  discard block
 block discarded – undo
784 1021
 				<p class="help-block">Uncheck if the script is running as cron job</p>
785 1022
 				<div id="cronends"> 
786 1023
 					<label for="cronend">Run script for xx seconds</label>
787
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1024
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1025
+	print $globalCronEnd;
1026
+} else {
1027
+	print '0';
1028
+}
1029
+?>" />
788 1030
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
789 1031
 				</div>
790 1032
 			</p>
@@ -837,15 +1079,30 @@  discard block
 block discarded – undo
837 1079
 			<br />
838 1080
 			<p>
839 1081
 				<label for="refresh">Show flights detected since xxx seconds</label>
840
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1082
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1083
+	echo $globalLiveInterval;
1084
+} else {
1085
+	echo '200';
1086
+}
1087
+?>" />
841 1088
 			</p>
842 1089
 			<p>
843 1090
 				<label for="maprefresh">Live map refresh (in seconds)</label>
844
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1091
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1092
+	echo $globalMapRefresh;
1093
+} else {
1094
+	echo '30';
1095
+}
1096
+?>" />
845 1097
 			</p>
846 1098
 			<p>
847 1099
 				<label for="mapidle">Map idle timeout (in minutes)</label>
848
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1100
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1101
+	echo $globalMapIdleTimeout;
1102
+} else {
1103
+	echo '30';
1104
+}
1105
+?>" />
849 1106
 				<p class="help-block">0 to disable</p>
850 1107
 			</p>
851 1108
 			<p>
@@ -860,12 +1117,20 @@  discard block
 block discarded – undo
860 1117
 			<br />
861 1118
 			<p>
862 1119
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
863
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1120
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1121
+	echo $globalClosestMinDist;
1122
+} else {
1123
+	echo '50';
1124
+}
1125
+?>" />
864 1126
 			</p>
865 1127
 			<br />
866 1128
 			<p>
867 1129
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
868
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1130
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1131
+	echo $globalAircraftSize;
1132
+}
1133
+?>" />
869 1134
 			</p>
870 1135
 			<br />
871 1136
 			<p>
@@ -878,7 +1143,12 @@  discard block
 block discarded – undo
878 1143
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
879 1144
 			?>
880 1145
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
881
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1146
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1147
+	echo $globalAircraftIconColor;
1148
+} else {
1149
+	echo '1a3151';
1150
+}
1151
+?>" />
882 1152
 			<?php
883 1153
 				if (!is_writable('../cache')) {
884 1154
 			?>
@@ -896,14 +1166,27 @@  discard block
 block discarded – undo
896 1166
 			<p>
897 1167
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
898 1168
 				<div class="range">
899
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
900
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1169
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1170
+	echo $globalAirportZoom;
1171
+} else {
1172
+	echo '7';
1173
+}
1174
+?>" />
1175
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1176
+	echo $globalAirportZoom;
1177
+} else {
1178
+	echo '7';
1179
+}
1180
+?></output>
901 1181
 				</div>
902 1182
 			</p>
903 1183
 			<br />
904 1184
 			<p>
905 1185
 				<label for="customcss">Custom CSS web path</label>
906
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1186
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1187
+	echo $globalCustomCSS;
1188
+}
1189
+?>" />
907 1190
 			</p>
908 1191
 		</fieldset>
909 1192
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -930,8 +1213,12 @@  discard block
 block discarded – undo
930 1213
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
931 1214
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
932 1215
 
933
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
934
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1216
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1217
+		$error .= 'Mysql driver for PDO must be loaded';
1218
+	}
1219
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1220
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1221
+	}
935 1222
 	
936 1223
 	$_SESSION['database_root'] = $dbroot;
937 1224
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -999,15 +1286,23 @@  discard block
 block discarded – undo
999 1286
 	$source_city = $_POST['source_city'];
1000 1287
 	$source_country = $_POST['source_country'];
1001 1288
 	$source_ref = $_POST['source_ref'];
1002
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1003
-	else $source_id = array();
1289
+	if (isset($source_id)) {
1290
+		$source_id = $_POST['source_id'];
1291
+	} else {
1292
+		$source_id = array();
1293
+	}
1004 1294
 	
1005 1295
 	$sources = array();
1006 1296
 	foreach ($source_name as $keys => $name) {
1007
-	    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]);
1008
-	    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]);
1297
+	    if (isset($source_id[$keys])) {
1298
+	    	$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]);
1299
+	    } else {
1300
+	    	$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]);
1301
+	    }
1302
+	}
1303
+	if (count($sources) > 0) {
1304
+		$_SESSION['sources'] = $sources;
1009 1305
 	}
1010
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1011 1306
 
1012 1307
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1013 1308
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1028,14 +1323,23 @@  discard block
 block discarded – undo
1028 1323
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1029 1324
 
1030 1325
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1031
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1032
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1326
+	if ($globalaircraft == 'aircraft') {
1327
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1328
+	} else {
1329
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1330
+	}
1033 1331
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1034
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1035
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1332
+	if ($globaltracker == 'tracker') {
1333
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1334
+	} else {
1335
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1336
+	}
1036 1337
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1037
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1038
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1338
+	if ($globalmarine == 'marine') {
1339
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1340
+	} else {
1341
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1342
+	}
1039 1343
 
1040 1344
 /*	
1041 1345
 	$globalSBS1Hosts = array();
@@ -1057,19 +1361,35 @@  discard block
 block discarded – undo
1057 1361
 	$name = $_POST['name'];
1058 1362
 	$format = $_POST['format'];
1059 1363
 	$timezone = $_POST['timezone'];
1060
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1061
-	else $sourcestats = array();
1062
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1063
-	else $noarchive = array();
1364
+	if (isset($_POST['sourcestats'])) {
1365
+		$sourcestats = $_POST['sourcestats'];
1366
+	} else {
1367
+		$sourcestats = array();
1368
+	}
1369
+	if (isset($_POST['noarchive'])) {
1370
+		$noarchive = $_POST['noarchive'];
1371
+	} else {
1372
+		$noarchive = array();
1373
+	}
1064 1374
 	$gSources = array();
1065 1375
 	$forcepilots = false;
1066 1376
 	foreach ($host as $key => $h) {
1067
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1068
-		else $cov = 'FALSE';
1069
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1070
-		else $arch = 'FALSE';
1071
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1072
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1377
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1378
+			$cov = 'TRUE';
1379
+		} else {
1380
+			$cov = 'FALSE';
1381
+		}
1382
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1383
+			$arch = 'TRUE';
1384
+		} else {
1385
+			$arch = 'FALSE';
1386
+		}
1387
+		if ($h != '') {
1388
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]);
1389
+		}
1390
+		if ($format[$key] == 'airwhere') {
1391
+			$forcepilots = true;
1392
+		}
1073 1393
 	}
1074 1394
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1075 1395
 
@@ -1097,7 +1417,9 @@  discard block
 block discarded – undo
1097 1417
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1098 1418
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1099 1419
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1100
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1420
+	} else {
1421
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1422
+	}
1101 1423
 
1102 1424
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1103 1425
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1136,7 +1458,9 @@  discard block
 block discarded – undo
1136 1458
 
1137 1459
 	// Create in settings.php keys not yet configurable if not already here
1138 1460
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1139
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1461
+	if (!isset($globalDebug)) {
1462
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1463
+	}
1140 1464
 
1141 1465
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1142 1466
 	if ($resetyearstats == 'resetyearstats') {
@@ -1173,37 +1497,56 @@  discard block
 block discarded – undo
1173 1497
 	}
1174 1498
 */
1175 1499
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1176
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1177
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1178
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1179
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1500
+	if ($globalsbs == 'sbs') {
1501
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1502
+	} else {
1503
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1504
+	}
1505
+	if ($globalaprs == 'aprs') {
1506
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1507
+	} else {
1508
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1509
+	}
1180 1510
 	$va = false;
1181 1511
 	if ($globalivao == 'ivao') {
1182 1512
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1183 1513
 		$va = true;
1184
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1514
+	} else {
1515
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1516
+	}
1185 1517
 	if ($globalvatsim == 'vatsim') {
1186 1518
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1187 1519
 		$va = true;
1188
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1520
+	} else {
1521
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1522
+	}
1189 1523
 	if ($globalphpvms == 'phpvms') {
1190 1524
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1191 1525
 		$va = true;
1192
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1526
+	} else {
1527
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1528
+	}
1193 1529
 	if ($globalvam == 'vam') {
1194 1530
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1195 1531
 		$va = true;
1196
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1532
+	} else {
1533
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1534
+	}
1197 1535
 	if ($va) {
1198 1536
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1199
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1537
+	} else {
1538
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1539
+	}
1200 1540
 	if ($globalva == 'va' || $va) {
1201 1541
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1202 1542
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1203 1543
 	} else {
1204 1544
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1205
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1206
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1545
+		if ($forcepilots) {
1546
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1547
+		} else {
1548
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1549
+		}
1207 1550
 	}
1208 1551
 	
1209 1552
 	
@@ -1379,7 +1722,9 @@  discard block
 block discarded – undo
1379 1722
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1380 1723
 	}
1381 1724
 
1382
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1725
+	if (!isset($globalTransaction)) {
1726
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1727
+	}
1383 1728
 
1384 1729
 	// Set some defaults values...
1385 1730
 	if (!isset($globalAircraftImageSources)) {
@@ -1394,15 +1739,23 @@  discard block
 block discarded – undo
1394 1739
 
1395 1740
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1396 1741
 
1397
-	if ($error == '') settings::modify_settings($settings);
1398
-	if ($error == '') settings::comment_settings($settings_comment);
1742
+	if ($error == '') {
1743
+		settings::modify_settings($settings);
1744
+	}
1745
+	if ($error == '') {
1746
+		settings::comment_settings($settings_comment);
1747
+	}
1399 1748
 	if ($error != '') {
1400 1749
 		print '<div class="info column">'.$error.'</div>';
1401 1750
 		require('../footer.php');
1402 1751
 		exit;
1403 1752
 	} else {
1404
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1405
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1753
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1754
+			$_SESSION['waypoints'] = 1;
1755
+		}
1756
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1757
+			$_SESSION['owner'] = 1;
1758
+		}
1406 1759
 		if (isset($_POST['createdb'])) {
1407 1760
 			$_SESSION['install'] = 'database_create';
1408 1761
 		} else {
@@ -1443,10 +1796,18 @@  discard block
 block discarded – undo
1443 1796
 	$popw = false;
1444 1797
 	foreach ($_SESSION['done'] as $done) {
1445 1798
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1446
-	    if ($done == 'Create database') $pop = true;
1447
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1448
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1449
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1799
+	    if ($done == 'Create database') {
1800
+	    	$pop = true;
1801
+	    }
1802
+	    if ($_SESSION['install'] == 'database_create') {
1803
+	    	$pop = true;
1804
+	    }
1805
+	    if ($_SESSION['install'] == 'database_import') {
1806
+	    	$popi = true;
1807
+	    }
1808
+	    if ($_SESSION['install'] == 'waypoints') {
1809
+	    	$popw = true;
1810
+	    }
1450 1811
 	}
1451 1812
 	if ($pop) {
1452 1813
 	    sleep(5);
@@ -1457,7 +1818,9 @@  discard block
 block discarded – undo
1457 1818
 	} else if ($popw) {
1458 1819
 	    sleep(5);
1459 1820
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1460
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1821
+	} else {
1822
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1823
+	}
1461 1824
 	print '</div></ul>';
1462 1825
 	print '<div id="error"></div>';
1463 1826
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_db.php 3 patches
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 87
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -667,20 +667,20 @@  discard block
 block discarded – undo
667 667
 		try {
668 668
 			$Connection = new Connection();
669 669
 			$sth = $Connection->db->prepare($query);
670
-                        $sth->execute();
671
-                } catch(PDOException $e) {
672
-                        return "error : ".$e->getMessage();
673
-                }
670
+						$sth->execute();
671
+				} catch(PDOException $e) {
672
+						return "error : ".$e->getMessage();
673
+				}
674 674
 
675 675
 
676 676
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
677 677
 		try {
678 678
 			$Connection = new Connection();
679 679
 			$sth = $Connection->db->prepare($query);
680
-                        $sth->execute();
681
-                } catch(PDOException $e) {
682
-                        return "error : ".$e->getMessage();
683
-                }
680
+						$sth->execute();
681
+				} catch(PDOException $e) {
682
+						return "error : ".$e->getMessage();
683
+				}
684 684
 
685 685
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
686 686
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -746,10 +746,10 @@  discard block
 block discarded – undo
746 746
 		try {
747 747
 			$Connection = new Connection();
748 748
 			$sth = $Connection->db->prepare($query);
749
-                        $sth->execute();
750
-                } catch(PDOException $e) {
751
-                        return "error : ".$e->getMessage();
752
-                }
749
+						$sth->execute();
750
+				} catch(PDOException $e) {
751
+						return "error : ".$e->getMessage();
752
+				}
753 753
 
754 754
 
755 755
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -759,10 +759,10 @@  discard block
 block discarded – undo
759 759
 		try {
760 760
 			$Connection = new Connection();
761 761
 			$sth = $Connection->db->prepare($query);
762
-                        $sth->execute($query_values);
763
-                } catch(PDOException $e) {
764
-                        return "error : ".$e->getMessage();
765
-                }
762
+						$sth->execute($query_values);
763
+				} catch(PDOException $e) {
764
+						return "error : ".$e->getMessage();
765
+				}
766 766
 		$i++;
767 767
 /*
768 768
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 
877 877
 
878 878
 
879
-                return "success";
879
+				return "success";
880 880
 	}
881 881
 	
882 882
 	public static function translation() {
@@ -892,10 +892,10 @@  discard block
 block discarded – undo
892 892
 		try {
893 893
 			$Connection = new Connection();
894 894
 			$sth = $Connection->db->prepare($query);
895
-                        $sth->execute(array(':source' => 'translation.csv'));
896
-                } catch(PDOException $e) {
897
-                        return "error : ".$e->getMessage();
898
-                }
895
+						$sth->execute(array(':source' => 'translation.csv'));
896
+				} catch(PDOException $e) {
897
+						return "error : ".$e->getMessage();
898
+				}
899 899
 
900 900
 		
901 901
 		//update_db::unzip($out_file);
@@ -914,21 +914,21 @@  discard block
 block discarded – undo
914 914
 					$data = $row;
915 915
 					$operator = $data[2];
916 916
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
917
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
918
-                                                //echo substr($operator, 0, 2)."\n";;
919
-                                                if (count($airline_array) > 0) {
917
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
918
+												//echo substr($operator, 0, 2)."\n";;
919
+												if (count($airline_array) > 0) {
920 920
 							//print_r($airline_array);
921 921
 							$operator = $airline_array[0]['icao'].substr($operator,2);
922
-                                                }
923
-                                        }
922
+												}
923
+										}
924 924
 					
925 925
 					$operator_correct = $data[3];
926 926
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
927
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
928
-                                                if (count($airline_array) > 0) {
929
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
930
-                                            	}
931
-                                        }
927
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
928
+												if (count($airline_array) > 0) {
929
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
930
+												}
931
+										}
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$Connection->db->commit();
943 943
 		}
944 944
 		return '';
945
-        }
945
+		}
946 946
 	
947 947
 	public static function translation_fam() {
948 948
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -952,10 +952,10 @@  discard block
 block discarded – undo
952 952
 		try {
953 953
 			$Connection = new Connection();
954 954
 			$sth = $Connection->db->prepare($query);
955
-                        $sth->execute(array(':source' => 'website_fam'));
956
-                } catch(PDOException $e) {
957
-                        return "error : ".$e->getMessage();
958
-                }
955
+						$sth->execute(array(':source' => 'website_fam'));
956
+				} catch(PDOException $e) {
957
+						return "error : ".$e->getMessage();
958
+				}
959 959
 
960 960
 		
961 961
 		//update_db::unzip($out_file);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 			//$Connection->db->commit();
985 985
 		}
986 986
 		return '';
987
-        }
987
+		}
988 988
 
989 989
 	/*
990 990
 	* This function use FAA public data.
@@ -996,19 +996,19 @@  discard block
 block discarded – undo
996 996
 		try {
997 997
 			$Connection = new Connection();
998 998
 			$sth = $Connection->db->prepare($query);
999
-                        $sth->execute(array(':source' => 'website_faa'));
1000
-                } catch(PDOException $e) {
1001
-                        return "error : ".$e->getMessage();
1002
-                }
999
+						$sth->execute(array(':source' => 'website_faa'));
1000
+				} catch(PDOException $e) {
1001
+						return "error : ".$e->getMessage();
1002
+				}
1003 1003
 
1004 1004
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1005 1005
 		try {
1006 1006
 			$Connection = new Connection();
1007 1007
 			$sth = $Connection->db->prepare($query);
1008
-                        $sth->execute(array(':source' => 'website_faa'));
1009
-                } catch(PDOException $e) {
1010
-                        return "error : ".$e->getMessage();
1011
-                }
1008
+						$sth->execute(array(':source' => 'website_faa'));
1009
+				} catch(PDOException $e) {
1010
+						return "error : ".$e->getMessage();
1011
+				}
1012 1012
 
1013 1013
 		$delimiter = ",";
1014 1014
 		$mfr = array();
@@ -1084,17 +1084,17 @@  discard block
 block discarded – undo
1084 1084
 		}
1085 1085
 		print_r($mfr);
1086 1086
 		return '';
1087
-        }
1087
+		}
1088 1088
 	public static function modes_fam() {
1089 1089
 		global $tmp_dir, $globalTransaction;
1090 1090
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1091 1091
 		try {
1092 1092
 			$Connection = new Connection();
1093 1093
 			$sth = $Connection->db->prepare($query);
1094
-                        $sth->execute(array(':source' => 'website_fam'));
1095
-                } catch(PDOException $e) {
1096
-                        return "error : ".$e->getMessage();
1097
-                }
1094
+						$sth->execute(array(':source' => 'website_fam'));
1095
+				} catch(PDOException $e) {
1096
+						return "error : ".$e->getMessage();
1097
+				}
1098 1098
 
1099 1099
 		
1100 1100
 		//update_db::unzip($out_file);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 			if ($globalTransaction) $Connection->db->commit();
1125 1125
 		}
1126 1126
 		return '';
1127
-        }
1127
+		}
1128 1128
         
1129 1129
 	public static function owner_fam() {
1130 1130
 		global $tmp_dir, $globalTransaction;
@@ -1132,10 +1132,10 @@  discard block
 block discarded – undo
1132 1132
 		try {
1133 1133
 			$Connection = new Connection();
1134 1134
 			$sth = $Connection->db->prepare($query);
1135
-                        $sth->execute(array(':source' => 'website_fam'));
1136
-                } catch(PDOException $e) {
1137
-                        return "error : ".$e->getMessage();
1138
-                }
1135
+						$sth->execute(array(':source' => 'website_fam'));
1136
+				} catch(PDOException $e) {
1137
+						return "error : ".$e->getMessage();
1138
+				}
1139 1139
 
1140 1140
 		$delimiter = "\t";
1141 1141
 		$Connection = new Connection();
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 			if ($globalTransaction) $Connection->db->commit();
1162 1162
 		}
1163 1163
 		return '';
1164
-        }
1164
+		}
1165 1165
 
1166 1166
 	public static function routes_fam() {
1167 1167
 		global $tmp_dir, $globalTransaction;
@@ -1169,10 +1169,10 @@  discard block
 block discarded – undo
1169 1169
 		try {
1170 1170
 			$Connection = new Connection();
1171 1171
 			$sth = $Connection->db->prepare($query);
1172
-                        $sth->execute(array(':source' => 'website_fam'));
1173
-                } catch(PDOException $e) {
1174
-                        return "error : ".$e->getMessage();
1175
-                }
1172
+						$sth->execute(array(':source' => 'website_fam'));
1173
+				} catch(PDOException $e) {
1174
+						return "error : ".$e->getMessage();
1175
+				}
1176 1176
 
1177 1177
 		
1178 1178
 		//update_db::unzip($out_file);
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 			if ($globalTransaction) $Connection->db->commit();
1202 1202
 		}
1203 1203
 		return '';
1204
-        }
1204
+		}
1205 1205
 
1206 1206
 	public static function marine_identity_fam() {
1207 1207
 		global $tmp_dir, $globalTransaction;
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
 		try {
1210 1210
 			$Connection = new Connection();
1211 1211
 			$sth = $Connection->db->prepare($query);
1212
-                        $sth->execute();
1213
-                } catch(PDOException $e) {
1214
-                        return "error : ".$e->getMessage();
1215
-                }
1212
+						$sth->execute();
1213
+				} catch(PDOException $e) {
1214
+						return "error : ".$e->getMessage();
1215
+				}
1216 1216
 
1217 1217
 		
1218 1218
 		//update_db::unzip($out_file);
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			if ($globalTransaction) $Connection->db->commit();
1243 1243
 		}
1244 1244
 		return '';
1245
-        }
1245
+		}
1246 1246
 
1247 1247
 	public static function banned_fam() {
1248 1248
 		global $tmp_dir, $globalTransaction;
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 			if ($globalTransaction) $Connection->db->commit();
1277 1277
 		}
1278 1278
 		return '';
1279
-        }
1279
+		}
1280 1280
 
1281 1281
 	public static function tle($filename,$tletype) {
1282 1282
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1287,10 +1287,10 @@  discard block
 block discarded – undo
1287 1287
 		try {
1288 1288
 			$Connection = new Connection();
1289 1289
 			$sth = $Connection->db->prepare($query);
1290
-                        $sth->execute(array(':source' => $filename));
1291
-                } catch(PDOException $e) {
1292
-                        return "error : ".$e->getMessage();
1293
-                }
1290
+						$sth->execute(array(':source' => $filename));
1291
+				} catch(PDOException $e) {
1292
+						return "error : ".$e->getMessage();
1293
+				}
1294 1294
 		
1295 1295
 		$Connection = new Connection();
1296 1296
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1325,54 +1325,54 @@  discard block
 block discarded – undo
1325 1325
 			//$Connection->db->commit();
1326 1326
 		}
1327 1327
 		return '';
1328
-        }
1328
+		}
1329 1329
 
1330 1330
 	/**
1331
-        * Convert a HTML table to an array
1332
-        * @param String $data HTML page
1333
-        * @return Array array of the tables in HTML page
1334
-        */
1335
-        private static function table2array($data) {
1336
-                $html = str_get_html($data);
1337
-                $tabledata=array();
1338
-                foreach($html->find('tr') as $element)
1339
-                {
1340
-                        $td = array();
1341
-                        foreach( $element->find('th') as $row)
1342
-                        {
1343
-                                $td [] = trim($row->plaintext);
1344
-                        }
1345
-                        $td=array_filter($td);
1346
-                        $tabledata[] = $td;
1347
-
1348
-                        $td = array();
1349
-                        $tdi = array();
1350
-                        foreach( $element->find('td') as $row)
1351
-                        {
1352
-                                $td [] = trim($row->plaintext);
1353
-                                $tdi [] = trim($row->innertext);
1354
-                        }
1355
-                        $td=array_filter($td);
1356
-                        $tdi=array_filter($tdi);
1357
-                    //    $tabledata[]=array_merge($td,$tdi);
1358
-                        $tabledata[]=$td;
1359
-                }
1360
-                return(array_filter($tabledata));
1361
-        }
1362
-
1363
-       /**
1364
-        * Get data from form result
1365
-        * @param String $url form URL
1366
-        * @return String the result
1367
-        */
1368
-        private static function getData($url) {
1369
-                $ch = curl_init();
1370
-                curl_setopt($ch, CURLOPT_URL, $url);
1371
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1372
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1373
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1374
-                return curl_exec($ch);
1375
-        }
1331
+	 * Convert a HTML table to an array
1332
+	 * @param String $data HTML page
1333
+	 * @return Array array of the tables in HTML page
1334
+	 */
1335
+		private static function table2array($data) {
1336
+				$html = str_get_html($data);
1337
+				$tabledata=array();
1338
+				foreach($html->find('tr') as $element)
1339
+				{
1340
+						$td = array();
1341
+						foreach( $element->find('th') as $row)
1342
+						{
1343
+								$td [] = trim($row->plaintext);
1344
+						}
1345
+						$td=array_filter($td);
1346
+						$tabledata[] = $td;
1347
+
1348
+						$td = array();
1349
+						$tdi = array();
1350
+						foreach( $element->find('td') as $row)
1351
+						{
1352
+								$td [] = trim($row->plaintext);
1353
+								$tdi [] = trim($row->innertext);
1354
+						}
1355
+						$td=array_filter($td);
1356
+						$tdi=array_filter($tdi);
1357
+					//    $tabledata[]=array_merge($td,$tdi);
1358
+						$tabledata[]=$td;
1359
+				}
1360
+				return(array_filter($tabledata));
1361
+		}
1362
+
1363
+	   /**
1364
+	    * Get data from form result
1365
+	    * @param String $url form URL
1366
+	    * @return String the result
1367
+	    */
1368
+		private static function getData($url) {
1369
+				$ch = curl_init();
1370
+				curl_setopt($ch, CURLOPT_URL, $url);
1371
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1372
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1373
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1374
+				return curl_exec($ch);
1375
+		}
1376 1376
 /*
1377 1377
 	public static function waypoints() {
1378 1378
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 			if ($globalTransaction) $Connection->db->commit();
1456 1456
 		}
1457 1457
 		return '';
1458
-        }
1458
+		}
1459 1459
 
1460 1460
 	public static function ivao_airlines($filename) {
1461 1461
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1465,10 +1465,10 @@  discard block
 block discarded – undo
1465 1465
 		try {
1466 1466
 			$Connection = new Connection();
1467 1467
 			$sth = $Connection->db->prepare($query);
1468
-                        $sth->execute();
1469
-                } catch(PDOException $e) {
1470
-                        return "error : ".$e->getMessage();
1471
-                }
1468
+						$sth->execute();
1469
+				} catch(PDOException $e) {
1470
+						return "error : ".$e->getMessage();
1471
+				}
1472 1472
 
1473 1473
 		$header = NULL;
1474 1474
 		$delimiter = ':';
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 			if ($globalTransaction) $Connection->db->commit();
1493 1493
 		}
1494 1494
 		return '';
1495
-        }
1495
+		}
1496 1496
 	
1497 1497
 	public static function update_airspace() {
1498 1498
 		global $tmp_dir, $globalDBdriver;
@@ -1502,11 +1502,11 @@  discard block
 block discarded – undo
1502 1502
 			$query = 'DROP TABLE airspace';
1503 1503
 			try {
1504 1504
 				$sth = $Connection->db->prepare($query);
1505
-                    		$sth->execute();
1506
-	                } catch(PDOException $e) {
1505
+							$sth->execute();
1506
+					} catch(PDOException $e) {
1507 1507
 				return "error : ".$e->getMessage();
1508
-	                }
1509
-	        }
1508
+					}
1509
+			}
1510 1510
 
1511 1511
 
1512 1512
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1561,10 +1561,10 @@  discard block
 block discarded – undo
1561 1561
 			$query = 'DROP TABLE countries';
1562 1562
 			try {
1563 1563
 				$sth = $Connection->db->prepare($query);
1564
-            	        	$sth->execute();
1565
-	                } catch(PDOException $e) {
1566
-    	                	echo "error : ".$e->getMessage();
1567
-	                }
1564
+							$sth->execute();
1565
+					} catch(PDOException $e) {
1566
+							echo "error : ".$e->getMessage();
1567
+					}
1568 1568
 		}
1569 1569
 		if ($globalDBdriver == 'mysql') {
1570 1570
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2093,11 +2093,11 @@  discard block
 block discarded – undo
2093 2093
 						$query = 'DROP TABLE airspace';
2094 2094
 						try {
2095 2095
 							$sth = $Connection->db->prepare($query);
2096
-    	    	    					$sth->execute();
2097
-			            		} catch(PDOException $e) {
2096
+										$sth->execute();
2097
+								} catch(PDOException $e) {
2098 2098
 							return "error : ".$e->getMessage();
2099
-		            			}
2100
-		    			}
2099
+								}
2100
+						}
2101 2101
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2102 2102
 					update_db::insert_airspace_version($airspace_md5);
2103 2103
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2277,12 +2277,12 @@  discard block
 block discarded – undo
2277 2277
 		echo $data;
2278 2278
 		*/
2279 2279
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2280
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2281
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2282
-		    $result = fread($fh,100000000);
2283
-		    //echo $result;
2284
-		    //var_dump(str_get_html($result));
2285
-		    //print_r(self::table2array($result));
2280
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2281
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2282
+			$result = fread($fh,100000000);
2283
+			//echo $result;
2284
+			//var_dump(str_get_html($result));
2285
+			//print_r(self::table2array($result));
2286 2286
 		}
2287 2287
 
2288 2288
 	}
@@ -2296,10 +2296,10 @@  discard block
 block discarded – undo
2296 2296
 		try {
2297 2297
 			$Connection = new Connection();
2298 2298
 			$sth = $Connection->db->prepare($query);
2299
-                        $sth->execute();
2300
-                } catch(PDOException $e) {
2301
-                        return "error : ".$e->getMessage();
2302
-                }
2299
+						$sth->execute();
2300
+				} catch(PDOException $e) {
2301
+						return "error : ".$e->getMessage();
2302
+				}
2303 2303
 
2304 2304
 		$error = '';
2305 2305
 		if ($globalDebug) echo "Notam : Download...";
@@ -2355,8 +2355,8 @@  discard block
 block discarded – undo
2355 2355
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2356 2356
 					$data['permanent'] = 0;
2357 2357
 				} else {
2358
-				    $data['date_end'] = NULL;
2359
-				    $data['permanent'] = 1;
2358
+					$data['date_end'] = NULL;
2359
+					$data['permanent'] = 1;
2360 2360
 				}
2361 2361
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2362 2362
 				$NOTAM = new NOTAM();
@@ -2430,13 +2430,13 @@  discard block
 block discarded – undo
2430 2430
 		try {
2431 2431
 			$Connection = new Connection();
2432 2432
 			$sth = $Connection->db->prepare($query);
2433
-                        $sth->execute();
2434
-                } catch(PDOException $e) {
2435
-                        return "error : ".$e->getMessage();
2436
-                }
2437
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2438
-                if ($row['nb'] > 0) return false;
2439
-                else return true;
2433
+						$sth->execute();
2434
+				} catch(PDOException $e) {
2435
+						return "error : ".$e->getMessage();
2436
+				}
2437
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2438
+				if ($row['nb'] > 0) return false;
2439
+				else return true;
2440 2440
 	}
2441 2441
 
2442 2442
 	public static function insert_last_update() {
@@ -2445,10 +2445,10 @@  discard block
 block discarded – undo
2445 2445
 		try {
2446 2446
 			$Connection = new Connection();
2447 2447
 			$sth = $Connection->db->prepare($query);
2448
-                        $sth->execute();
2449
-                } catch(PDOException $e) {
2450
-                        return "error : ".$e->getMessage();
2451
-                }
2448
+						$sth->execute();
2449
+				} catch(PDOException $e) {
2450
+						return "error : ".$e->getMessage();
2451
+				}
2452 2452
 	}
2453 2453
 
2454 2454
 	public static function check_airspace_version($version) {
@@ -2456,13 +2456,13 @@  discard block
 block discarded – undo
2456 2456
 		try {
2457 2457
 			$Connection = new Connection();
2458 2458
 			$sth = $Connection->db->prepare($query);
2459
-                        $sth->execute(array(':version' => $version));
2460
-                } catch(PDOException $e) {
2461
-                        return "error : ".$e->getMessage();
2462
-                }
2463
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2464
-                if ($row['nb'] > 0) return true;
2465
-                else return false;
2459
+						$sth->execute(array(':version' => $version));
2460
+				} catch(PDOException $e) {
2461
+						return "error : ".$e->getMessage();
2462
+				}
2463
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2464
+				if ($row['nb'] > 0) return true;
2465
+				else return false;
2466 2466
 	}
2467 2467
 
2468 2468
 	public static function check_geoid_version($version) {
@@ -2470,13 +2470,13 @@  discard block
 block discarded – undo
2470 2470
 		try {
2471 2471
 			$Connection = new Connection();
2472 2472
 			$sth = $Connection->db->prepare($query);
2473
-                        $sth->execute(array(':version' => $version));
2474
-                } catch(PDOException $e) {
2475
-                        return "error : ".$e->getMessage();
2476
-                }
2477
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2478
-                if ($row['nb'] > 0) return true;
2479
-                else return false;
2473
+						$sth->execute(array(':version' => $version));
2474
+				} catch(PDOException $e) {
2475
+						return "error : ".$e->getMessage();
2476
+				}
2477
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2478
+				if ($row['nb'] > 0) return true;
2479
+				else return false;
2480 2480
 	}
2481 2481
 
2482 2482
 	public static function check_marine_identity_version($version) {
@@ -2484,13 +2484,13 @@  discard block
 block discarded – undo
2484 2484
 		try {
2485 2485
 			$Connection = new Connection();
2486 2486
 			$sth = $Connection->db->prepare($query);
2487
-                        $sth->execute(array(':version' => $version));
2488
-                } catch(PDOException $e) {
2489
-                        return "error : ".$e->getMessage();
2490
-                }
2491
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2492
-                if ($row['nb'] > 0) return true;
2493
-                else return false;
2487
+						$sth->execute(array(':version' => $version));
2488
+				} catch(PDOException $e) {
2489
+						return "error : ".$e->getMessage();
2490
+				}
2491
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2492
+				if ($row['nb'] > 0) return true;
2493
+				else return false;
2494 2494
 	}
2495 2495
 
2496 2496
 
@@ -2512,10 +2512,10 @@  discard block
 block discarded – undo
2512 2512
 		try {
2513 2513
 			$Connection = new Connection();
2514 2514
 			$sth = $Connection->db->prepare($query);
2515
-                        $sth->execute(array(':version' => $version));
2516
-                } catch(PDOException $e) {
2517
-                        return "error : ".$e->getMessage();
2518
-                }
2515
+						$sth->execute(array(':version' => $version));
2516
+				} catch(PDOException $e) {
2517
+						return "error : ".$e->getMessage();
2518
+				}
2519 2519
 	}
2520 2520
 
2521 2521
 	public static function insert_marine_identity_version($version) {
@@ -2524,10 +2524,10 @@  discard block
 block discarded – undo
2524 2524
 		try {
2525 2525
 			$Connection = new Connection();
2526 2526
 			$sth = $Connection->db->prepare($query);
2527
-                        $sth->execute(array(':version' => $version));
2528
-                } catch(PDOException $e) {
2529
-                        return "error : ".$e->getMessage();
2530
-                }
2527
+						$sth->execute(array(':version' => $version));
2528
+				} catch(PDOException $e) {
2529
+						return "error : ".$e->getMessage();
2530
+				}
2531 2531
 	}
2532 2532
 
2533 2533
 	public static function check_last_notam_update() {
@@ -2540,13 +2540,13 @@  discard block
 block discarded – undo
2540 2540
 		try {
2541 2541
 			$Connection = new Connection();
2542 2542
 			$sth = $Connection->db->prepare($query);
2543
-                        $sth->execute();
2544
-                } catch(PDOException $e) {
2545
-                        return "error : ".$e->getMessage();
2546
-                }
2547
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2548
-                if ($row['nb'] > 0) return false;
2549
-                else return true;
2543
+						$sth->execute();
2544
+				} catch(PDOException $e) {
2545
+						return "error : ".$e->getMessage();
2546
+				}
2547
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2548
+				if ($row['nb'] > 0) return false;
2549
+				else return true;
2550 2550
 	}
2551 2551
 
2552 2552
 	public static function insert_last_notam_update() {
@@ -2555,10 +2555,10 @@  discard block
 block discarded – undo
2555 2555
 		try {
2556 2556
 			$Connection = new Connection();
2557 2557
 			$sth = $Connection->db->prepare($query);
2558
-                        $sth->execute();
2559
-                } catch(PDOException $e) {
2560
-                        return "error : ".$e->getMessage();
2561
-                }
2558
+						$sth->execute();
2559
+				} catch(PDOException $e) {
2560
+						return "error : ".$e->getMessage();
2561
+				}
2562 2562
 	}
2563 2563
 
2564 2564
 	public static function check_last_airspace_update() {
@@ -2571,13 +2571,13 @@  discard block
 block discarded – undo
2571 2571
 		try {
2572 2572
 			$Connection = new Connection();
2573 2573
 			$sth = $Connection->db->prepare($query);
2574
-                        $sth->execute();
2575
-                } catch(PDOException $e) {
2576
-                        return "error : ".$e->getMessage();
2577
-                }
2578
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2579
-                if ($row['nb'] > 0) return false;
2580
-                else return true;
2574
+						$sth->execute();
2575
+				} catch(PDOException $e) {
2576
+						return "error : ".$e->getMessage();
2577
+				}
2578
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2579
+				if ($row['nb'] > 0) return false;
2580
+				else return true;
2581 2581
 	}
2582 2582
 
2583 2583
 	public static function insert_last_airspace_update() {
@@ -2586,10 +2586,10 @@  discard block
 block discarded – undo
2586 2586
 		try {
2587 2587
 			$Connection = new Connection();
2588 2588
 			$sth = $Connection->db->prepare($query);
2589
-                        $sth->execute();
2590
-                } catch(PDOException $e) {
2591
-                        return "error : ".$e->getMessage();
2592
-                }
2589
+						$sth->execute();
2590
+				} catch(PDOException $e) {
2591
+						return "error : ".$e->getMessage();
2592
+				}
2593 2593
 	}
2594 2594
 
2595 2595
 	public static function check_last_geoid_update() {
@@ -2602,13 +2602,13 @@  discard block
 block discarded – undo
2602 2602
 		try {
2603 2603
 			$Connection = new Connection();
2604 2604
 			$sth = $Connection->db->prepare($query);
2605
-                        $sth->execute();
2606
-                } catch(PDOException $e) {
2607
-                        return "error : ".$e->getMessage();
2608
-                }
2609
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2610
-                if ($row['nb'] > 0) return false;
2611
-                else return true;
2605
+						$sth->execute();
2606
+				} catch(PDOException $e) {
2607
+						return "error : ".$e->getMessage();
2608
+				}
2609
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2610
+				if ($row['nb'] > 0) return false;
2611
+				else return true;
2612 2612
 	}
2613 2613
 
2614 2614
 	public static function insert_last_geoid_update() {
@@ -2617,10 +2617,10 @@  discard block
 block discarded – undo
2617 2617
 		try {
2618 2618
 			$Connection = new Connection();
2619 2619
 			$sth = $Connection->db->prepare($query);
2620
-                        $sth->execute();
2621
-                } catch(PDOException $e) {
2622
-                        return "error : ".$e->getMessage();
2623
-                }
2620
+						$sth->execute();
2621
+				} catch(PDOException $e) {
2622
+						return "error : ".$e->getMessage();
2623
+				}
2624 2624
 	}
2625 2625
 
2626 2626
 	public static function check_last_owner_update() {
@@ -2633,13 +2633,13 @@  discard block
 block discarded – undo
2633 2633
 		try {
2634 2634
 			$Connection = new Connection();
2635 2635
 			$sth = $Connection->db->prepare($query);
2636
-                        $sth->execute();
2637
-                } catch(PDOException $e) {
2638
-                        return "error : ".$e->getMessage();
2639
-                }
2640
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2641
-                if ($row['nb'] > 0) return false;
2642
-                else return true;
2636
+						$sth->execute();
2637
+				} catch(PDOException $e) {
2638
+						return "error : ".$e->getMessage();
2639
+				}
2640
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2641
+				if ($row['nb'] > 0) return false;
2642
+				else return true;
2643 2643
 	}
2644 2644
 
2645 2645
 	public static function insert_last_owner_update() {
@@ -2648,10 +2648,10 @@  discard block
 block discarded – undo
2648 2648
 		try {
2649 2649
 			$Connection = new Connection();
2650 2650
 			$sth = $Connection->db->prepare($query);
2651
-                        $sth->execute();
2652
-                } catch(PDOException $e) {
2653
-                        return "error : ".$e->getMessage();
2654
-                }
2651
+						$sth->execute();
2652
+				} catch(PDOException $e) {
2653
+						return "error : ".$e->getMessage();
2654
+				}
2655 2655
 	}
2656 2656
 	public static function check_last_schedules_update() {
2657 2657
 		global $globalDBdriver;
@@ -2663,13 +2663,13 @@  discard block
 block discarded – undo
2663 2663
 		try {
2664 2664
 			$Connection = new Connection();
2665 2665
 			$sth = $Connection->db->prepare($query);
2666
-                        $sth->execute();
2667
-                } catch(PDOException $e) {
2668
-                        return "error : ".$e->getMessage();
2669
-                }
2670
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2671
-                if ($row['nb'] > 0) return false;
2672
-                else return true;
2666
+						$sth->execute();
2667
+				} catch(PDOException $e) {
2668
+						return "error : ".$e->getMessage();
2669
+				}
2670
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2671
+				if ($row['nb'] > 0) return false;
2672
+				else return true;
2673 2673
 	}
2674 2674
 
2675 2675
 	public static function insert_last_schedules_update() {
@@ -2678,10 +2678,10 @@  discard block
 block discarded – undo
2678 2678
 		try {
2679 2679
 			$Connection = new Connection();
2680 2680
 			$sth = $Connection->db->prepare($query);
2681
-                        $sth->execute();
2682
-                } catch(PDOException $e) {
2683
-                        return "error : ".$e->getMessage();
2684
-                }
2681
+						$sth->execute();
2682
+				} catch(PDOException $e) {
2683
+						return "error : ".$e->getMessage();
2684
+				}
2685 2685
 	}
2686 2686
 	public static function check_last_tle_update() {
2687 2687
 		global $globalDBdriver;
@@ -2693,13 +2693,13 @@  discard block
 block discarded – undo
2693 2693
 		try {
2694 2694
 			$Connection = new Connection();
2695 2695
 			$sth = $Connection->db->prepare($query);
2696
-                        $sth->execute();
2697
-                } catch(PDOException $e) {
2698
-                        return "error : ".$e->getMessage();
2699
-                }
2700
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2701
-                if ($row['nb'] > 0) return false;
2702
-                else return true;
2696
+						$sth->execute();
2697
+				} catch(PDOException $e) {
2698
+						return "error : ".$e->getMessage();
2699
+				}
2700
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2701
+				if ($row['nb'] > 0) return false;
2702
+				else return true;
2703 2703
 	}
2704 2704
 
2705 2705
 	public static function insert_last_tle_update() {
@@ -2708,10 +2708,10 @@  discard block
 block discarded – undo
2708 2708
 		try {
2709 2709
 			$Connection = new Connection();
2710 2710
 			$sth = $Connection->db->prepare($query);
2711
-                        $sth->execute();
2712
-                } catch(PDOException $e) {
2713
-                        return "error : ".$e->getMessage();
2714
-                }
2711
+						$sth->execute();
2712
+				} catch(PDOException $e) {
2713
+						return "error : ".$e->getMessage();
2714
+				}
2715 2715
 	}
2716 2716
 	public static function check_last_marine_identity_update() {
2717 2717
 		global $globalDBdriver;
@@ -2723,13 +2723,13 @@  discard block
 block discarded – undo
2723 2723
 		try {
2724 2724
 			$Connection = new Connection();
2725 2725
 			$sth = $Connection->db->prepare($query);
2726
-                        $sth->execute();
2727
-                } catch(PDOException $e) {
2728
-                        return "error : ".$e->getMessage();
2729
-                }
2730
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2731
-                if ($row['nb'] > 0) return false;
2732
-                else return true;
2726
+						$sth->execute();
2727
+				} catch(PDOException $e) {
2728
+						return "error : ".$e->getMessage();
2729
+				}
2730
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2731
+				if ($row['nb'] > 0) return false;
2732
+				else return true;
2733 2733
 	}
2734 2734
 
2735 2735
 	public static function insert_last_marine_identity_update() {
@@ -2738,10 +2738,10 @@  discard block
 block discarded – undo
2738 2738
 		try {
2739 2739
 			$Connection = new Connection();
2740 2740
 			$sth = $Connection->db->prepare($query);
2741
-                        $sth->execute();
2742
-                } catch(PDOException $e) {
2743
-                        return "error : ".$e->getMessage();
2744
-                }
2741
+						$sth->execute();
2742
+				} catch(PDOException $e) {
2743
+						return "error : ".$e->getMessage();
2744
+				}
2745 2745
 	}
2746 2746
 	public static function delete_duplicatemodes() {
2747 2747
 		global $globalDBdriver;
@@ -2753,10 +2753,10 @@  discard block
 block discarded – undo
2753 2753
 		try {
2754 2754
 			$Connection = new Connection();
2755 2755
 			$sth = $Connection->db->prepare($query);
2756
-                        $sth->execute();
2757
-                } catch(PDOException $e) {
2758
-                        return "error : ".$e->getMessage();
2759
-                }
2756
+						$sth->execute();
2757
+				} catch(PDOException $e) {
2758
+						return "error : ".$e->getMessage();
2759
+				}
2760 2760
 	}
2761 2761
 	public static function delete_duplicateowner() {
2762 2762
 		global $globalDBdriver;
@@ -2768,10 +2768,10 @@  discard block
 block discarded – undo
2768 2768
 		try {
2769 2769
 			$Connection = new Connection();
2770 2770
 			$sth = $Connection->db->prepare($query);
2771
-                        $sth->execute();
2772
-                } catch(PDOException $e) {
2773
-                        return "error : ".$e->getMessage();
2774
-                }
2771
+						$sth->execute();
2772
+				} catch(PDOException $e) {
2773
+						return "error : ".$e->getMessage();
2774
+				}
2775 2775
 	}
2776 2776
 	
2777 2777
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 			$Connection = new Connection();
669 669
 			$sth = $Connection->db->prepare($query);
670 670
                         $sth->execute();
671
-                } catch(PDOException $e) {
671
+                } catch (PDOException $e) {
672 672
                         return "error : ".$e->getMessage();
673 673
                 }
674 674
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			$Connection = new Connection();
679 679
 			$sth = $Connection->db->prepare($query);
680 680
                         $sth->execute();
681
-                } catch(PDOException $e) {
681
+                } catch (PDOException $e) {
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 		if ($globalTransaction) $Connection->db->beginTransaction();
690 690
   
691 691
 		$i = 0;
692
-		while($row = sparql_fetch_array($result))
692
+		while ($row = sparql_fetch_array($result))
693 693
 		{
694 694
 			if ($i >= 1) {
695 695
 			//print_r($row);
@@ -709,31 +709,31 @@  discard block
 block discarded – undo
709 709
 				$row['image'] = '';
710 710
 				$row['image_thumb'] = '';
711 711
 			} else {
712
-				$image = str_replace(' ','_',$row['image']);
712
+				$image = str_replace(' ', '_', $row['image']);
713 713
 				$digest = md5($image);
714
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
715
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
717
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
714
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
715
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
717
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
718 718
 			}
719 719
 			
720
-			$country = explode('-',$row['country']);
720
+			$country = explode('-', $row['country']);
721 721
 			$row['country'] = $country[0];
722 722
 			
723 723
 			$row['type'] = trim($row['type']);
724
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
724
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
725 725
 				$row['type'] = 'Military';
726 726
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
727 727
 				$row['type'] = 'small_airport';
728 728
 			}
729 729
 			
730
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
731
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
730
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
731
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
732 732
 			//print_r($query_dest_values);
733 733
 			
734 734
 			try {
735 735
 				$sth_dest->execute($query_dest_values);
736
-			} catch(PDOException $e) {
736
+			} catch (PDOException $e) {
737 737
 				return "error : ".$e->getMessage();
738 738
 			}
739 739
 			}
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			$Connection = new Connection();
748 748
 			$sth = $Connection->db->prepare($query);
749 749
                         $sth->execute();
750
-                } catch(PDOException $e) {
750
+                } catch (PDOException $e) {
751 751
                         return "error : ".$e->getMessage();
752 752
                 }
753 753
 
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 		if ($globalDebug) echo "Insert Not available Airport...\n";
756 756
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
757 757
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
758
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
758
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
759 759
 		try {
760 760
 			$Connection = new Connection();
761 761
 			$sth = $Connection->db->prepare($query);
762 762
                         $sth->execute($query_values);
763
-                } catch(PDOException $e) {
763
+                } catch (PDOException $e) {
764 764
                         return "error : ".$e->getMessage();
765 765
                 }
766 766
 		$i++;
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		echo "Download data from ourairports.com...\n";
779 779
 		$delimiter = ',';
780 780
 		$out_file = $tmp_dir.'airports.csv';
781
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
781
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
782 782
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
783 783
 		echo "Add data from ourairports.com...\n";
784 784
 
@@ -789,32 +789,32 @@  discard block
 block discarded – undo
789 789
 			//$Connection->db->beginTransaction();
790 790
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
791 791
 			{
792
-				if(!$header) $header = $row;
792
+				if (!$header) $header = $row;
793 793
 				else {
794 794
 					$data = array();
795 795
 					$data = array_combine($header, $row);
796 796
 					try {
797 797
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
798 798
 						$sth->execute(array(':icao' => $data['gps_code']));
799
-					} catch(PDOException $e) {
799
+					} catch (PDOException $e) {
800 800
 						return "error : ".$e->getMessage();
801 801
 					}
802 802
 					if ($sth->fetchColumn() > 0) {
803 803
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
804 804
 						try {
805 805
 							$sth = $Connection->db->prepare($query);
806
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
807
-						} catch(PDOException $e) {
806
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
807
+						} catch (PDOException $e) {
808 808
 							return "error : ".$e->getMessage();
809 809
 						}
810 810
 					} else {
811 811
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
812 812
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
813
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
813
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
814 814
 						try {
815 815
 							$sth = $Connection->db->prepare($query);
816 816
 							$sth->execute($query_values);
817
-						} catch(PDOException $e) {
817
+						} catch (PDOException $e) {
818 818
 							return "error : ".$e->getMessage();
819 819
 						}
820 820
 						$i++;
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
 		echo "Download data from another free database...\n";
829 829
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
830
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
830
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
831 831
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
832 832
 		update_db::unzip($out_file);
833 833
 		$header = NULL;
@@ -839,15 +839,15 @@  discard block
 block discarded – undo
839 839
 			//$Connection->db->beginTransaction();
840 840
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
841 841
 			{
842
-				if(!$header) $header = $row;
842
+				if (!$header) $header = $row;
843 843
 				else {
844 844
 					$data = $row;
845 845
 
846 846
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
847 847
 					try {
848 848
 						$sth = $Connection->db->prepare($query);
849
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
850
-					} catch(PDOException $e) {
849
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
850
+					} catch (PDOException $e) {
851 851
 						return "error : ".$e->getMessage();
852 852
 					}
853 853
 				}
@@ -861,15 +861,15 @@  discard block
 block discarded – undo
861 861
 		try {
862 862
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
863 863
 			$sth->execute();
864
-		} catch(PDOException $e) {
864
+		} catch (PDOException $e) {
865 865
 			return "error : ".$e->getMessage();
866 866
 		}
867 867
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
868 868
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
869 869
 			try {
870 870
 				$sth2 = $Connection->db->prepare($query2);
871
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
872
-			} catch(PDOException $e) {
871
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
872
+			} catch (PDOException $e) {
873 873
 				return "error : ".$e->getMessage();
874 874
 			}
875 875
 		}
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			$Connection = new Connection();
894 894
 			$sth = $Connection->db->prepare($query);
895 895
                         $sth->execute(array(':source' => 'translation.csv'));
896
-                } catch(PDOException $e) {
896
+                } catch (PDOException $e) {
897 897
                         return "error : ".$e->getMessage();
898 898
                 }
899 899
 
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
911 911
 			{
912 912
 				$i++;
913
-				if($i > 12) {
913
+				if ($i > 12) {
914 914
 					$data = $row;
915 915
 					$operator = $data[2];
916 916
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                                                 //echo substr($operator, 0, 2)."\n";;
919 919
                                                 if (count($airline_array) > 0) {
920 920
 							//print_r($airline_array);
921
-							$operator = $airline_array[0]['icao'].substr($operator,2);
921
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
922 922
                                                 }
923 923
                                         }
924 924
 					
@@ -926,14 +926,14 @@  discard block
 block discarded – undo
926 926
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
927 927
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
928 928
                                                 if (count($airline_array) > 0) {
929
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
929
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
930 930
                                             	}
931 931
                                         }
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
935
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
936
-					} catch(PDOException $e) {
935
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
936
+					} catch (PDOException $e) {
937 937
 						return "error : ".$e->getMessage();
938 938
 					}
939 939
 				}
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 			$Connection = new Connection();
954 954
 			$sth = $Connection->db->prepare($query);
955 955
                         $sth->execute(array(':source' => 'website_fam'));
956
-                } catch(PDOException $e) {
956
+                } catch (PDOException $e) {
957 957
                         return "error : ".$e->getMessage();
958 958
                 }
959 959
 
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
974 974
 					try {
975 975
 						$sth = $Connection->db->prepare($query);
976
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
977
-					} catch(PDOException $e) {
976
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
977
+					} catch (PDOException $e) {
978 978
 						return "error : ".$e->getMessage();
979 979
 					}
980 980
 				}
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 			$Connection = new Connection();
998 998
 			$sth = $Connection->db->prepare($query);
999 999
                         $sth->execute(array(':source' => 'website_faa'));
1000
-                } catch(PDOException $e) {
1000
+                } catch (PDOException $e) {
1001 1001
                         return "error : ".$e->getMessage();
1002 1002
                 }
1003 1003
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			$Connection = new Connection();
1007 1007
 			$sth = $Connection->db->prepare($query);
1008 1008
                         $sth->execute(array(':source' => 'website_faa'));
1009
-                } catch(PDOException $e) {
1009
+                } catch (PDOException $e) {
1010 1010
                         return "error : ".$e->getMessage();
1011 1011
                 }
1012 1012
 
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1024 1024
 					try {
1025 1025
 						$sths = $Connection->db->prepare($query_search);
1026
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1027
-					} catch(PDOException $e) {
1026
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1027
+					} catch (PDOException $e) {
1028 1028
 						return "error s : ".$e->getMessage();
1029 1029
 					}
1030 1030
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 							//}
1038 1038
 						try {
1039 1039
 							$sthi = $Connection->db->prepare($queryi);
1040
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1041
-						} catch(PDOException $e) {
1040
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1041
+						} catch (PDOException $e) {
1042 1042
 							return "error u : ".$e->getMessage();
1043 1043
 						}
1044 1044
 					} else {
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 						try {
1047 1047
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1048 1048
 							$sthsm->execute(array(':mfr' => $data[2]));
1049
-						} catch(PDOException $e) {
1049
+						} catch (PDOException $e) {
1050 1050
 							return "error mfr : ".$e->getMessage();
1051 1051
 						}
1052 1052
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1057 1057
 							try {
1058 1058
 								$sthf = $Connection->db->prepare($queryf);
1059
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1060
-							} catch(PDOException $e) {
1059
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1060
+							} catch (PDOException $e) {
1061 1061
 								return "error f : ".$e->getMessage();
1062 1062
 							}
1063 1063
 						}
@@ -1067,13 +1067,13 @@  discard block
 block discarded – undo
1067 1067
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1068 1068
 						try {
1069 1069
 							$sth = $Connection->db->prepare($query);
1070
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1071
-						} catch(PDOException $e) {
1070
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1071
+						} catch (PDOException $e) {
1072 1072
 							return "error i : ".$e->getMessage();
1073 1073
 						}
1074 1074
 					}
1075 1075
 				}
1076
-				if ($i % 90 == 0) {
1076
+				if ($i%90 == 0) {
1077 1077
 					if ($globalTransaction) $Connection->db->commit();
1078 1078
 					if ($globalTransaction) $Connection->db->beginTransaction();
1079 1079
 				}
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			$Connection = new Connection();
1093 1093
 			$sth = $Connection->db->prepare($query);
1094 1094
                         $sth->execute(array(':source' => 'website_fam'));
1095
-                } catch(PDOException $e) {
1095
+                } catch (PDOException $e) {
1096 1096
                         return "error : ".$e->getMessage();
1097 1097
                 }
1098 1098
 
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1114 1114
 					try {
1115 1115
 						$sth = $Connection->db->prepare($query);
1116
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1117
-					} catch(PDOException $e) {
1116
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1117
+					} catch (PDOException $e) {
1118 1118
 						return "error : ".$e->getMessage();
1119 1119
 					}
1120 1120
 				}
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 			$Connection = new Connection();
1134 1134
 			$sth = $Connection->db->prepare($query);
1135 1135
                         $sth->execute(array(':source' => 'website_fam'));
1136
-                } catch(PDOException $e) {
1136
+                } catch (PDOException $e) {
1137 1137
                         return "error : ".$e->getMessage();
1138 1138
                 }
1139 1139
 
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1150 1150
 					try {
1151 1151
 						$sth = $Connection->db->prepare($query);
1152
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1153
-					} catch(PDOException $e) {
1152
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1153
+					} catch (PDOException $e) {
1154 1154
 						print_r($data);
1155 1155
 						return "error : ".$e->getMessage();
1156 1156
 					}
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			$Connection = new Connection();
1171 1171
 			$sth = $Connection->db->prepare($query);
1172 1172
                         $sth->execute(array(':source' => 'website_fam'));
1173
-                } catch(PDOException $e) {
1173
+                } catch (PDOException $e) {
1174 1174
                         return "error : ".$e->getMessage();
1175 1175
                 }
1176 1176
 
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1191 1191
 					try {
1192 1192
 						$sth = $Connection->db->prepare($query);
1193
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1194
-					} catch(PDOException $e) {
1193
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1194
+					} catch (PDOException $e) {
1195 1195
 						return "error : ".$e->getMessage();
1196 1196
 					}
1197 1197
 				}
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 			$Connection = new Connection();
1211 1211
 			$sth = $Connection->db->prepare($query);
1212 1212
                         $sth->execute();
1213
-                } catch(PDOException $e) {
1213
+                } catch (PDOException $e) {
1214 1214
                         return "error : ".$e->getMessage();
1215 1215
                 }
1216 1216
 
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1232 1232
 					try {
1233 1233
 						$sth = $Connection->db->prepare($query);
1234
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1235
-					} catch(PDOException $e) {
1234
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1235
+					} catch (PDOException $e) {
1236 1236
 						return "error : ".$e->getMessage();
1237 1237
 					}
1238 1238
 				}
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 			$Connection = new Connection();
1252 1252
 			$sth = $Connection->db->prepare($query);
1253 1253
 			$sth->execute();
1254
-		} catch(PDOException $e) {
1254
+		} catch (PDOException $e) {
1255 1255
 			return "error : ".$e->getMessage();
1256 1256
 		}
1257 1257
 
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 					try {
1268 1268
 						$sth = $Connection->db->prepare($query);
1269 1269
 						$sth->execute(array(':icao' => $icao));
1270
-					} catch(PDOException $e) {
1270
+					} catch (PDOException $e) {
1271 1271
 						return "error : ".$e->getMessage();
1272 1272
 					}
1273 1273
 				}
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		return '';
1279 1279
         }
1280 1280
 
1281
-	public static function tle($filename,$tletype) {
1281
+	public static function tle($filename, $tletype) {
1282 1282
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1283 1283
 		global $tmp_dir, $globalTransaction;
1284 1284
 		//$Spotter = new Spotter();
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 			$Connection = new Connection();
1289 1289
 			$sth = $Connection->db->prepare($query);
1290 1290
                         $sth->execute(array(':source' => $filename));
1291
-                } catch(PDOException $e) {
1291
+                } catch (PDOException $e) {
1292 1292
                         return "error : ".$e->getMessage();
1293 1293
                 }
1294 1294
 		
@@ -1313,8 +1313,8 @@  discard block
 block discarded – undo
1313 1313
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1314 1314
 					try {
1315 1315
 						$sth = $Connection->db->prepare($query);
1316
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1317
-					} catch(PDOException $e) {
1316
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1317
+					} catch (PDOException $e) {
1318 1318
 						return "error : ".$e->getMessage();
1319 1319
 					}
1320 1320
 
@@ -1334,28 +1334,28 @@  discard block
 block discarded – undo
1334 1334
         */
1335 1335
         private static function table2array($data) {
1336 1336
                 $html = str_get_html($data);
1337
-                $tabledata=array();
1338
-                foreach($html->find('tr') as $element)
1337
+                $tabledata = array();
1338
+                foreach ($html->find('tr') as $element)
1339 1339
                 {
1340 1340
                         $td = array();
1341
-                        foreach( $element->find('th') as $row)
1341
+                        foreach ($element->find('th') as $row)
1342 1342
                         {
1343 1343
                                 $td [] = trim($row->plaintext);
1344 1344
                         }
1345
-                        $td=array_filter($td);
1345
+                        $td = array_filter($td);
1346 1346
                         $tabledata[] = $td;
1347 1347
 
1348 1348
                         $td = array();
1349 1349
                         $tdi = array();
1350
-                        foreach( $element->find('td') as $row)
1350
+                        foreach ($element->find('td') as $row)
1351 1351
                         {
1352 1352
                                 $td [] = trim($row->plaintext);
1353 1353
                                 $tdi [] = trim($row->innertext);
1354 1354
                         }
1355
-                        $td=array_filter($td);
1356
-                        $tdi=array_filter($tdi);
1355
+                        $td = array_filter($td);
1356
+                        $tdi = array_filter($tdi);
1357 1357
                     //    $tabledata[]=array_merge($td,$tdi);
1358
-                        $tabledata[]=$td;
1358
+                        $tabledata[] = $td;
1359 1359
                 }
1360 1360
                 return(array_filter($tabledata));
1361 1361
         }
@@ -1428,13 +1428,13 @@  discard block
 block discarded – undo
1428 1428
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1429 1429
 			{
1430 1430
 				$i++;
1431
-				if($i > 3 && count($row) > 2) {
1431
+				if ($i > 3 && count($row) > 2) {
1432 1432
 					$data = array_values(array_filter($row));
1433 1433
 					$cntdata = count($data);
1434 1434
 					if ($cntdata > 10) {
1435 1435
 						$value = $data[9];
1436 1436
 						
1437
-						for ($i =10;$i < $cntdata;$i++) {
1437
+						for ($i = 10; $i < $cntdata; $i++) {
1438 1438
 							$value .= ' '.$data[$i];
1439 1439
 						}
1440 1440
 						$data[9] = $value;
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1445 1445
 						try {
1446 1446
 							$sth = $Connection->db->prepare($query);
1447
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1448
-						} catch(PDOException $e) {
1447
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1448
+						} catch (PDOException $e) {
1449 1449
 							return "error : ".$e->getMessage();
1450 1450
 						}
1451 1451
 					}
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 			$Connection = new Connection();
1467 1467
 			$sth = $Connection->db->prepare($query);
1468 1468
                         $sth->execute();
1469
-                } catch(PDOException $e) {
1469
+                } catch (PDOException $e) {
1470 1470
                         return "error : ".$e->getMessage();
1471 1471
                 }
1472 1472
 
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 			if ($globalTransaction) $Connection->db->beginTransaction();
1479 1479
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1480 1480
 			{
1481
-				if(count($row) > 1) {
1481
+				if (count($row) > 1) {
1482 1482
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1483 1483
 					try {
1484 1484
 						$sth = $Connection->db->prepare($query);
1485
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1486
-					} catch(PDOException $e) {
1485
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1486
+					} catch (PDOException $e) {
1487 1487
 						return "error : ".$e->getMessage();
1488 1488
 					}
1489 1489
 				}
@@ -1503,21 +1503,21 @@  discard block
 block discarded – undo
1503 1503
 			try {
1504 1504
 				$sth = $Connection->db->prepare($query);
1505 1505
                     		$sth->execute();
1506
-	                } catch(PDOException $e) {
1506
+	                } catch (PDOException $e) {
1507 1507
 				return "error : ".$e->getMessage();
1508 1508
 	                }
1509 1509
 	        }
1510 1510
 
1511 1511
 
1512
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1512
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1513 1513
 		else {
1514
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1514
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1515 1515
 			$query = "CREATE EXTENSION postgis";
1516
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1516
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1517 1517
 			try {
1518 1518
 				$sth = $Connection->db->prepare($query);
1519 1519
 				$sth->execute();
1520
-			} catch(PDOException $e) {
1520
+			} catch (PDOException $e) {
1521 1521
 				return "error : ".$e->getMessage();
1522 1522
 			}
1523 1523
 		}
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 		include_once('class.create_db.php');
1531 1531
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1532 1532
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1533
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1533
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1534 1534
 		$error = '';
1535 1535
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1536 1536
 			if ($globalDebug) echo "Gunzip...";
@@ -1562,14 +1562,14 @@  discard block
 block discarded – undo
1562 1562
 			try {
1563 1563
 				$sth = $Connection->db->prepare($query);
1564 1564
             	        	$sth->execute();
1565
-	                } catch(PDOException $e) {
1565
+	                } catch (PDOException $e) {
1566 1566
     	                	echo "error : ".$e->getMessage();
1567 1567
 	                }
1568 1568
 		}
1569 1569
 		if ($globalDBdriver == 'mysql') {
1570
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1570
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1571 1571
 		} else {
1572
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1572
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1573 1573
 		}
1574 1574
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1575 1575
 		return $error;
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1583 1583
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1584 1584
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1585
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1585
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1586 1586
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1587 1587
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1588 1588
 		return $error;
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1603 1603
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1604 1604
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1605
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1605
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1606 1606
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1607 1607
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1608 1608
 		if ($error != '') {
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 		global $tmp_dir, $globalDebug;
1616 1616
 		$error = '';
1617 1617
 		if ($globalDebug) echo "Routes : Download...";
1618
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1618
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1619 1619
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1620 1620
 			if ($globalDebug) echo "Gunzip...";
1621 1621
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 		global $tmp_dir, $globalDebug;
1632 1632
 		$error = '';
1633 1633
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1634
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1634
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1635 1635
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1636 1636
 			if ($globalDebug) echo "Gunzip...";
1637 1637
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		global $tmp_dir, $globalDebug;
1648 1648
 		$error = '';
1649 1649
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1650
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1650
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1651 1651
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1652 1652
 			if ($globalDebug) echo "Gunzip...";
1653 1653
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
 */
1676 1676
 		if ($globalDebug) echo "Modes : Download...";
1677 1677
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1678
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1678
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1679 1679
 
1680 1680
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1681 1681
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 	public static function update_ModeS_faa() {
1696 1696
 		global $tmp_dir, $globalDebug;
1697 1697
 		if ($globalDebug) echo "Modes FAA: Download...";
1698
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1698
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1699 1699
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1700 1700
 			if ($globalDebug) echo "Unzip...";
1701 1701
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 	public static function update_ModeS_flarm() {
1712 1712
 		global $tmp_dir, $globalDebug;
1713 1713
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1714
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1714
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1715 1715
 		if (file_exists($tmp_dir.'data.fln')) {
1716 1716
 			if ($globalDebug) echo "Add to DB...";
1717 1717
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 	public static function update_ModeS_ogn() {
1726 1726
 		global $tmp_dir, $globalDebug;
1727 1727
 		if ($globalDebug) echo "Modes OGN: Download...";
1728
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1728
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1729 1729
 		if (file_exists($tmp_dir.'ogn.csv')) {
1730 1730
 			if ($globalDebug) echo "Add to DB...";
1731 1731
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1740,201 +1740,201 @@  discard block
 block discarded – undo
1740 1740
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1741 1741
 		
1742 1742
 		if ($globalDebug) echo "Owner France: Download...";
1743
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1743
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1744 1744
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1745 1745
 			if ($globalDebug) echo "Add to DB...";
1746
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1746
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1747 1747
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1748 1748
 		if ($error != '') {
1749 1749
 			return $error;
1750 1750
 		} elseif ($globalDebug) echo "Done\n";
1751 1751
 		
1752 1752
 		if ($globalDebug) echo "Owner Ireland: Download...";
1753
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1753
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1754 1754
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1755 1755
 			if ($globalDebug) echo "Add to DB...";
1756
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1756
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1757 1757
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1758 1758
 		if ($error != '') {
1759 1759
 			return $error;
1760 1760
 		} elseif ($globalDebug) echo "Done\n";
1761 1761
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1762
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1762
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1763 1763
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1764 1764
 			if ($globalDebug) echo "Add to DB...";
1765
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1765
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1766 1766
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1767 1767
 		if ($error != '') {
1768 1768
 			return $error;
1769 1769
 		} elseif ($globalDebug) echo "Done\n";
1770 1770
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1771
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1771
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1772 1772
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1773 1773
 			if ($globalDebug) echo "Add to DB...";
1774
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1774
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1775 1775
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1776 1776
 		if ($error != '') {
1777 1777
 			return $error;
1778 1778
 		} elseif ($globalDebug) echo "Done\n";
1779 1779
 		if ($globalDebug) echo "Owner Australia: Download...";
1780
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1780
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1781 1781
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1782 1782
 			if ($globalDebug) echo "Add to DB...";
1783
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1783
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1784 1784
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1785 1785
 		if ($error != '') {
1786 1786
 			return $error;
1787 1787
 		} elseif ($globalDebug) echo "Done\n";
1788 1788
 		if ($globalDebug) echo "Owner Austria: Download...";
1789
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1789
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1790 1790
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1791 1791
 			if ($globalDebug) echo "Add to DB...";
1792
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1792
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1793 1793
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1794 1794
 		if ($error != '') {
1795 1795
 			return $error;
1796 1796
 		} elseif ($globalDebug) echo "Done\n";
1797 1797
 		if ($globalDebug) echo "Owner Chile: Download...";
1798
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1798
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1799 1799
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1800 1800
 			if ($globalDebug) echo "Add to DB...";
1801
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1801
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1802 1802
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1803 1803
 		if ($error != '') {
1804 1804
 			return $error;
1805 1805
 		} elseif ($globalDebug) echo "Done\n";
1806 1806
 		if ($globalDebug) echo "Owner Colombia: Download...";
1807
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1807
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1808 1808
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1809 1809
 			if ($globalDebug) echo "Add to DB...";
1810
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1810
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1811 1811
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1812 1812
 		if ($error != '') {
1813 1813
 			return $error;
1814 1814
 		} elseif ($globalDebug) echo "Done\n";
1815 1815
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1816
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1816
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1817 1817
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1818 1818
 			if ($globalDebug) echo "Add to DB...";
1819
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1819
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1820 1820
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1821 1821
 		if ($error != '') {
1822 1822
 			return $error;
1823 1823
 		} elseif ($globalDebug) echo "Done\n";
1824 1824
 		if ($globalDebug) echo "Owner Brazil: Download...";
1825
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1825
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1826 1826
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1827 1827
 			if ($globalDebug) echo "Add to DB...";
1828
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1828
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1829 1829
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1830 1830
 		if ($error != '') {
1831 1831
 			return $error;
1832 1832
 		} elseif ($globalDebug) echo "Done\n";
1833 1833
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1834
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1834
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1835 1835
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1836 1836
 			if ($globalDebug) echo "Add to DB...";
1837
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1837
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1838 1838
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1839 1839
 		if ($error != '') {
1840 1840
 			return $error;
1841 1841
 		} elseif ($globalDebug) echo "Done\n";
1842 1842
 		if ($globalDebug) echo "Owner Croatia: Download...";
1843
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1843
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1844 1844
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1845 1845
 			if ($globalDebug) echo "Add to DB...";
1846
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1846
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1847 1847
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1848 1848
 		if ($error != '') {
1849 1849
 			return $error;
1850 1850
 		} elseif ($globalDebug) echo "Done\n";
1851 1851
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1852
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1852
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1853 1853
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1854 1854
 			if ($globalDebug) echo "Add to DB...";
1855
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1855
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1856 1856
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1857 1857
 		if ($error != '') {
1858 1858
 			return $error;
1859 1859
 		} elseif ($globalDebug) echo "Done\n";
1860 1860
 		if ($globalDebug) echo "Owner Maldives: Download...";
1861
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1861
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1862 1862
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1863 1863
 			if ($globalDebug) echo "Add to DB...";
1864
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1864
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1865 1865
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1866 1866
 		if ($error != '') {
1867 1867
 			return $error;
1868 1868
 		} elseif ($globalDebug) echo "Done\n";
1869 1869
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1870
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1870
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1871 1871
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1872 1872
 			if ($globalDebug) echo "Add to DB...";
1873
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1873
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1874 1874
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1875 1875
 		if ($error != '') {
1876 1876
 			return $error;
1877 1877
 		} elseif ($globalDebug) echo "Done\n";
1878 1878
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1879
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1879
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1880 1880
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1881 1881
 			if ($globalDebug) echo "Add to DB...";
1882
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1882
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1883 1883
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1884 1884
 		if ($error != '') {
1885 1885
 			return $error;
1886 1886
 		} elseif ($globalDebug) echo "Done\n";
1887 1887
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1888
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1888
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1889 1889
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1890 1890
 			if ($globalDebug) echo "Add to DB...";
1891
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1891
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1892 1892
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1893 1893
 		if ($error != '') {
1894 1894
 			return $error;
1895 1895
 		} elseif ($globalDebug) echo "Done\n";
1896 1896
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1897
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1897
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1898 1898
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1899 1899
 			if ($globalDebug) echo "Add to DB...";
1900
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1900
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1901 1901
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1902 1902
 		if ($error != '') {
1903 1903
 			return $error;
1904 1904
 		} elseif ($globalDebug) echo "Done\n";
1905 1905
 		if ($globalDebug) echo "Owner Iceland: Download...";
1906
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1906
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1907 1907
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1908 1908
 			if ($globalDebug) echo "Add to DB...";
1909
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1909
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1910 1910
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1911 1911
 		if ($error != '') {
1912 1912
 			return $error;
1913 1913
 		} elseif ($globalDebug) echo "Done\n";
1914 1914
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1915
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1915
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1916 1916
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1917 1917
 			if ($globalDebug) echo "Add to DB...";
1918
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1918
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1919 1919
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1920 1920
 		if ($error != '') {
1921 1921
 			return $error;
1922 1922
 		} elseif ($globalDebug) echo "Done\n";
1923 1923
 		if ($globalMasterSource) {
1924 1924
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1925
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1925
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1926 1926
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1927 1927
 				if ($globalDebug) echo "Add to DB...";
1928
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1928
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1929 1929
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1930 1930
 			if ($error != '') {
1931 1931
 				return $error;
1932 1932
 			} elseif ($globalDebug) echo "Done\n";
1933 1933
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1934
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1934
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1935 1935
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1936 1936
 				if ($globalDebug) echo "Add to DB...";
1937
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1937
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1938 1938
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1939 1939
 			if ($error != '') {
1940 1940
 				return $error;
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
 		global $tmp_dir, $globalDebug;
1948 1948
 		$error = '';
1949 1949
 		if ($globalDebug) echo "Translation : Download...";
1950
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1950
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1951 1951
 		if (file_exists($tmp_dir.'translation.zip')) {
1952 1952
 			if ($globalDebug) echo "Unzip...";
1953 1953
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 	public static function update_translation_fam() {
1964 1964
 		global $tmp_dir, $globalDebug;
1965 1965
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1966
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1966
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1967 1967
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1968 1968
 			if ($globalDebug) echo "Gunzip...";
1969 1969
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 	public static function update_ModeS_fam() {
1979 1979
 		global $tmp_dir, $globalDebug;
1980 1980
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1981
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1981
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1982 1982
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1983 1983
 			if ($globalDebug) echo "Gunzip...";
1984 1984
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1994,9 +1994,9 @@  discard block
 block discarded – undo
1994 1994
 		global $tmp_dir, $globalDebug, $globalOwner;
1995 1995
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1996 1996
 		if ($globalOwner === TRUE) {
1997
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1997
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1998 1998
 		} else {
1999
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1999
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2000 2000
 		}
2001 2001
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2002 2002
 			if ($globalDebug) echo "Gunzip...";
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 	public static function update_routes_fam() {
2013 2013
 		global $tmp_dir, $globalDebug;
2014 2014
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2015
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2015
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2016 2016
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2017 2017
 			if ($globalDebug) echo "Gunzip...";
2018 2018
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2026,13 +2026,13 @@  discard block
 block discarded – undo
2026 2026
 	}
2027 2027
 	public static function update_marine_identity_fam() {
2028 2028
 		global $tmp_dir, $globalDebug;
2029
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2029
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2030 2030
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2031
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2031
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2032 2032
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2033 2033
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2034 2034
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2035
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2035
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2036 2036
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2037 2037
 					if ($globalDebug) echo "Gunzip...";
2038 2038
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
 	public static function update_banned_fam() {
2053 2053
 		global $tmp_dir, $globalDebug;
2054 2054
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2055
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2055
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2056 2056
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2057 2057
 			//if ($globalDebug) echo "Gunzip...";
2058 2058
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2071,18 +2071,18 @@  discard block
 block discarded – undo
2071 2071
 		$error = '';
2072 2072
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2073 2073
 		if ($globalDBdriver == 'mysql') {
2074
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2074
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2075 2075
 		} else {
2076
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2076
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2077 2077
 		}
2078 2078
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2079
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2079
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2080 2080
 			$airspace_md5 = $airspace_md5_file[0];
2081 2081
 			if (!update_db::check_airspace_version($airspace_md5)) {
2082 2082
 				if ($globalDBdriver == 'mysql') {
2083
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2083
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2084 2084
 				} else {
2085
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2085
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2086 2086
 				}
2087 2087
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2088 2088
 					if ($globalDebug) echo "Gunzip...";
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 						try {
2095 2095
 							$sth = $Connection->db->prepare($query);
2096 2096
     	    	    					$sth->execute();
2097
-			            		} catch(PDOException $e) {
2097
+			            		} catch (PDOException $e) {
2098 2098
 							return "error : ".$e->getMessage();
2099 2099
 		            			}
2100 2100
 		    			}
@@ -2113,15 +2113,15 @@  discard block
 block discarded – undo
2113 2113
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2114 2114
 		$error = '';
2115 2115
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2116
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2116
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2117 2117
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2118
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2118
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2119 2119
 			$geoid_md5 = $geoid_md5_file[0];
2120 2120
 			if (!update_db::check_geoid_version($geoid_md5)) {
2121
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2121
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2122 2122
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2123 2123
 					if ($globalDebug) echo "Gunzip...";
2124
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2124
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2125 2125
 					update_db::insert_geoid_version($geoid_md5);
2126 2126
 				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2127 2127
 			}
@@ -2135,15 +2135,15 @@  discard block
 block discarded – undo
2135 2135
 	public static function update_tle() {
2136 2136
 		global $tmp_dir, $globalDebug;
2137 2137
 		if ($globalDebug) echo "Download TLE : Download...";
2138
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2139
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2140
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2138
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2139
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2140
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2141 2141
 		foreach ($alltle as $filename) {
2142 2142
 			if ($globalDebug) echo "downloading ".$filename.'...';
2143
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2143
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2144 2144
 			if (file_exists($tmp_dir.$filename)) {
2145 2145
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2146
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2146
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2147 2147
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2148 2148
 			if ($error != '') {
2149 2149
 				echo $error."\n";
@@ -2156,32 +2156,32 @@  discard block
 block discarded – undo
2156 2156
 		global $tmp_dir, $globalDebug;
2157 2157
 		$error = '';
2158 2158
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2159
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2159
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2160 2160
 		if (file_exists($tmp_dir.'models.md5sum')) {
2161 2161
 			if ($globalDebug) echo "Check files...\n";
2162 2162
 			$newmodelsdb = array();
2163
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2164
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2163
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2164
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2165 2165
 					$model = trim($row[2]);
2166 2166
 					$newmodelsdb[$model] = trim($row[0]);
2167 2167
 				}
2168 2168
 			}
2169 2169
 			$modelsdb = array();
2170 2170
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2171
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2172
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2171
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2172
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2173 2173
 						$model = trim($row[2]);
2174 2174
 						$modelsdb[$model] = trim($row[0]);
2175 2175
 					}
2176 2176
 				}
2177 2177
 			}
2178
-			$diff = array_diff($newmodelsdb,$modelsdb);
2178
+			$diff = array_diff($newmodelsdb, $modelsdb);
2179 2179
 			foreach ($diff as $key => $value) {
2180 2180
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2181
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2181
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2182 2182
 				
2183 2183
 			}
2184
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2184
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2185 2185
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2186 2186
 		if ($error != '') {
2187 2187
 			return $error;
@@ -2193,32 +2193,32 @@  discard block
 block discarded – undo
2193 2193
 		global $tmp_dir, $globalDebug;
2194 2194
 		$error = '';
2195 2195
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2196
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2196
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2197 2197
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2198 2198
 			if ($globalDebug) echo "Check files...\n";
2199 2199
 			$newmodelsdb = array();
2200
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2201
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2200
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2201
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2202 2202
 					$model = trim($row[2]);
2203 2203
 					$newmodelsdb[$model] = trim($row[0]);
2204 2204
 				}
2205 2205
 			}
2206 2206
 			$modelsdb = array();
2207 2207
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2208
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2209
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2208
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2209
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2210 2210
 						$model = trim($row[2]);
2211 2211
 						$modelsdb[$model] = trim($row[0]);
2212 2212
 					}
2213 2213
 				}
2214 2214
 			}
2215
-			$diff = array_diff($newmodelsdb,$modelsdb);
2215
+			$diff = array_diff($newmodelsdb, $modelsdb);
2216 2216
 			foreach ($diff as $key => $value) {
2217 2217
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2218
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2218
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2219 2219
 				
2220 2220
 			}
2221
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2221
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2222 2222
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2223 2223
 		if ($error != '') {
2224 2224
 			return $error;
@@ -2230,32 +2230,32 @@  discard block
 block discarded – undo
2230 2230
 		global $tmp_dir, $globalDebug;
2231 2231
 		$error = '';
2232 2232
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2233
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2233
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2234 2234
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2235 2235
 			if ($globalDebug) echo "Check files...\n";
2236 2236
 			$newmodelsdb = array();
2237
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2238
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2237
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2238
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2239 2239
 					$model = trim($row[2]);
2240 2240
 					$newmodelsdb[$model] = trim($row[0]);
2241 2241
 				}
2242 2242
 			}
2243 2243
 			$modelsdb = array();
2244 2244
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2245
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2246
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2245
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2246
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2247 2247
 						$model = trim($row[2]);
2248 2248
 						$modelsdb[$model] = trim($row[0]);
2249 2249
 					}
2250 2250
 				}
2251 2251
 			}
2252
-			$diff = array_diff($newmodelsdb,$modelsdb);
2252
+			$diff = array_diff($newmodelsdb, $modelsdb);
2253 2253
 			foreach ($diff as $key => $value) {
2254 2254
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2255
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2255
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2256 2256
 				
2257 2257
 			}
2258
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2258
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2259 2259
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2260 2260
 		if ($error != '') {
2261 2261
 			return $error;
@@ -2278,8 +2278,8 @@  discard block
 block discarded – undo
2278 2278
 		*/
2279 2279
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2280 2280
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2281
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2282
-		    $result = fread($fh,100000000);
2281
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2282
+		    $result = fread($fh, 100000000);
2283 2283
 		    //echo $result;
2284 2284
 		    //var_dump(str_get_html($result));
2285 2285
 		    //print_r(self::table2array($result));
@@ -2297,23 +2297,23 @@  discard block
 block discarded – undo
2297 2297
 			$Connection = new Connection();
2298 2298
 			$sth = $Connection->db->prepare($query);
2299 2299
                         $sth->execute();
2300
-                } catch(PDOException $e) {
2300
+                } catch (PDOException $e) {
2301 2301
                         return "error : ".$e->getMessage();
2302 2302
                 }
2303 2303
 
2304 2304
 		$error = '';
2305 2305
 		if ($globalDebug) echo "Notam : Download...";
2306
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2306
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2307 2307
 		if (file_exists($tmp_dir.'notam.rss')) {
2308
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2308
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2309 2309
 			foreach ($notams['channel']['item'] as $notam) {
2310
-				$title = explode(':',$notam['title']);
2310
+				$title = explode(':', $notam['title']);
2311 2311
 				$data['ref'] = trim($title[0]);
2312 2312
 				unset($title[0]);
2313
-				$data['title'] = trim(implode(':',$title));
2314
-				$description = strip_tags($notam['description'],'<pre>');
2315
-				preg_match(':^(.*?)<pre>:',$description,$match);
2316
-				$q = explode('/',$match[1]);
2313
+				$data['title'] = trim(implode(':', $title));
2314
+				$description = strip_tags($notam['description'], '<pre>');
2315
+				preg_match(':^(.*?)<pre>:', $description, $match);
2316
+				$q = explode('/', $match[1]);
2317 2317
 				$data['fir'] = $q[0];
2318 2318
 				$data['code'] = $q[1];
2319 2319
 				$ifrvfr = $q[2];
@@ -2329,30 +2329,30 @@  discard block
 block discarded – undo
2329 2329
 				$data['lower_limit'] = $q[5];
2330 2330
 				$data['upper_limit'] = $q[6];
2331 2331
 				$latlonrad = $q[7];
2332
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2333
-				$latitude = $Common->convertDec($las,'latitude');
2334
-				$longitude = $Common->convertDec($lns,'longitude');
2332
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2333
+				$latitude = $Common->convertDec($las, 'latitude');
2334
+				$longitude = $Common->convertDec($lns, 'longitude');
2335 2335
 				if ($lac == 'S') $latitude = '-'.$latitude;
2336 2336
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2337 2337
 				$data['center_latitude'] = $latitude;
2338 2338
 				$data['center_longitude'] = $longitude;
2339 2339
 				$data['radius'] = intval($radius);
2340 2340
 				
2341
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2341
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2342 2342
 				$data['text'] = $match[1];
2343
-				preg_match(':</pre>(.*?)$:',$description,$match);
2343
+				preg_match(':</pre>(.*?)$:', $description, $match);
2344 2344
 				$fromto = $match[1];
2345
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2345
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2346 2346
 				$fromall = trim($match[1]);
2347
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2347
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2348 2348
 				$from = trim($match[1]);
2349
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2350
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2349
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2350
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2351 2351
 				$toall = trim($match[1]);
2352
-				if (!preg_match(':Permanent:',$toall)) {
2353
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2352
+				if (!preg_match(':Permanent:', $toall)) {
2353
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2354 2354
 					$to = trim($match[1]);
2355
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2355
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2356 2356
 					$data['permanent'] = 0;
2357 2357
 				} else {
2358 2358
 				    $data['date_end'] = NULL;
@@ -2360,7 +2360,7 @@  discard block
 block discarded – undo
2360 2360
 				}
2361 2361
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2362 2362
 				$NOTAM = new NOTAM();
2363
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2363
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2364 2364
 				unset($data);
2365 2365
 			} 
2366 2366
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2383,16 +2383,16 @@  discard block
 block discarded – undo
2383 2383
 				$Connection = new Connection();
2384 2384
 				$sth = $Connection->db->prepare($query);
2385 2385
 				$sth->execute();
2386
-			} catch(PDOException $e) {
2386
+			} catch (PDOException $e) {
2387 2387
 				return "error : ".$e->getMessage();
2388 2388
 			}
2389 2389
 		}
2390 2390
 		$Common = new Common();
2391 2391
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2392
-		$airspace_json = json_decode($airspace_lst,true);
2392
+		$airspace_json = json_decode($airspace_lst, true);
2393 2393
 		foreach ($airspace_json['records'] as $airspace) {
2394 2394
 			if ($globalDebug) echo $airspace['name']."...\n";
2395
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2395
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2396 2396
 			if (file_exists($tmp_dir.$airspace['name'])) {
2397 2397
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2398 2398
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
 				$Connection = new Connection();
2415 2415
 				$sth = $Connection->db->prepare($query);
2416 2416
 				$sth->execute(array(':new' => $new, ':old' => $old));
2417
-			} catch(PDOException $e) {
2417
+			} catch (PDOException $e) {
2418 2418
 				return "error : ".$e->getMessage();
2419 2419
 			}
2420 2420
 		}
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
 			$Connection = new Connection();
2432 2432
 			$sth = $Connection->db->prepare($query);
2433 2433
                         $sth->execute();
2434
-                } catch(PDOException $e) {
2434
+                } catch (PDOException $e) {
2435 2435
                         return "error : ".$e->getMessage();
2436 2436
                 }
2437 2437
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
 			$Connection = new Connection();
2447 2447
 			$sth = $Connection->db->prepare($query);
2448 2448
                         $sth->execute();
2449
-                } catch(PDOException $e) {
2449
+                } catch (PDOException $e) {
2450 2450
                         return "error : ".$e->getMessage();
2451 2451
                 }
2452 2452
 	}
@@ -2457,7 +2457,7 @@  discard block
 block discarded – undo
2457 2457
 			$Connection = new Connection();
2458 2458
 			$sth = $Connection->db->prepare($query);
2459 2459
                         $sth->execute(array(':version' => $version));
2460
-                } catch(PDOException $e) {
2460
+                } catch (PDOException $e) {
2461 2461
                         return "error : ".$e->getMessage();
2462 2462
                 }
2463 2463
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2471,7 +2471,7 @@  discard block
 block discarded – undo
2471 2471
 			$Connection = new Connection();
2472 2472
 			$sth = $Connection->db->prepare($query);
2473 2473
                         $sth->execute(array(':version' => $version));
2474
-                } catch(PDOException $e) {
2474
+                } catch (PDOException $e) {
2475 2475
                         return "error : ".$e->getMessage();
2476 2476
                 }
2477 2477
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
 			$Connection = new Connection();
2486 2486
 			$sth = $Connection->db->prepare($query);
2487 2487
                         $sth->execute(array(':version' => $version));
2488
-                } catch(PDOException $e) {
2488
+                } catch (PDOException $e) {
2489 2489
                         return "error : ".$e->getMessage();
2490 2490
                 }
2491 2491
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
 			$Connection = new Connection();
2502 2502
 			$sth = $Connection->db->prepare($query);
2503 2503
 			$sth->execute(array(':version' => $version));
2504
-		} catch(PDOException $e) {
2504
+		} catch (PDOException $e) {
2505 2505
 			return "error : ".$e->getMessage();
2506 2506
 		}
2507 2507
 	}
@@ -2513,7 +2513,7 @@  discard block
 block discarded – undo
2513 2513
 			$Connection = new Connection();
2514 2514
 			$sth = $Connection->db->prepare($query);
2515 2515
                         $sth->execute(array(':version' => $version));
2516
-                } catch(PDOException $e) {
2516
+                } catch (PDOException $e) {
2517 2517
                         return "error : ".$e->getMessage();
2518 2518
                 }
2519 2519
 	}
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
 			$Connection = new Connection();
2526 2526
 			$sth = $Connection->db->prepare($query);
2527 2527
                         $sth->execute(array(':version' => $version));
2528
-                } catch(PDOException $e) {
2528
+                } catch (PDOException $e) {
2529 2529
                         return "error : ".$e->getMessage();
2530 2530
                 }
2531 2531
 	}
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
 			$Connection = new Connection();
2542 2542
 			$sth = $Connection->db->prepare($query);
2543 2543
                         $sth->execute();
2544
-                } catch(PDOException $e) {
2544
+                } catch (PDOException $e) {
2545 2545
                         return "error : ".$e->getMessage();
2546 2546
                 }
2547 2547
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
 			$Connection = new Connection();
2557 2557
 			$sth = $Connection->db->prepare($query);
2558 2558
                         $sth->execute();
2559
-                } catch(PDOException $e) {
2559
+                } catch (PDOException $e) {
2560 2560
                         return "error : ".$e->getMessage();
2561 2561
                 }
2562 2562
 	}
@@ -2572,7 +2572,7 @@  discard block
 block discarded – undo
2572 2572
 			$Connection = new Connection();
2573 2573
 			$sth = $Connection->db->prepare($query);
2574 2574
                         $sth->execute();
2575
-                } catch(PDOException $e) {
2575
+                } catch (PDOException $e) {
2576 2576
                         return "error : ".$e->getMessage();
2577 2577
                 }
2578 2578
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2587,7 +2587,7 @@  discard block
 block discarded – undo
2587 2587
 			$Connection = new Connection();
2588 2588
 			$sth = $Connection->db->prepare($query);
2589 2589
                         $sth->execute();
2590
-                } catch(PDOException $e) {
2590
+                } catch (PDOException $e) {
2591 2591
                         return "error : ".$e->getMessage();
2592 2592
                 }
2593 2593
 	}
@@ -2603,7 +2603,7 @@  discard block
 block discarded – undo
2603 2603
 			$Connection = new Connection();
2604 2604
 			$sth = $Connection->db->prepare($query);
2605 2605
                         $sth->execute();
2606
-                } catch(PDOException $e) {
2606
+                } catch (PDOException $e) {
2607 2607
                         return "error : ".$e->getMessage();
2608 2608
                 }
2609 2609
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2618,7 +2618,7 @@  discard block
 block discarded – undo
2618 2618
 			$Connection = new Connection();
2619 2619
 			$sth = $Connection->db->prepare($query);
2620 2620
                         $sth->execute();
2621
-                } catch(PDOException $e) {
2621
+                } catch (PDOException $e) {
2622 2622
                         return "error : ".$e->getMessage();
2623 2623
                 }
2624 2624
 	}
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 			$Connection = new Connection();
2635 2635
 			$sth = $Connection->db->prepare($query);
2636 2636
                         $sth->execute();
2637
-                } catch(PDOException $e) {
2637
+                } catch (PDOException $e) {
2638 2638
                         return "error : ".$e->getMessage();
2639 2639
                 }
2640 2640
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2649,7 +2649,7 @@  discard block
 block discarded – undo
2649 2649
 			$Connection = new Connection();
2650 2650
 			$sth = $Connection->db->prepare($query);
2651 2651
                         $sth->execute();
2652
-                } catch(PDOException $e) {
2652
+                } catch (PDOException $e) {
2653 2653
                         return "error : ".$e->getMessage();
2654 2654
                 }
2655 2655
 	}
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
 			$Connection = new Connection();
2665 2665
 			$sth = $Connection->db->prepare($query);
2666 2666
                         $sth->execute();
2667
-                } catch(PDOException $e) {
2667
+                } catch (PDOException $e) {
2668 2668
                         return "error : ".$e->getMessage();
2669 2669
                 }
2670 2670
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
 			$Connection = new Connection();
2680 2680
 			$sth = $Connection->db->prepare($query);
2681 2681
                         $sth->execute();
2682
-                } catch(PDOException $e) {
2682
+                } catch (PDOException $e) {
2683 2683
                         return "error : ".$e->getMessage();
2684 2684
                 }
2685 2685
 	}
@@ -2694,7 +2694,7 @@  discard block
 block discarded – undo
2694 2694
 			$Connection = new Connection();
2695 2695
 			$sth = $Connection->db->prepare($query);
2696 2696
                         $sth->execute();
2697
-                } catch(PDOException $e) {
2697
+                } catch (PDOException $e) {
2698 2698
                         return "error : ".$e->getMessage();
2699 2699
                 }
2700 2700
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2709,7 +2709,7 @@  discard block
 block discarded – undo
2709 2709
 			$Connection = new Connection();
2710 2710
 			$sth = $Connection->db->prepare($query);
2711 2711
                         $sth->execute();
2712
-                } catch(PDOException $e) {
2712
+                } catch (PDOException $e) {
2713 2713
                         return "error : ".$e->getMessage();
2714 2714
                 }
2715 2715
 	}
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
 			$Connection = new Connection();
2725 2725
 			$sth = $Connection->db->prepare($query);
2726 2726
                         $sth->execute();
2727
-                } catch(PDOException $e) {
2727
+                } catch (PDOException $e) {
2728 2728
                         return "error : ".$e->getMessage();
2729 2729
                 }
2730 2730
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2739,7 +2739,7 @@  discard block
 block discarded – undo
2739 2739
 			$Connection = new Connection();
2740 2740
 			$sth = $Connection->db->prepare($query);
2741 2741
                         $sth->execute();
2742
-                } catch(PDOException $e) {
2742
+                } catch (PDOException $e) {
2743 2743
                         return "error : ".$e->getMessage();
2744 2744
                 }
2745 2745
 	}
@@ -2754,7 +2754,7 @@  discard block
 block discarded – undo
2754 2754
 			$Connection = new Connection();
2755 2755
 			$sth = $Connection->db->prepare($query);
2756 2756
                         $sth->execute();
2757
-                } catch(PDOException $e) {
2757
+                } catch (PDOException $e) {
2758 2758
                         return "error : ".$e->getMessage();
2759 2759
                 }
2760 2760
 	}
@@ -2769,7 +2769,7 @@  discard block
 block discarded – undo
2769 2769
 			$Connection = new Connection();
2770 2770
 			$sth = $Connection->db->prepare($query);
2771 2771
                         $sth->execute();
2772
-                } catch(PDOException $e) {
2772
+                } catch (PDOException $e) {
2773 2773
                         return "error : ".$e->getMessage();
2774 2774
                 }
2775 2775
 	}
Please login to merge, or discard this patch.
Braces   +956 added lines, -331 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -686,25 +777,45 @@  discard block
 block discarded – undo
686 777
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
687 778
 		$Connection = new Connection();
688 779
 		$sth_dest = $Connection->db->prepare($query_dest);
689
-		if ($globalTransaction) $Connection->db->beginTransaction();
780
+		if ($globalTransaction) {
781
+			$Connection->db->beginTransaction();
782
+		}
690 783
   
691 784
 		$i = 0;
692 785
 		while($row = sparql_fetch_array($result))
693 786
 		{
694 787
 			if ($i >= 1) {
695 788
 			//print_r($row);
696
-			if (!isset($row['iata'])) $row['iata'] = '';
697
-			if (!isset($row['icao'])) $row['icao'] = '';
698
-			if (!isset($row['type'])) $row['type'] = '';
699
-			if (!isset($row['altitude'])) $row['altitude'] = '';
789
+			if (!isset($row['iata'])) {
790
+				$row['iata'] = '';
791
+			}
792
+			if (!isset($row['icao'])) {
793
+				$row['icao'] = '';
794
+			}
795
+			if (!isset($row['type'])) {
796
+				$row['type'] = '';
797
+			}
798
+			if (!isset($row['altitude'])) {
799
+				$row['altitude'] = '';
800
+			}
700 801
 			if (isset($row['city_bis'])) {
701 802
 				$row['city'] = $row['city_bis'];
702 803
 			}
703
-			if (!isset($row['city'])) $row['city'] = '';
704
-			if (!isset($row['country'])) $row['country'] = '';
705
-			if (!isset($row['homepage'])) $row['homepage'] = '';
706
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
707
-			if (!isset($row['name'])) continue;
804
+			if (!isset($row['city'])) {
805
+				$row['city'] = '';
806
+			}
807
+			if (!isset($row['country'])) {
808
+				$row['country'] = '';
809
+			}
810
+			if (!isset($row['homepage'])) {
811
+				$row['homepage'] = '';
812
+			}
813
+			if (!isset($row['wikipedia_page'])) {
814
+				$row['wikipedia_page'] = '';
815
+			}
816
+			if (!isset($row['name'])) {
817
+				continue;
818
+			}
708 819
 			if (!isset($row['image'])) {
709 820
 				$row['image'] = '';
710 821
 				$row['image_thumb'] = '';
@@ -740,7 +851,9 @@  discard block
 block discarded – undo
740 851
 
741 852
 			$i++;
742 853
 		}
743
-		if ($globalTransaction) $Connection->db->commit();
854
+		if ($globalTransaction) {
855
+			$Connection->db->commit();
856
+		}
744 857
 		echo "Delete duplicate rows...\n";
745 858
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
746 859
 		try {
@@ -752,7 +865,9 @@  discard block
 block discarded – undo
752 865
                 }
753 866
 
754 867
 
755
-		if ($globalDebug) echo "Insert Not available Airport...\n";
868
+		if ($globalDebug) {
869
+			echo "Insert Not available Airport...\n";
870
+		}
756 871
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
757 872
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
758 873
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -779,7 +894,9 @@  discard block
 block discarded – undo
779 894
 		$delimiter = ',';
780 895
 		$out_file = $tmp_dir.'airports.csv';
781 896
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
782
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
897
+		if (!file_exists($out_file) || !is_readable($out_file)) {
898
+			return FALSE;
899
+		}
783 900
 		echo "Add data from ourairports.com...\n";
784 901
 
785 902
 		$header = NULL;
@@ -789,8 +906,9 @@  discard block
 block discarded – undo
789 906
 			//$Connection->db->beginTransaction();
790 907
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
791 908
 			{
792
-				if(!$header) $header = $row;
793
-				else {
909
+				if(!$header) {
910
+					$header = $row;
911
+				} else {
794 912
 					$data = array();
795 913
 					$data = array_combine($header, $row);
796 914
 					try {
@@ -828,7 +946,9 @@  discard block
 block discarded – undo
828 946
 		echo "Download data from another free database...\n";
829 947
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
830 948
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
831
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
949
+		if (!file_exists($out_file) || !is_readable($out_file)) {
950
+			return FALSE;
951
+		}
832 952
 		update_db::unzip($out_file);
833 953
 		$header = NULL;
834 954
 		echo "Add data from another free database...\n";
@@ -839,8 +959,9 @@  discard block
 block discarded – undo
839 959
 			//$Connection->db->beginTransaction();
840 960
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
841 961
 			{
842
-				if(!$header) $header = $row;
843
-				else {
962
+				if(!$header) {
963
+					$header = $row;
964
+				} else {
844 965
 					$data = $row;
845 966
 
846 967
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1016,7 +1137,9 @@  discard block
 block discarded – undo
1016 1137
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1017 1138
 		{
1018 1139
 			$i = 0;
1019
-			if ($globalTransaction) $Connection->db->beginTransaction();
1140
+			if ($globalTransaction) {
1141
+				$Connection->db->beginTransaction();
1142
+			}
1020 1143
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1021 1144
 			{
1022 1145
 				if ($i > 0) {
@@ -1029,7 +1152,9 @@  discard block
 block discarded – undo
1029 1152
 					}
1030 1153
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1031 1154
 					if (!empty($result_search)) {
1032
-						if ($globalDebug) echo '.';
1155
+						if ($globalDebug) {
1156
+							echo '.';
1157
+						}
1033 1158
 							//if ($globalDBdriver == 'mysql') {
1034 1159
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1035 1160
 							//} else {
@@ -1051,8 +1176,12 @@  discard block
 block discarded – undo
1051 1176
 						}
1052 1177
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1053 1178
 						if (!empty($result_search_mfr)) {
1054
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1055
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1179
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1180
+								$data[16] = $data[23];
1181
+							}
1182
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1183
+								$data[16] = $data[15];
1184
+							}
1056 1185
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1057 1186
 							try {
1058 1187
 								$sthf = $Connection->db->prepare($queryf);
@@ -1063,7 +1192,9 @@  discard block
 block discarded – undo
1063 1192
 						}
1064 1193
 					}
1065 1194
 					if (strtotime($data[29]) > time()) {
1066
-						if ($globalDebug) echo 'i';
1195
+						if ($globalDebug) {
1196
+							echo 'i';
1197
+						}
1067 1198
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1068 1199
 						try {
1069 1200
 							$sth = $Connection->db->prepare($query);
@@ -1074,13 +1205,19 @@  discard block
 block discarded – undo
1074 1205
 					}
1075 1206
 				}
1076 1207
 				if ($i % 90 == 0) {
1077
-					if ($globalTransaction) $Connection->db->commit();
1078
-					if ($globalTransaction) $Connection->db->beginTransaction();
1208
+					if ($globalTransaction) {
1209
+						$Connection->db->commit();
1210
+					}
1211
+					if ($globalTransaction) {
1212
+						$Connection->db->beginTransaction();
1213
+					}
1079 1214
 				}
1080 1215
 				$i++;
1081 1216
 			}
1082 1217
 			fclose($handle);
1083
-			if ($globalTransaction) $Connection->db->commit();
1218
+			if ($globalTransaction) {
1219
+				$Connection->db->commit();
1220
+			}
1084 1221
 		}
1085 1222
 		print_r($mfr);
1086 1223
 		return '';
@@ -1105,11 +1242,15 @@  discard block
 block discarded – undo
1105 1242
 			$i = 0;
1106 1243
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1107 1244
 			//$Connection->db->beginTransaction();
1108
-			if ($globalTransaction) $Connection->db->beginTransaction();
1245
+			if ($globalTransaction) {
1246
+				$Connection->db->beginTransaction();
1247
+			}
1109 1248
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1110 1249
 			{
1111 1250
 				if ($i > 0) {
1112
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1251
+					if ($data[1] == 'NULL') {
1252
+						$data[1] = $data[0];
1253
+					}
1113 1254
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1114 1255
 					try {
1115 1256
 						$sth = $Connection->db->prepare($query);
@@ -1121,7 +1262,9 @@  discard block
 block discarded – undo
1121 1262
 				$i++;
1122 1263
 			}
1123 1264
 			fclose($handle);
1124
-			if ($globalTransaction) $Connection->db->commit();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->commit();
1267
+			}
1125 1268
 		}
1126 1269
 		return '';
1127 1270
         }
@@ -1142,7 +1285,9 @@  discard block
 block discarded – undo
1142 1285
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1143 1286
 		{
1144 1287
 			$i = 0;
1145
-			if ($globalTransaction) $Connection->db->beginTransaction();
1288
+			if ($globalTransaction) {
1289
+				$Connection->db->beginTransaction();
1290
+			}
1146 1291
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1147 1292
 			{
1148 1293
 				if ($i > 0) {
@@ -1158,7 +1303,9 @@  discard block
 block discarded – undo
1158 1303
 				$i++;
1159 1304
 			}
1160 1305
 			fclose($handle);
1161
-			if ($globalTransaction) $Connection->db->commit();
1306
+			if ($globalTransaction) {
1307
+				$Connection->db->commit();
1308
+			}
1162 1309
 		}
1163 1310
 		return '';
1164 1311
         }
@@ -1183,7 +1330,9 @@  discard block
 block discarded – undo
1183 1330
 			$i = 0;
1184 1331
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1185 1332
 			//$Connection->db->beginTransaction();
1186
-			if ($globalTransaction) $Connection->db->beginTransaction();
1333
+			if ($globalTransaction) {
1334
+				$Connection->db->beginTransaction();
1335
+			}
1187 1336
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1188 1337
 			{
1189 1338
 				if ($i > 0) {
@@ -1198,7 +1347,9 @@  discard block
 block discarded – undo
1198 1347
 				$i++;
1199 1348
 			}
1200 1349
 			fclose($handle);
1201
-			if ($globalTransaction) $Connection->db->commit();
1350
+			if ($globalTransaction) {
1351
+				$Connection->db->commit();
1352
+			}
1202 1353
 		}
1203 1354
 		return '';
1204 1355
         }
@@ -1223,7 +1374,9 @@  discard block
 block discarded – undo
1223 1374
 			$i = 0;
1224 1375
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1225 1376
 			//$Connection->db->beginTransaction();
1226
-			if ($globalTransaction) $Connection->db->beginTransaction();
1377
+			if ($globalTransaction) {
1378
+				$Connection->db->beginTransaction();
1379
+			}
1227 1380
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1228 1381
 			{
1229 1382
 				if ($i > 0) {
@@ -1239,7 +1392,9 @@  discard block
 block discarded – undo
1239 1392
 				$i++;
1240 1393
 			}
1241 1394
 			fclose($handle);
1242
-			if ($globalTransaction) $Connection->db->commit();
1395
+			if ($globalTransaction) {
1396
+				$Connection->db->commit();
1397
+			}
1243 1398
 		}
1244 1399
 		return '';
1245 1400
         }
@@ -1258,7 +1413,9 @@  discard block
 block discarded – undo
1258 1413
 		$Connection = new Connection();
1259 1414
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1260 1415
 		{
1261
-			if ($globalTransaction) $Connection->db->beginTransaction();
1416
+			if ($globalTransaction) {
1417
+				$Connection->db->beginTransaction();
1418
+			}
1262 1419
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1263 1420
 			{
1264 1421
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1273,7 +1430,9 @@  discard block
 block discarded – undo
1273 1430
 				}
1274 1431
 			}
1275 1432
 			fclose($handle);
1276
-			if ($globalTransaction) $Connection->db->commit();
1433
+			if ($globalTransaction) {
1434
+				$Connection->db->commit();
1435
+			}
1277 1436
 		}
1278 1437
 		return '';
1279 1438
         }
@@ -1424,7 +1583,9 @@  discard block
 block discarded – undo
1424 1583
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1425 1584
 		{
1426 1585
 			$i = 0;
1427
-			if ($globalTransaction) $Connection->db->beginTransaction();
1586
+			if ($globalTransaction) {
1587
+				$Connection->db->beginTransaction();
1588
+			}
1428 1589
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1429 1590
 			{
1430 1591
 				$i++;
@@ -1452,7 +1613,9 @@  discard block
 block discarded – undo
1452 1613
 				}
1453 1614
 			}
1454 1615
 			fclose($handle);
1455
-			if ($globalTransaction) $Connection->db->commit();
1616
+			if ($globalTransaction) {
1617
+				$Connection->db->commit();
1618
+			}
1456 1619
 		}
1457 1620
 		return '';
1458 1621
         }
@@ -1475,7 +1638,9 @@  discard block
 block discarded – undo
1475 1638
 		$Connection = new Connection();
1476 1639
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1477 1640
 		{
1478
-			if ($globalTransaction) $Connection->db->beginTransaction();
1641
+			if ($globalTransaction) {
1642
+				$Connection->db->beginTransaction();
1643
+			}
1479 1644
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1480 1645
 			{
1481 1646
 				if(count($row) > 1) {
@@ -1489,7 +1654,9 @@  discard block
 block discarded – undo
1489 1654
 				}
1490 1655
 			}
1491 1656
 			fclose($handle);
1492
-			if ($globalTransaction) $Connection->db->commit();
1657
+			if ($globalTransaction) {
1658
+				$Connection->db->commit();
1659
+			}
1493 1660
 		}
1494 1661
 		return '';
1495 1662
         }
@@ -1509,8 +1676,9 @@  discard block
 block discarded – undo
1509 1676
 	        }
1510 1677
 
1511 1678
 
1512
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1513
-		else {
1679
+		if ($globalDBdriver == 'mysql') {
1680
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1681
+		} else {
1514 1682
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1515 1683
 			$query = "CREATE EXTENSION postgis";
1516 1684
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1529,20 +1697,30 @@  discard block
 block discarded – undo
1529 1697
 		global $tmp_dir, $globalDebug;
1530 1698
 		include_once('class.create_db.php');
1531 1699
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1532
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1700
+		if ($globalDebug) {
1701
+			echo "NOTAM from FlightAirMap website : Download...";
1702
+		}
1533 1703
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1534 1704
 		$error = '';
1535 1705
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1536
-			if ($globalDebug) echo "Gunzip...";
1706
+			if ($globalDebug) {
1707
+				echo "Gunzip...";
1708
+			}
1537 1709
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1538
-			if ($globalDebug) echo "Add to DB...";
1710
+			if ($globalDebug) {
1711
+				echo "Add to DB...";
1712
+			}
1539 1713
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1540 1714
 			$NOTAM = new NOTAM();
1541 1715
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1542
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1716
+		} else {
1717
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1718
+		}
1543 1719
 		if ($error != '') {
1544 1720
 			return $error;
1545
-		} elseif ($globalDebug) echo "Done\n";
1721
+		} elseif ($globalDebug) {
1722
+			echo "Done\n";
1723
+		}
1546 1724
 		return '';
1547 1725
 	}
1548 1726
 
@@ -1596,67 +1774,111 @@  discard block
 block discarded – undo
1596 1774
 		//if ($globalDebug) echo "IVAO : Download...";
1597 1775
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1598 1776
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1599
-			if ($globalDebug) echo "Unzip...";
1777
+			if ($globalDebug) {
1778
+				echo "Unzip...";
1779
+			}
1600 1780
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1601
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1602 1784
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1603
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1785
+			if ($globalDebug) {
1786
+				echo "Copy airlines logos to airlines images directory...";
1787
+			}
1604 1788
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1605
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1606
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1607
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1789
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1790
+					$error = "Failed to copy airlines logo.";
1791
+				}
1792
+			} else {
1793
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1794
+			}
1795
+		} else {
1796
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1797
+		}
1608 1798
 		if ($error != '') {
1609 1799
 			return $error;
1610
-		} elseif ($globalDebug) echo "Done\n";
1800
+		} elseif ($globalDebug) {
1801
+			echo "Done\n";
1802
+		}
1611 1803
 		return '';
1612 1804
 	}
1613 1805
 
1614 1806
 	public static function update_routes() {
1615 1807
 		global $tmp_dir, $globalDebug;
1616 1808
 		$error = '';
1617
-		if ($globalDebug) echo "Routes : Download...";
1809
+		if ($globalDebug) {
1810
+			echo "Routes : Download...";
1811
+		}
1618 1812
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1619 1813
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1620
-			if ($globalDebug) echo "Gunzip...";
1814
+			if ($globalDebug) {
1815
+				echo "Gunzip...";
1816
+			}
1621 1817
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1622
-			if ($globalDebug) echo "Add to DB...";
1818
+			if ($globalDebug) {
1819
+				echo "Add to DB...";
1820
+			}
1623 1821
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1624
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1822
+		} else {
1823
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1824
+		}
1625 1825
 		if ($error != '') {
1626 1826
 			return $error;
1627
-		} elseif ($globalDebug) echo "Done\n";
1827
+		} elseif ($globalDebug) {
1828
+			echo "Done\n";
1829
+		}
1628 1830
 		return '';
1629 1831
 	}
1630 1832
 	public static function update_oneworld() {
1631 1833
 		global $tmp_dir, $globalDebug;
1632 1834
 		$error = '';
1633
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1835
+		if ($globalDebug) {
1836
+			echo "Schedules Oneworld : Download...";
1837
+		}
1634 1838
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1635 1839
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1636
-			if ($globalDebug) echo "Gunzip...";
1840
+			if ($globalDebug) {
1841
+				echo "Gunzip...";
1842
+			}
1637 1843
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1638
-			if ($globalDebug) echo "Add to DB...";
1844
+			if ($globalDebug) {
1845
+				echo "Add to DB...";
1846
+			}
1639 1847
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1640
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1848
+		} else {
1849
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1850
+		}
1641 1851
 		if ($error != '') {
1642 1852
 			return $error;
1643
-		} elseif ($globalDebug) echo "Done\n";
1853
+		} elseif ($globalDebug) {
1854
+			echo "Done\n";
1855
+		}
1644 1856
 		return '';
1645 1857
 	}
1646 1858
 	public static function update_skyteam() {
1647 1859
 		global $tmp_dir, $globalDebug;
1648 1860
 		$error = '';
1649
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1861
+		if ($globalDebug) {
1862
+			echo "Schedules Skyteam : Download...";
1863
+		}
1650 1864
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1651 1865
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1652
-			if ($globalDebug) echo "Gunzip...";
1866
+			if ($globalDebug) {
1867
+				echo "Gunzip...";
1868
+			}
1653 1869
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1654
-			if ($globalDebug) echo "Add to DB...";
1870
+			if ($globalDebug) {
1871
+				echo "Add to DB...";
1872
+			}
1655 1873
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1656
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1874
+		} else {
1875
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1876
+		}
1657 1877
 		if ($error != '') {
1658 1878
 			return $error;
1659
-		} elseif ($globalDebug) echo "Done\n";
1879
+		} elseif ($globalDebug) {
1880
+			echo "Done\n";
1881
+		}
1660 1882
 		return '';
1661 1883
 	}
1662 1884
 	public static function update_ModeS() {
@@ -1673,355 +1895,619 @@  discard block
 block discarded – undo
1673 1895
 			exit;
1674 1896
 		} elseif ($globalDebug) echo "Done\n";
1675 1897
 */
1676
-		if ($globalDebug) echo "Modes : Download...";
1677
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1898
+		if ($globalDebug) {
1899
+			echo "Modes : Download...";
1900
+		}
1901
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1678 1902
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1679 1903
 
1680 1904
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1681 1905
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1682
-			if ($globalDebug) echo "Unzip...";
1683
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1906
+			if ($globalDebug) {
1907
+				echo "Unzip...";
1908
+			}
1909
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1684 1910
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1685
-			if ($globalDebug) echo "Add to DB...";
1911
+			if ($globalDebug) {
1912
+				echo "Add to DB...";
1913
+			}
1686 1914
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1687 1915
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1688
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1916
+		} else {
1917
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1918
+		}
1689 1919
 		if ($error != '') {
1690 1920
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
1921
+		} elseif ($globalDebug) {
1922
+			echo "Done\n";
1923
+		}
1692 1924
 		return '';
1693 1925
 	}
1694 1926
 
1695 1927
 	public static function update_ModeS_faa() {
1696 1928
 		global $tmp_dir, $globalDebug;
1697
-		if ($globalDebug) echo "Modes FAA: Download...";
1929
+		if ($globalDebug) {
1930
+			echo "Modes FAA: Download...";
1931
+		}
1698 1932
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1699 1933
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1700
-			if ($globalDebug) echo "Unzip...";
1934
+			if ($globalDebug) {
1935
+				echo "Unzip...";
1936
+			}
1701 1937
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1702
-			if ($globalDebug) echo "Add to DB...";
1938
+			if ($globalDebug) {
1939
+				echo "Add to DB...";
1940
+			}
1703 1941
 			$error = update_db::modes_faa();
1704
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1942
+		} else {
1943
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1944
+		}
1705 1945
 		if ($error != '') {
1706 1946
 			return $error;
1707
-		} elseif ($globalDebug) echo "Done\n";
1947
+		} elseif ($globalDebug) {
1948
+			echo "Done\n";
1949
+		}
1708 1950
 		return '';
1709 1951
 	}
1710 1952
 
1711 1953
 	public static function update_ModeS_flarm() {
1712 1954
 		global $tmp_dir, $globalDebug;
1713
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1955
+		if ($globalDebug) {
1956
+			echo "Modes Flarmnet: Download...";
1957
+		}
1714 1958
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1715 1959
 		if (file_exists($tmp_dir.'data.fln')) {
1716
-			if ($globalDebug) echo "Add to DB...";
1960
+			if ($globalDebug) {
1961
+				echo "Add to DB...";
1962
+			}
1717 1963
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1718
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1964
+		} else {
1965
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1966
+		}
1719 1967
 		if ($error != '') {
1720 1968
 			return $error;
1721
-		} elseif ($globalDebug) echo "Done\n";
1969
+		} elseif ($globalDebug) {
1970
+			echo "Done\n";
1971
+		}
1722 1972
 		return '';
1723 1973
 	}
1724 1974
 
1725 1975
 	public static function update_ModeS_ogn() {
1726 1976
 		global $tmp_dir, $globalDebug;
1727
-		if ($globalDebug) echo "Modes OGN: Download...";
1977
+		if ($globalDebug) {
1978
+			echo "Modes OGN: Download...";
1979
+		}
1728 1980
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1729 1981
 		if (file_exists($tmp_dir.'ogn.csv')) {
1730
-			if ($globalDebug) echo "Add to DB...";
1982
+			if ($globalDebug) {
1983
+				echo "Add to DB...";
1984
+			}
1731 1985
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1732
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1986
+		} else {
1987
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1988
+		}
1733 1989
 		if ($error != '') {
1734 1990
 			return $error;
1735
-		} elseif ($globalDebug) echo "Done\n";
1991
+		} elseif ($globalDebug) {
1992
+			echo "Done\n";
1993
+		}
1736 1994
 		return '';
1737 1995
 	}
1738 1996
 
1739 1997
 	public static function update_owner() {
1740 1998
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1741 1999
 		
1742
-		if ($globalDebug) echo "Owner France: Download...";
2000
+		if ($globalDebug) {
2001
+			echo "Owner France: Download...";
2002
+		}
1743 2003
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1744 2004
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1745
-			if ($globalDebug) echo "Add to DB...";
2005
+			if ($globalDebug) {
2006
+				echo "Add to DB...";
2007
+			}
1746 2008
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1747
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2009
+		} else {
2010
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2011
+		}
1748 2012
 		if ($error != '') {
1749 2013
 			return $error;
1750
-		} elseif ($globalDebug) echo "Done\n";
2014
+		} elseif ($globalDebug) {
2015
+			echo "Done\n";
2016
+		}
1751 2017
 		
1752
-		if ($globalDebug) echo "Owner Ireland: Download...";
2018
+		if ($globalDebug) {
2019
+			echo "Owner Ireland: Download...";
2020
+		}
1753 2021
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1754 2022
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1755
-			if ($globalDebug) echo "Add to DB...";
2023
+			if ($globalDebug) {
2024
+				echo "Add to DB...";
2025
+			}
1756 2026
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1757
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2027
+		} else {
2028
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2029
+		}
1758 2030
 		if ($error != '') {
1759 2031
 			return $error;
1760
-		} elseif ($globalDebug) echo "Done\n";
1761
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2032
+		} elseif ($globalDebug) {
2033
+			echo "Done\n";
2034
+		}
2035
+		if ($globalDebug) {
2036
+			echo "Owner Switzerland: Download...";
2037
+		}
1762 2038
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1763 2039
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1764
-			if ($globalDebug) echo "Add to DB...";
2040
+			if ($globalDebug) {
2041
+				echo "Add to DB...";
2042
+			}
1765 2043
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1766
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2044
+		} else {
2045
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2046
+		}
1767 2047
 		if ($error != '') {
1768 2048
 			return $error;
1769
-		} elseif ($globalDebug) echo "Done\n";
1770
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2049
+		} elseif ($globalDebug) {
2050
+			echo "Done\n";
2051
+		}
2052
+		if ($globalDebug) {
2053
+			echo "Owner Czech Republic: Download...";
2054
+		}
1771 2055
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1772 2056
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1773
-			if ($globalDebug) echo "Add to DB...";
2057
+			if ($globalDebug) {
2058
+				echo "Add to DB...";
2059
+			}
1774 2060
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1775
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2061
+		} else {
2062
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2063
+		}
1776 2064
 		if ($error != '') {
1777 2065
 			return $error;
1778
-		} elseif ($globalDebug) echo "Done\n";
1779
-		if ($globalDebug) echo "Owner Australia: Download...";
2066
+		} elseif ($globalDebug) {
2067
+			echo "Done\n";
2068
+		}
2069
+		if ($globalDebug) {
2070
+			echo "Owner Australia: Download...";
2071
+		}
1780 2072
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1781 2073
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1782
-			if ($globalDebug) echo "Add to DB...";
2074
+			if ($globalDebug) {
2075
+				echo "Add to DB...";
2076
+			}
1783 2077
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1784
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2078
+		} else {
2079
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2080
+		}
1785 2081
 		if ($error != '') {
1786 2082
 			return $error;
1787
-		} elseif ($globalDebug) echo "Done\n";
1788
-		if ($globalDebug) echo "Owner Austria: Download...";
2083
+		} elseif ($globalDebug) {
2084
+			echo "Done\n";
2085
+		}
2086
+		if ($globalDebug) {
2087
+			echo "Owner Austria: Download...";
2088
+		}
1789 2089
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1790 2090
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1791
-			if ($globalDebug) echo "Add to DB...";
2091
+			if ($globalDebug) {
2092
+				echo "Add to DB...";
2093
+			}
1792 2094
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1793
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2095
+		} else {
2096
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2097
+		}
1794 2098
 		if ($error != '') {
1795 2099
 			return $error;
1796
-		} elseif ($globalDebug) echo "Done\n";
1797
-		if ($globalDebug) echo "Owner Chile: Download...";
2100
+		} elseif ($globalDebug) {
2101
+			echo "Done\n";
2102
+		}
2103
+		if ($globalDebug) {
2104
+			echo "Owner Chile: Download...";
2105
+		}
1798 2106
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1799 2107
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1800
-			if ($globalDebug) echo "Add to DB...";
2108
+			if ($globalDebug) {
2109
+				echo "Add to DB...";
2110
+			}
1801 2111
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1802
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2112
+		} else {
2113
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2114
+		}
1803 2115
 		if ($error != '') {
1804 2116
 			return $error;
1805
-		} elseif ($globalDebug) echo "Done\n";
1806
-		if ($globalDebug) echo "Owner Colombia: Download...";
2117
+		} elseif ($globalDebug) {
2118
+			echo "Done\n";
2119
+		}
2120
+		if ($globalDebug) {
2121
+			echo "Owner Colombia: Download...";
2122
+		}
1807 2123
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1808 2124
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1809
-			if ($globalDebug) echo "Add to DB...";
2125
+			if ($globalDebug) {
2126
+				echo "Add to DB...";
2127
+			}
1810 2128
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1811
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2129
+		} else {
2130
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2131
+		}
1812 2132
 		if ($error != '') {
1813 2133
 			return $error;
1814
-		} elseif ($globalDebug) echo "Done\n";
1815
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2134
+		} elseif ($globalDebug) {
2135
+			echo "Done\n";
2136
+		}
2137
+		if ($globalDebug) {
2138
+			echo "Owner Bosnia Herzegobina: Download...";
2139
+		}
1816 2140
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1817 2141
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1818
-			if ($globalDebug) echo "Add to DB...";
2142
+			if ($globalDebug) {
2143
+				echo "Add to DB...";
2144
+			}
1819 2145
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1820
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2146
+		} else {
2147
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2148
+		}
1821 2149
 		if ($error != '') {
1822 2150
 			return $error;
1823
-		} elseif ($globalDebug) echo "Done\n";
1824
-		if ($globalDebug) echo "Owner Brazil: Download...";
2151
+		} elseif ($globalDebug) {
2152
+			echo "Done\n";
2153
+		}
2154
+		if ($globalDebug) {
2155
+			echo "Owner Brazil: Download...";
2156
+		}
1825 2157
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1826 2158
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1827
-			if ($globalDebug) echo "Add to DB...";
2159
+			if ($globalDebug) {
2160
+				echo "Add to DB...";
2161
+			}
1828 2162
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1829
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2163
+		} else {
2164
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2165
+		}
1830 2166
 		if ($error != '') {
1831 2167
 			return $error;
1832
-		} elseif ($globalDebug) echo "Done\n";
1833
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2168
+		} elseif ($globalDebug) {
2169
+			echo "Done\n";
2170
+		}
2171
+		if ($globalDebug) {
2172
+			echo "Owner Cayman Islands: Download...";
2173
+		}
1834 2174
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1835 2175
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1836
-			if ($globalDebug) echo "Add to DB...";
2176
+			if ($globalDebug) {
2177
+				echo "Add to DB...";
2178
+			}
1837 2179
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1838
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2180
+		} else {
2181
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2182
+		}
1839 2183
 		if ($error != '') {
1840 2184
 			return $error;
1841
-		} elseif ($globalDebug) echo "Done\n";
1842
-		if ($globalDebug) echo "Owner Croatia: Download...";
2185
+		} elseif ($globalDebug) {
2186
+			echo "Done\n";
2187
+		}
2188
+		if ($globalDebug) {
2189
+			echo "Owner Croatia: Download...";
2190
+		}
1843 2191
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1844 2192
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1845
-			if ($globalDebug) echo "Add to DB...";
2193
+			if ($globalDebug) {
2194
+				echo "Add to DB...";
2195
+			}
1846 2196
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1847
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2197
+		} else {
2198
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2199
+		}
1848 2200
 		if ($error != '') {
1849 2201
 			return $error;
1850
-		} elseif ($globalDebug) echo "Done\n";
1851
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2202
+		} elseif ($globalDebug) {
2203
+			echo "Done\n";
2204
+		}
2205
+		if ($globalDebug) {
2206
+			echo "Owner Luxembourg: Download...";
2207
+		}
1852 2208
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1853 2209
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1854
-			if ($globalDebug) echo "Add to DB...";
2210
+			if ($globalDebug) {
2211
+				echo "Add to DB...";
2212
+			}
1855 2213
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1856
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2214
+		} else {
2215
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2216
+		}
1857 2217
 		if ($error != '') {
1858 2218
 			return $error;
1859
-		} elseif ($globalDebug) echo "Done\n";
1860
-		if ($globalDebug) echo "Owner Maldives: Download...";
2219
+		} elseif ($globalDebug) {
2220
+			echo "Done\n";
2221
+		}
2222
+		if ($globalDebug) {
2223
+			echo "Owner Maldives: Download...";
2224
+		}
1861 2225
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1862 2226
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1863
-			if ($globalDebug) echo "Add to DB...";
2227
+			if ($globalDebug) {
2228
+				echo "Add to DB...";
2229
+			}
1864 2230
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1865
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2231
+		} else {
2232
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2233
+		}
1866 2234
 		if ($error != '') {
1867 2235
 			return $error;
1868
-		} elseif ($globalDebug) echo "Done\n";
1869
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2236
+		} elseif ($globalDebug) {
2237
+			echo "Done\n";
2238
+		}
2239
+		if ($globalDebug) {
2240
+			echo "Owner New Zealand: Download...";
2241
+		}
1870 2242
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1871 2243
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1872
-			if ($globalDebug) echo "Add to DB...";
2244
+			if ($globalDebug) {
2245
+				echo "Add to DB...";
2246
+			}
1873 2247
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1874
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2248
+		} else {
2249
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2250
+		}
1875 2251
 		if ($error != '') {
1876 2252
 			return $error;
1877
-		} elseif ($globalDebug) echo "Done\n";
1878
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2253
+		} elseif ($globalDebug) {
2254
+			echo "Done\n";
2255
+		}
2256
+		if ($globalDebug) {
2257
+			echo "Owner Papua New Guinea: Download...";
2258
+		}
1879 2259
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1880 2260
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1881
-			if ($globalDebug) echo "Add to DB...";
2261
+			if ($globalDebug) {
2262
+				echo "Add to DB...";
2263
+			}
1882 2264
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1883
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2265
+		} else {
2266
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2267
+		}
1884 2268
 		if ($error != '') {
1885 2269
 			return $error;
1886
-		} elseif ($globalDebug) echo "Done\n";
1887
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2270
+		} elseif ($globalDebug) {
2271
+			echo "Done\n";
2272
+		}
2273
+		if ($globalDebug) {
2274
+			echo "Owner Slovakia: Download...";
2275
+		}
1888 2276
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1889 2277
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1890
-			if ($globalDebug) echo "Add to DB...";
2278
+			if ($globalDebug) {
2279
+				echo "Add to DB...";
2280
+			}
1891 2281
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1892
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2282
+		} else {
2283
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2284
+		}
1893 2285
 		if ($error != '') {
1894 2286
 			return $error;
1895
-		} elseif ($globalDebug) echo "Done\n";
1896
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2287
+		} elseif ($globalDebug) {
2288
+			echo "Done\n";
2289
+		}
2290
+		if ($globalDebug) {
2291
+			echo "Owner Ecuador: Download...";
2292
+		}
1897 2293
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1898 2294
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1899
-			if ($globalDebug) echo "Add to DB...";
2295
+			if ($globalDebug) {
2296
+				echo "Add to DB...";
2297
+			}
1900 2298
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1901
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2299
+		} else {
2300
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2301
+		}
1902 2302
 		if ($error != '') {
1903 2303
 			return $error;
1904
-		} elseif ($globalDebug) echo "Done\n";
1905
-		if ($globalDebug) echo "Owner Iceland: Download...";
2304
+		} elseif ($globalDebug) {
2305
+			echo "Done\n";
2306
+		}
2307
+		if ($globalDebug) {
2308
+			echo "Owner Iceland: Download...";
2309
+		}
1906 2310
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1907 2311
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1908
-			if ($globalDebug) echo "Add to DB...";
2312
+			if ($globalDebug) {
2313
+				echo "Add to DB...";
2314
+			}
1909 2315
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1910
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2316
+		} else {
2317
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2318
+		}
1911 2319
 		if ($error != '') {
1912 2320
 			return $error;
1913
-		} elseif ($globalDebug) echo "Done\n";
1914
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2321
+		} elseif ($globalDebug) {
2322
+			echo "Done\n";
2323
+		}
2324
+		if ($globalDebug) {
2325
+			echo "Owner Isle of Man: Download...";
2326
+		}
1915 2327
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1916 2328
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1917
-			if ($globalDebug) echo "Add to DB...";
2329
+			if ($globalDebug) {
2330
+				echo "Add to DB...";
2331
+			}
1918 2332
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1919
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2333
+		} else {
2334
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2335
+		}
1920 2336
 		if ($error != '') {
1921 2337
 			return $error;
1922
-		} elseif ($globalDebug) echo "Done\n";
2338
+		} elseif ($globalDebug) {
2339
+			echo "Done\n";
2340
+		}
1923 2341
 		if ($globalMasterSource) {
1924
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2342
+			if ($globalDebug) {
2343
+				echo "ModeS Netherlands: Download...";
2344
+			}
1925 2345
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1926 2346
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1927
-				if ($globalDebug) echo "Add to DB...";
2347
+				if ($globalDebug) {
2348
+					echo "Add to DB...";
2349
+				}
1928 2350
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1929
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2351
+			} else {
2352
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2353
+			}
1930 2354
 			if ($error != '') {
1931 2355
 				return $error;
1932
-			} elseif ($globalDebug) echo "Done\n";
1933
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2356
+			} elseif ($globalDebug) {
2357
+				echo "Done\n";
2358
+			}
2359
+			if ($globalDebug) {
2360
+				echo "ModeS Denmark: Download...";
2361
+			}
1934 2362
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1935 2363
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1936
-				if ($globalDebug) echo "Add to DB...";
2364
+				if ($globalDebug) {
2365
+					echo "Add to DB...";
2366
+				}
1937 2367
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1938
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2368
+			} else {
2369
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2370
+			}
1939 2371
 			if ($error != '') {
1940 2372
 				return $error;
1941
-			} elseif ($globalDebug) echo "Done\n";
1942
-		} elseif ($globalDebug) echo "Done\n";
2373
+			} elseif ($globalDebug) {
2374
+				echo "Done\n";
2375
+			}
2376
+		} elseif ($globalDebug) {
2377
+			echo "Done\n";
2378
+		}
1943 2379
 		return '';
1944 2380
 	}
1945 2381
 
1946 2382
 	public static function update_translation() {
1947 2383
 		global $tmp_dir, $globalDebug;
1948 2384
 		$error = '';
1949
-		if ($globalDebug) echo "Translation : Download...";
2385
+		if ($globalDebug) {
2386
+			echo "Translation : Download...";
2387
+		}
1950 2388
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1951 2389
 		if (file_exists($tmp_dir.'translation.zip')) {
1952
-			if ($globalDebug) echo "Unzip...";
2390
+			if ($globalDebug) {
2391
+				echo "Unzip...";
2392
+			}
1953 2393
 			update_db::unzip($tmp_dir.'translation.zip');
1954
-			if ($globalDebug) echo "Add to DB...";
2394
+			if ($globalDebug) {
2395
+				echo "Add to DB...";
2396
+			}
1955 2397
 			$error = update_db::translation();
1956
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2398
+		} else {
2399
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2400
+		}
1957 2401
 		if ($error != '') {
1958 2402
 			return $error;
1959
-		} elseif ($globalDebug) echo "Done\n";
2403
+		} elseif ($globalDebug) {
2404
+			echo "Done\n";
2405
+		}
1960 2406
 		return '';
1961 2407
 	}
1962 2408
 
1963 2409
 	public static function update_translation_fam() {
1964 2410
 		global $tmp_dir, $globalDebug;
1965
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2411
+		if ($globalDebug) {
2412
+			echo "Translation from FlightAirMap website : Download...";
2413
+		}
1966 2414
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1967 2415
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1968
-			if ($globalDebug) echo "Gunzip...";
2416
+			if ($globalDebug) {
2417
+				echo "Gunzip...";
2418
+			}
1969 2419
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1970
-			if ($globalDebug) echo "Add to DB...";
2420
+			if ($globalDebug) {
2421
+				echo "Add to DB...";
2422
+			}
1971 2423
 			$error = update_db::translation_fam();
1972
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2424
+		} else {
2425
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2426
+		}
1973 2427
 		if ($error != '') {
1974 2428
 			return $error;
1975
-		} elseif ($globalDebug) echo "Done\n";
2429
+		} elseif ($globalDebug) {
2430
+			echo "Done\n";
2431
+		}
1976 2432
 		return '';
1977 2433
 	}
1978 2434
 	public static function update_ModeS_fam() {
1979 2435
 		global $tmp_dir, $globalDebug;
1980
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2436
+		if ($globalDebug) {
2437
+			echo "ModeS from FlightAirMap website : Download...";
2438
+		}
1981 2439
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1982 2440
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1983
-			if ($globalDebug) echo "Gunzip...";
2441
+			if ($globalDebug) {
2442
+				echo "Gunzip...";
2443
+			}
1984 2444
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1985
-			if ($globalDebug) echo "Add to DB...";
2445
+			if ($globalDebug) {
2446
+				echo "Add to DB...";
2447
+			}
1986 2448
 			$error = update_db::modes_fam();
1987
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2449
+		} else {
2450
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2451
+		}
1988 2452
 		if ($error != '') {
1989 2453
 			return $error;
1990
-		} elseif ($globalDebug) echo "Done\n";
2454
+		} elseif ($globalDebug) {
2455
+			echo "Done\n";
2456
+		}
1991 2457
 		return '';
1992 2458
 	}
1993 2459
 	public static function update_owner_fam() {
1994 2460
 		global $tmp_dir, $globalDebug, $globalOwner;
1995
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2461
+		if ($globalDebug) {
2462
+			echo "owner from FlightAirMap website : Download...";
2463
+		}
1996 2464
 		if ($globalOwner === TRUE) {
1997 2465
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1998 2466
 		} else {
1999 2467
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2000 2468
 		}
2001 2469
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2002
-			if ($globalDebug) echo "Gunzip...";
2470
+			if ($globalDebug) {
2471
+				echo "Gunzip...";
2472
+			}
2003 2473
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2004
-			if ($globalDebug) echo "Add to DB...";
2474
+			if ($globalDebug) {
2475
+				echo "Add to DB...";
2476
+			}
2005 2477
 			$error = update_db::owner_fam();
2006
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2478
+		} else {
2479
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2480
+		}
2007 2481
 		if ($error != '') {
2008 2482
 			return $error;
2009
-		} elseif ($globalDebug) echo "Done\n";
2483
+		} elseif ($globalDebug) {
2484
+			echo "Done\n";
2485
+		}
2010 2486
 		return '';
2011 2487
 	}
2012 2488
 	public static function update_routes_fam() {
2013 2489
 		global $tmp_dir, $globalDebug;
2014
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2490
+		if ($globalDebug) {
2491
+			echo "Routes from FlightAirMap website : Download...";
2492
+		}
2015 2493
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2016 2494
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2017
-			if ($globalDebug) echo "Gunzip...";
2495
+			if ($globalDebug) {
2496
+				echo "Gunzip...";
2497
+			}
2018 2498
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2019
-			if ($globalDebug) echo "Add to DB...";
2499
+			if ($globalDebug) {
2500
+				echo "Add to DB...";
2501
+			}
2020 2502
 			$error = update_db::routes_fam();
2021
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2503
+		} else {
2504
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2505
+		}
2022 2506
 		if ($error != '') {
2023 2507
 			return $error;
2024
-		} elseif ($globalDebug) echo "Done\n";
2508
+		} elseif ($globalDebug) {
2509
+			echo "Done\n";
2510
+		}
2025 2511
 		return '';
2026 2512
 	}
2027 2513
 	public static function update_marine_identity_fam() {
@@ -2031,14 +2517,22 @@  discard block
 block discarded – undo
2031 2517
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2032 2518
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2033 2519
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2034
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2520
+				if ($globalDebug) {
2521
+					echo "Marine identity from FlightAirMap website : Download...";
2522
+				}
2035 2523
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2036 2524
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2037
-					if ($globalDebug) echo "Gunzip...";
2525
+					if ($globalDebug) {
2526
+						echo "Gunzip...";
2527
+					}
2038 2528
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2039
-					if ($globalDebug) echo "Add to DB...";
2529
+					if ($globalDebug) {
2530
+						echo "Add to DB...";
2531
+					}
2040 2532
 					$error = update_db::marine_identity_fam();
2041
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2533
+				} else {
2534
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2535
+				}
2042 2536
 				if ($error != '') {
2043 2537
 					return $error;
2044 2538
 				} elseif ($globalDebug) {
@@ -2051,17 +2545,25 @@  discard block
 block discarded – undo
2051 2545
 	}
2052 2546
 	public static function update_banned_fam() {
2053 2547
 		global $tmp_dir, $globalDebug;
2054
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2548
+		if ($globalDebug) {
2549
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2550
+		}
2055 2551
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2056 2552
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2057 2553
 			//if ($globalDebug) echo "Gunzip...";
2058 2554
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2059
-			if ($globalDebug) echo "Add to DB...";
2555
+			if ($globalDebug) {
2556
+				echo "Add to DB...";
2557
+			}
2060 2558
 			$error = update_db::banned_fam();
2061
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2559
+		} else {
2560
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2561
+		}
2062 2562
 		if ($error != '') {
2063 2563
 			return $error;
2064
-		} elseif ($globalDebug) echo "Done\n";
2564
+		} elseif ($globalDebug) {
2565
+			echo "Done\n";
2566
+		}
2065 2567
 		return '';
2066 2568
 	}
2067 2569
 
@@ -2069,7 +2571,9 @@  discard block
 block discarded – undo
2069 2571
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2070 2572
 		include_once('class.create_db.php');
2071 2573
 		$error = '';
2072
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2574
+		if ($globalDebug) {
2575
+			echo "Airspace from FlightAirMap website : Download...";
2576
+		}
2073 2577
 		if ($globalDBdriver == 'mysql') {
2074 2578
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2075 2579
 		} else {
@@ -2085,9 +2589,13 @@  discard block
 block discarded – undo
2085 2589
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2086 2590
 				}
2087 2591
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2088
-					if ($globalDebug) echo "Gunzip...";
2592
+					if ($globalDebug) {
2593
+						echo "Gunzip...";
2594
+					}
2089 2595
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2090
-					if ($globalDebug) echo "Add to DB...";
2596
+					if ($globalDebug) {
2597
+						echo "Add to DB...";
2598
+					}
2091 2599
 					$Connection = new Connection();
2092 2600
 					if ($Connection->tableExists('airspace')) {
2093 2601
 						$query = 'DROP TABLE airspace';
@@ -2100,19 +2608,27 @@  discard block
 block discarded – undo
2100 2608
 		    			}
2101 2609
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2102 2610
 					update_db::insert_airspace_version($airspace_md5);
2103
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2611
+				} else {
2612
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2613
+				}
2104 2614
 			}
2105
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2615
+		} else {
2616
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2617
+		}
2106 2618
 		if ($error != '') {
2107 2619
 			return $error;
2108
-		} elseif ($globalDebug) echo "Done\n";
2620
+		} elseif ($globalDebug) {
2621
+			echo "Done\n";
2622
+		}
2109 2623
 		return '';
2110 2624
 	}
2111 2625
 
2112 2626
 	public static function update_geoid_fam() {
2113 2627
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2114 2628
 		$error = '';
2115
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2629
+		if ($globalDebug) {
2630
+			echo "Geoid from FlightAirMap website : Download...";
2631
+		}
2116 2632
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2117 2633
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2118 2634
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2120,34 +2636,52 @@  discard block
 block discarded – undo
2120 2636
 			if (!update_db::check_geoid_version($geoid_md5)) {
2121 2637
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2122 2638
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2123
-					if ($globalDebug) echo "Gunzip...";
2639
+					if ($globalDebug) {
2640
+						echo "Gunzip...";
2641
+					}
2124 2642
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2125 2643
 					update_db::insert_geoid_version($geoid_md5);
2126
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2644
+				} else {
2645
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2646
+				}
2127 2647
 			}
2128
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2648
+		} else {
2649
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2650
+		}
2129 2651
 		if ($error != '') {
2130 2652
 			return $error;
2131
-		} elseif ($globalDebug) echo "Done\n";
2653
+		} elseif ($globalDebug) {
2654
+			echo "Done\n";
2655
+		}
2132 2656
 		return '';
2133 2657
 	}
2134 2658
 
2135 2659
 	public static function update_tle() {
2136 2660
 		global $tmp_dir, $globalDebug;
2137
-		if ($globalDebug) echo "Download TLE : Download...";
2661
+		if ($globalDebug) {
2662
+			echo "Download TLE : Download...";
2663
+		}
2138 2664
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2139 2665
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2140 2666
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2141 2667
 		foreach ($alltle as $filename) {
2142
-			if ($globalDebug) echo "downloading ".$filename.'...';
2668
+			if ($globalDebug) {
2669
+				echo "downloading ".$filename.'...';
2670
+			}
2143 2671
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2144 2672
 			if (file_exists($tmp_dir.$filename)) {
2145
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2673
+				if ($globalDebug) {
2674
+					echo "Add to DB ".$filename."...";
2675
+				}
2146 2676
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2147
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2677
+			} else {
2678
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2679
+			}
2148 2680
 			if ($error != '') {
2149 2681
 				echo $error."\n";
2150
-			} elseif ($globalDebug) echo "Done\n";
2682
+			} elseif ($globalDebug) {
2683
+				echo "Done\n";
2684
+			}
2151 2685
 		}
2152 2686
 		return '';
2153 2687
 	}
@@ -2155,10 +2689,14 @@  discard block
 block discarded – undo
2155 2689
 	public static function update_models() {
2156 2690
 		global $tmp_dir, $globalDebug;
2157 2691
 		$error = '';
2158
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2692
+		if ($globalDebug) {
2693
+			echo "Models from FlightAirMap website : Download...";
2694
+		}
2159 2695
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2160 2696
 		if (file_exists($tmp_dir.'models.md5sum')) {
2161
-			if ($globalDebug) echo "Check files...\n";
2697
+			if ($globalDebug) {
2698
+				echo "Check files...\n";
2699
+			}
2162 2700
 			$newmodelsdb = array();
2163 2701
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2164 2702
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2177,25 +2715,35 @@  discard block
 block discarded – undo
2177 2715
 			}
2178 2716
 			$diff = array_diff($newmodelsdb,$modelsdb);
2179 2717
 			foreach ($diff as $key => $value) {
2180
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2718
+				if ($globalDebug) {
2719
+					echo 'Downloading model '.$key.' ...'."\n";
2720
+				}
2181 2721
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2182 2722
 				
2183 2723
 			}
2184 2724
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2185
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2725
+		} else {
2726
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2727
+		}
2186 2728
 		if ($error != '') {
2187 2729
 			return $error;
2188
-		} elseif ($globalDebug) echo "Done\n";
2730
+		} elseif ($globalDebug) {
2731
+			echo "Done\n";
2732
+		}
2189 2733
 		return '';
2190 2734
 	}
2191 2735
 
2192 2736
 	public static function update_space_models() {
2193 2737
 		global $tmp_dir, $globalDebug;
2194 2738
 		$error = '';
2195
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2739
+		if ($globalDebug) {
2740
+			echo "Space models from FlightAirMap website : Download...";
2741
+		}
2196 2742
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2197 2743
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2198
-			if ($globalDebug) echo "Check files...\n";
2744
+			if ($globalDebug) {
2745
+				echo "Check files...\n";
2746
+			}
2199 2747
 			$newmodelsdb = array();
2200 2748
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2201 2749
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2214,25 +2762,35 @@  discard block
 block discarded – undo
2214 2762
 			}
2215 2763
 			$diff = array_diff($newmodelsdb,$modelsdb);
2216 2764
 			foreach ($diff as $key => $value) {
2217
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2765
+				if ($globalDebug) {
2766
+					echo 'Downloading space model '.$key.' ...'."\n";
2767
+				}
2218 2768
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2219 2769
 				
2220 2770
 			}
2221 2771
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2222
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2772
+		} else {
2773
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2774
+		}
2223 2775
 		if ($error != '') {
2224 2776
 			return $error;
2225
-		} elseif ($globalDebug) echo "Done\n";
2777
+		} elseif ($globalDebug) {
2778
+			echo "Done\n";
2779
+		}
2226 2780
 		return '';
2227 2781
 	}
2228 2782
 
2229 2783
 	public static function update_vehicules_models() {
2230 2784
 		global $tmp_dir, $globalDebug;
2231 2785
 		$error = '';
2232
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2786
+		if ($globalDebug) {
2787
+			echo "Vehicules models from FlightAirMap website : Download...";
2788
+		}
2233 2789
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2234 2790
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2235
-			if ($globalDebug) echo "Check files...\n";
2791
+			if ($globalDebug) {
2792
+				echo "Check files...\n";
2793
+			}
2236 2794
 			$newmodelsdb = array();
2237 2795
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2238 2796
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2251,15 +2809,21 @@  discard block
 block discarded – undo
2251 2809
 			}
2252 2810
 			$diff = array_diff($newmodelsdb,$modelsdb);
2253 2811
 			foreach ($diff as $key => $value) {
2254
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2812
+				if ($globalDebug) {
2813
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2814
+				}
2255 2815
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2256 2816
 				
2257 2817
 			}
2258 2818
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2259
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2819
+		} else {
2820
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2821
+		}
2260 2822
 		if ($error != '') {
2261 2823
 			return $error;
2262
-		} elseif ($globalDebug) echo "Done\n";
2824
+		} elseif ($globalDebug) {
2825
+			echo "Done\n";
2826
+		}
2263 2827
 		return '';
2264 2828
 	}
2265 2829
 
@@ -2302,7 +2866,9 @@  discard block
 block discarded – undo
2302 2866
                 }
2303 2867
 
2304 2868
 		$error = '';
2305
-		if ($globalDebug) echo "Notam : Download...";
2869
+		if ($globalDebug) {
2870
+			echo "Notam : Download...";
2871
+		}
2306 2872
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2307 2873
 		if (file_exists($tmp_dir.'notam.rss')) {
2308 2874
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2317,14 +2883,30 @@  discard block
 block discarded – undo
2317 2883
 				$data['fir'] = $q[0];
2318 2884
 				$data['code'] = $q[1];
2319 2885
 				$ifrvfr = $q[2];
2320
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2321
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2322
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2323
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2324
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2325
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2326
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2327
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2886
+				if ($ifrvfr == 'IV') {
2887
+					$data['rules'] = 'IFR/VFR';
2888
+				}
2889
+				if ($ifrvfr == 'I') {
2890
+					$data['rules'] = 'IFR';
2891
+				}
2892
+				if ($ifrvfr == 'V') {
2893
+					$data['rules'] = 'VFR';
2894
+				}
2895
+				if ($q[4] == 'A') {
2896
+					$data['scope'] = 'Airport warning';
2897
+				}
2898
+				if ($q[4] == 'E') {
2899
+					$data['scope'] = 'Enroute warning';
2900
+				}
2901
+				if ($q[4] == 'W') {
2902
+					$data['scope'] = 'Navigation warning';
2903
+				}
2904
+				if ($q[4] == 'AE') {
2905
+					$data['scope'] = 'Airport/Enroute warning';
2906
+				}
2907
+				if ($q[4] == 'AW') {
2908
+					$data['scope'] = 'Airport/Navigation warning';
2909
+				}
2328 2910
 				//$data['scope'] = $q[4];
2329 2911
 				$data['lower_limit'] = $q[5];
2330 2912
 				$data['upper_limit'] = $q[6];
@@ -2332,8 +2914,12 @@  discard block
 block discarded – undo
2332 2914
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2333 2915
 				$latitude = $Common->convertDec($las,'latitude');
2334 2916
 				$longitude = $Common->convertDec($lns,'longitude');
2335
-				if ($lac == 'S') $latitude = '-'.$latitude;
2336
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2917
+				if ($lac == 'S') {
2918
+					$latitude = '-'.$latitude;
2919
+				}
2920
+				if ($lnc == 'W') {
2921
+					$longitude = '-'.$longitude;
2922
+				}
2337 2923
 				$data['center_latitude'] = $latitude;
2338 2924
 				$data['center_longitude'] = $longitude;
2339 2925
 				$data['radius'] = intval($radius);
@@ -2363,10 +2949,14 @@  discard block
 block discarded – undo
2363 2949
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2364 2950
 				unset($data);
2365 2951
 			} 
2366
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2952
+		} else {
2953
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2954
+		}
2367 2955
 		if ($error != '') {
2368 2956
 			return $error;
2369
-		} elseif ($globalDebug) echo "Done\n";
2957
+		} elseif ($globalDebug) {
2958
+			echo "Done\n";
2959
+		}
2370 2960
 		return '';
2371 2961
 	}
2372 2962
 	
@@ -2391,7 +2981,9 @@  discard block
 block discarded – undo
2391 2981
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2392 2982
 		$airspace_json = json_decode($airspace_lst,true);
2393 2983
 		foreach ($airspace_json['records'] as $airspace) {
2394
-			if ($globalDebug) echo $airspace['name']."...\n";
2984
+			if ($globalDebug) {
2985
+				echo $airspace['name']."...\n";
2986
+			}
2395 2987
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2396 2988
 			if (file_exists($tmp_dir.$airspace['name'])) {
2397 2989
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2435,8 +3027,11 @@  discard block
 block discarded – undo
2435 3027
                         return "error : ".$e->getMessage();
2436 3028
                 }
2437 3029
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2438
-                if ($row['nb'] > 0) return false;
2439
-                else return true;
3030
+                if ($row['nb'] > 0) {
3031
+                	return false;
3032
+                } else {
3033
+                	return true;
3034
+                }
2440 3035
 	}
2441 3036
 
2442 3037
 	public static function insert_last_update() {
@@ -2461,8 +3056,11 @@  discard block
 block discarded – undo
2461 3056
                         return "error : ".$e->getMessage();
2462 3057
                 }
2463 3058
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2464
-                if ($row['nb'] > 0) return true;
2465
-                else return false;
3059
+                if ($row['nb'] > 0) {
3060
+                	return true;
3061
+                } else {
3062
+                	return false;
3063
+                }
2466 3064
 	}
2467 3065
 
2468 3066
 	public static function check_geoid_version($version) {
@@ -2475,8 +3073,11 @@  discard block
 block discarded – undo
2475 3073
                         return "error : ".$e->getMessage();
2476 3074
                 }
2477 3075
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2478
-                if ($row['nb'] > 0) return true;
2479
-                else return false;
3076
+                if ($row['nb'] > 0) {
3077
+                	return true;
3078
+                } else {
3079
+                	return false;
3080
+                }
2480 3081
 	}
2481 3082
 
2482 3083
 	public static function check_marine_identity_version($version) {
@@ -2489,8 +3090,11 @@  discard block
 block discarded – undo
2489 3090
                         return "error : ".$e->getMessage();
2490 3091
                 }
2491 3092
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2492
-                if ($row['nb'] > 0) return true;
2493
-                else return false;
3093
+                if ($row['nb'] > 0) {
3094
+                	return true;
3095
+                } else {
3096
+                	return false;
3097
+                }
2494 3098
 	}
2495 3099
 
2496 3100
 
@@ -2545,8 +3149,11 @@  discard block
 block discarded – undo
2545 3149
                         return "error : ".$e->getMessage();
2546 3150
                 }
2547 3151
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2548
-                if ($row['nb'] > 0) return false;
2549
-                else return true;
3152
+                if ($row['nb'] > 0) {
3153
+                	return false;
3154
+                } else {
3155
+                	return true;
3156
+                }
2550 3157
 	}
2551 3158
 
2552 3159
 	public static function insert_last_notam_update() {
@@ -2576,8 +3183,11 @@  discard block
 block discarded – undo
2576 3183
                         return "error : ".$e->getMessage();
2577 3184
                 }
2578 3185
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2579
-                if ($row['nb'] > 0) return false;
2580
-                else return true;
3186
+                if ($row['nb'] > 0) {
3187
+                	return false;
3188
+                } else {
3189
+                	return true;
3190
+                }
2581 3191
 	}
2582 3192
 
2583 3193
 	public static function insert_last_airspace_update() {
@@ -2607,8 +3217,11 @@  discard block
 block discarded – undo
2607 3217
                         return "error : ".$e->getMessage();
2608 3218
                 }
2609 3219
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2610
-                if ($row['nb'] > 0) return false;
2611
-                else return true;
3220
+                if ($row['nb'] > 0) {
3221
+                	return false;
3222
+                } else {
3223
+                	return true;
3224
+                }
2612 3225
 	}
2613 3226
 
2614 3227
 	public static function insert_last_geoid_update() {
@@ -2638,8 +3251,11 @@  discard block
 block discarded – undo
2638 3251
                         return "error : ".$e->getMessage();
2639 3252
                 }
2640 3253
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2641
-                if ($row['nb'] > 0) return false;
2642
-                else return true;
3254
+                if ($row['nb'] > 0) {
3255
+                	return false;
3256
+                } else {
3257
+                	return true;
3258
+                }
2643 3259
 	}
2644 3260
 
2645 3261
 	public static function insert_last_owner_update() {
@@ -2668,8 +3284,11 @@  discard block
 block discarded – undo
2668 3284
                         return "error : ".$e->getMessage();
2669 3285
                 }
2670 3286
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2671
-                if ($row['nb'] > 0) return false;
2672
-                else return true;
3287
+                if ($row['nb'] > 0) {
3288
+                	return false;
3289
+                } else {
3290
+                	return true;
3291
+                }
2673 3292
 	}
2674 3293
 
2675 3294
 	public static function insert_last_schedules_update() {
@@ -2698,8 +3317,11 @@  discard block
 block discarded – undo
2698 3317
                         return "error : ".$e->getMessage();
2699 3318
                 }
2700 3319
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2701
-                if ($row['nb'] > 0) return false;
2702
-                else return true;
3320
+                if ($row['nb'] > 0) {
3321
+                	return false;
3322
+                } else {
3323
+                	return true;
3324
+                }
2703 3325
 	}
2704 3326
 
2705 3327
 	public static function insert_last_tle_update() {
@@ -2728,8 +3350,11 @@  discard block
 block discarded – undo
2728 3350
                         return "error : ".$e->getMessage();
2729 3351
                 }
2730 3352
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2731
-                if ($row['nb'] > 0) return false;
2732
-                else return true;
3353
+                if ($row['nb'] > 0) {
3354
+                	return false;
3355
+                } else {
3356
+                	return true;
3357
+                }
2733 3358
 	}
2734 3359
 
2735 3360
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.Elevation.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 	private $openedFiles = [];
29 29
 
30 30
 	public function __construct($htgFilesDestination = '', $resolution = 3) {
31
-		if ($htgFilesDestination == '') $htgFilesDestination = dirname(__FILE__).'/../data/';
31
+		if ($htgFilesDestination == '') {
32
+			$htgFilesDestination = dirname(__FILE__).'/../data/';
33
+		}
32 34
 		$this->htgFilesDestination = $htgFilesDestination;
33 35
 		$this->resolution          = $resolution;
34 36
 		switch ($resolution) {
@@ -171,16 +173,26 @@  discard block
 block discarded – undo
171 173
 		$fileName  = "N{$N}E{$E}.hgt";
172 174
 		if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
173 175
 			$Common = new Common();
174
-			if ($debug) echo 'Downloading '.$fileName.'.gz ...';
176
+			if ($debug) {
177
+				echo 'Downloading '.$fileName.'.gz ...';
178
+			}
175 179
 			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
176 180
 			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) {
177
-				if ($debug) echo "File '{$fileName}.gz' not exists.";
181
+				if ($debug) {
182
+					echo "File '{$fileName}.gz' not exists.";
183
+				}
178 184
 				return false;
179 185
 			}
180
-			if ($debug) echo 'Done'."\n";
181
-			if ($debug) echo 'Decompress '.$fileName.' ....';
186
+			if ($debug) {
187
+				echo 'Done'."\n";
188
+			}
189
+			if ($debug) {
190
+				echo 'Decompress '.$fileName.' ....';
191
+			}
182 192
 			$Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName);
183
-			if ($debug) echo 'Done'."\n";
193
+			if ($debug) {
194
+				echo 'Done'."\n";
195
+			}
184 196
 			unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
185 197
 		}
186 198
 		return true;
Please login to merge, or discard this patch.