Completed
Push — master ( 5864c2...fda5ba )
by Yannick
12:30 queued 04:30
created
require/class.TrackerImport.php 3 patches
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,73 +197,73 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
221
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
222
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
221
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
222
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
223 223
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
224 224
 		    }
225 225
 		}
226 226
 		if (isset($line['last_update']) && $line['last_update'] != '') {
227 227
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
228
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
229 229
 		}
230 230
 		if (isset($line['format_source']) && $line['format_source'] != '') {
231
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
231
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
232 232
 		}
233 233
 		if (isset($line['source_name']) && $line['source_name'] != '') {
234
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
234
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
235 235
 		}
236 236
 		if (isset($line['comment']) && $line['comment'] != '') {
237
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
237
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
238 238
 		    //$dataFound = true;
239 239
 		}
240 240
 		if (isset($line['type']) && $line['type'] != '') {
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
241
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
242 242
 		    //$dataFound = true;
243 243
 		}
244 244
 
245 245
 		if (isset($line['altitude']) && $line['altitude'] != '') {
246 246
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
247
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
248
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
249
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
247
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
248
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100)));
249
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
250 250
 			//$dataFound = true;
251 251
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
252 252
   		}
253 253
 
254 254
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
255
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
255
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
256 256
 		}
257 257
 		
258 258
 		if (isset($line['heading']) && $line['heading'] != '') {
259
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
261
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
259
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
261
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
262 262
 		    //$dataFound = true;
263 263
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
264
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
266
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
264
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
266
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
267 267
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
268 268
   		}
269 269
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -271,54 +271,54 @@  discard block
 block discarded – undo
271 271
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
272 272
 		    $this->all_tracked[$id]['lastupdate'] = time();
273 273
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
274
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
274
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275 275
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
276 276
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
277 277
 				$timeelapsed = microtime(true);
278 278
 				$TrackerLive = new TrackerLive($this->db);
279 279
 				if (isset($line['id'])) {
280 280
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
281
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
282 282
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
283 283
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
284
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
285 285
 				} else $recent_ident = '';
286
-				$TrackerLive->db=null;
286
+				$TrackerLive->db = null;
287 287
 
288 288
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
289 289
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
290 290
 			    } else {
291 291
 				$recent_ident = '';
292
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
292
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
293 293
 			    }
294 294
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
295
-			    if($recent_ident == "")
295
+			    if ($recent_ident == "")
296 296
 			    {
297 297
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
298 298
 				//adds the spotter data for the archive
299 299
 				    $highlight = '';
300
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
300
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
301 301
 				    $timeelapsed = microtime(true);
302 302
 				    $Tracker = new Tracker($this->db);
303
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
303
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
304 304
 				    $Tracker->db = null;
305 305
 				    if ($globalDebug && isset($result)) echo $result."\n";
306
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
306
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
307 307
 				    
308 308
 				    
309 309
 				    // Add source stat in DB
310 310
 				    $Stats = new Stats($this->db);
311 311
 				    if (!empty($this->stats)) {
312 312
 					if ($globalDebug) echo 'Add source stats : ';
313
-				        foreach($this->stats as $date => $data) {
314
-					    foreach($data as $source => $sourced) {
313
+				        foreach ($this->stats as $date => $data) {
314
+					    foreach ($data as $source => $sourced) {
315 315
 					        //print_r($sourced);
316
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
317
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
316
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
317
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
318 318
 				    		if (isset($sourced['msg'])) {
319 319
 				    		    if (time() - $sourced['msg']['date'] > 10) {
320 320
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
321
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
321
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
322 322
 			    			        unset($this->stats[$date][$source]['msg']);
323 323
 			    			    }
324 324
 			    			}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
342 342
 				    $TrackerLive = new TrackerLive($this->db);
343 343
 				    $TrackerLive->deleteLiveTrackerData();
344
-				    $TrackerLive->db=null;
344
+				    $TrackerLive->db = null;
345 345
 				    if ($globalDebug) echo " Done\n";
346 346
 				    $this->last_delete = time();
347 347
 				}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 				$this->all_tracked[$id]['addedTracker'] = 1;
351 351
 				if (isset($globalDaemon) && !$globalDaemon) {
352 352
 					$Tracker = new Tracker($this->db);
353
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
353
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
354 354
 					$Tracker->db = null;
355 355
 				}
356 356
 				
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
 		    $ignoreImport = false;
365 365
 
366 366
 		    if (!$ignoreImport) {
367
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
367
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
368 368
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
369 369
 				$timeelapsed = microtime(true);
370 370
 				$TrackerLive = new TrackerLive($this->db);
371
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
371
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
372 372
 				$TrackerLive->db = null;
373 373
 				$this->all_tracked[$id]['putinarchive'] = false;
374
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
375 375
 
376 376
 				// Put statistics in $this->stats variable
377 377
 				
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 							$latitude = $globalCenterLatitude;
389 389
 							$longitude = $globalCenterLongitude;
390 390
 						}
391
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
391
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
392 392
 					} else {
393 393
 						$latitude = $this->source_location[$source]['latitude'];
394 394
 						$longitude = $this->source_location[$source]['longitude'];
395 395
 					}
396
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
396
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
397 397
 					//$stats_heading = $stats_heading%22.5;
398 398
 					$stats_heading = round($stats_heading/22.5);
399
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
399
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
400 400
 					$current_date = date('Y-m-d');
401 401
 					if ($stats_heading == 16) $stats_heading = 0;
402 402
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
403
-						for ($i=0;$i<=15;$i++) {
403
+						for ($i = 0; $i <= 15; $i++) {
404 404
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
405 405
 						}
406 406
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
416 416
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
417 417
 						    end($this->stats[$current_date][$source]['hist']);
418
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
418
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
419 419
 						} else $mini = 0;
420
-						for ($i=$mini;$i<=$distance;$i+=10) {
420
+						for ($i = $mini; $i <= $distance; $i += 10) {
421 421
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
422 422
 						}
423 423
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				$this->all_tracked[$id]['lastupdate'] = time();
430 430
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431 431
 				if ($globalDebug) echo $result."\n";
432
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
432
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
433 433
 			//$this->del();
434 434
 			
435 435
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -224,7 +286,9 @@  discard block
 block discarded – undo
224 286
 		    }
225 287
 		}
226 288
 		if (isset($line['last_update']) && $line['last_update'] != '') {
227
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
289
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
290
+		    	$dataFound = true;
291
+		    }
228 292
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229 293
 		}
230 294
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -244,7 +308,9 @@  discard block
 block discarded – undo
244 308
 
245 309
 		if (isset($line['altitude']) && $line['altitude'] != '') {
246 310
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
247
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
311
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
312
+				$this->all_tracked[$id]['putinarchive'] = true;
313
+			}
248 314
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
249 315
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
250 316
 			//$dataFound = true;
@@ -256,15 +322,21 @@  discard block
 block discarded – undo
256 322
 		}
257 323
 		
258 324
 		if (isset($line['heading']) && $line['heading'] != '') {
259
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
325
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
326
+		    	$this->all_tracked[$id]['putinarchive'] = true;
327
+		    }
260 328
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
261 329
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
262 330
 		    //$dataFound = true;
263 331
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
264 332
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
265 333
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
266
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
267
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
334
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
335
+		    	$this->all_tracked[$id]['putinarchive'] = true;
336
+		    }
337
+  		    if ($globalDebug) {
338
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
339
+  		    }
268 340
   		}
269 341
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
270 342
 
@@ -273,20 +345,31 @@  discard block
 block discarded – undo
273 345
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
274 346
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275 347
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
276
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
348
+				if ($globalDebug) {
349
+					echo "Check if aircraft is already in DB...";
350
+				}
277 351
 				$timeelapsed = microtime(true);
278 352
 				$TrackerLive = new TrackerLive($this->db);
279 353
 				if (isset($line['id'])) {
280 354
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
281
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
355
+				    if ($globalDebugTimeElapsed) {
356
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    }
282 358
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
283 359
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
284
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
-				} else $recent_ident = '';
360
+				    if ($globalDebugTimeElapsed) {
361
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
362
+				    }
363
+				} else {
364
+					$recent_ident = '';
365
+				}
286 366
 				$TrackerLive->db=null;
287 367
 
288
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
289
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
368
+				if ($globalDebug && $recent_ident == '') {
369
+					echo " Not in DB.\n";
370
+				} elseif ($globalDebug && $recent_ident != '') {
371
+					echo " Already in DB.\n";
372
+				}
290 373
 			    } else {
291 374
 				$recent_ident = '';
292 375
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -294,27 +377,41 @@  discard block
 block discarded – undo
294 377
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
295 378
 			    if($recent_ident == "")
296 379
 			    {
297
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
380
+				if ($globalDebug) {
381
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				}
298 383
 				//adds the spotter data for the archive
299 384
 				    $highlight = '';
300
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
385
+				    if (!isset($this->all_tracked[$id]['id'])) {
386
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    }
301 388
 				    $timeelapsed = microtime(true);
302 389
 				    $Tracker = new Tracker($this->db);
303 390
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
304 391
 				    $Tracker->db = null;
305
-				    if ($globalDebug && isset($result)) echo $result."\n";
306
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
392
+				    if ($globalDebug && isset($result)) {
393
+				    	echo $result."\n";
394
+				    }
395
+				    if ($globalDebugTimeElapsed) {
396
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397
+				    }
307 398
 				    
308 399
 				    
309 400
 				    // Add source stat in DB
310 401
 				    $Stats = new Stats($this->db);
311 402
 				    if (!empty($this->stats)) {
312
-					if ($globalDebug) echo 'Add source stats : ';
403
+					if ($globalDebug) {
404
+						echo 'Add source stats : ';
405
+					}
313 406
 				        foreach($this->stats as $date => $data) {
314 407
 					    foreach($data as $source => $sourced) {
315 408
 					        //print_r($sourced);
316
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
317
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
409
+				    	        if (isset($sourced['polar'])) {
410
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
411
+				    	        }
412
+				    	        if (isset($sourced['hist'])) {
413
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
414
+				    	        }
318 415
 				    		if (isset($sourced['msg'])) {
319 416
 				    		    if (time() - $sourced['msg']['date'] > 10) {
320 417
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -327,7 +424,9 @@  discard block
 block discarded – undo
327 424
 			    			unset($this->stats[$date]);
328 425
 			    		    }
329 426
 				    	}
330
-				    	if ($globalDebug) echo 'Done'."\n";
427
+				    	if ($globalDebug) {
428
+				    		echo 'Done'."\n";
429
+				    	}
331 430
 
332 431
 				    }
333 432
 				    $Stats->db = null;
@@ -337,12 +436,16 @@  discard block
 block discarded – undo
337 436
 				$this->all_tracked[$id]['addedTracker'] = 1;
338 437
 				//print_r($this->all_tracked[$id]);
339 438
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
340
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
439
+				    if ($globalDebug) {
440
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    }
341 442
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
342 443
 				    $TrackerLive = new TrackerLive($this->db);
343 444
 				    $TrackerLive->deleteLiveTrackerData();
344 445
 				    $TrackerLive->db=null;
345
-				    if ($globalDebug) echo " Done\n";
446
+				    if ($globalDebug) {
447
+				    	echo " Done\n";
448
+				    }
346 449
 				    $this->last_delete = time();
347 450
 				}
348 451
 			    } else {
@@ -365,19 +468,25 @@  discard block
 block discarded – undo
365 468
 
366 469
 		    if (!$ignoreImport) {
367 470
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
368
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
471
+				if ($globalDebug) {
472
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				}
369 474
 				$timeelapsed = microtime(true);
370 475
 				$TrackerLive = new TrackerLive($this->db);
371 476
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
372 477
 				$TrackerLive->db = null;
373 478
 				$this->all_tracked[$id]['putinarchive'] = false;
374
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
479
+				if ($globalDebugTimeElapsed) {
480
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				}
375 482
 
376 483
 				// Put statistics in $this->stats variable
377 484
 				
378 485
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
379 486
 					$source = $this->all_tracked[$id]['source_name'];
380
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
487
+					if ($source == '') {
488
+						$source = $this->all_tracked[$id]['format_source'];
489
+					}
381 490
 					if (!isset($this->source_location[$source])) {
382 491
 						$Location = new Source();
383 492
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -398,7 +507,9 @@  discard block
 block discarded – undo
398 507
 					$stats_heading = round($stats_heading/22.5);
399 508
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
400 509
 					$current_date = date('Y-m-d');
401
-					if ($stats_heading == 16) $stats_heading = 0;
510
+					if ($stats_heading == 16) {
511
+						$stats_heading = 0;
512
+					}
402 513
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
403 514
 						for ($i=0;$i<=15;$i++) {
404 515
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -416,7 +527,9 @@  discard block
 block discarded – undo
416 527
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
417 528
 						    end($this->stats[$current_date][$source]['hist']);
418 529
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
-						} else $mini = 0;
530
+						} else {
531
+							$mini = 0;
532
+						}
420 533
 						for ($i=$mini;$i<=$distance;$i+=10) {
421 534
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
422 535
 						}
@@ -427,19 +540,29 @@  discard block
 block discarded – undo
427 540
 				}
428 541
 
429 542
 				$this->all_tracked[$id]['lastupdate'] = time();
430
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431
-				if ($globalDebug) echo $result."\n";
432
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
543
+				if ($this->all_tracked[$id]['putinarchive']) {
544
+					$send = true;
545
+				}
546
+				if ($globalDebug) {
547
+					echo $result."\n";
548
+				}
549
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
550
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
551
+			}
433 552
 			//$this->del();
434 553
 			
435 554
 			
436 555
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
437
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
556
+			    if ($globalDebug) {
557
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    }
438 559
 			    $TrackerLive = new TrackerLive($this->db);
439 560
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
440 561
 			    $TrackerLive->db = null;
441 562
 			    //TrackerLive->deleteLiveTrackerData();
442
-			    if ($globalDebug) echo " Done\n";
563
+			    if ($globalDebug) {
564
+			    	echo " Done\n";
565
+			    }
443 566
 			    $this->last_delete_hourly = time();
444 567
 			}
445 568
 			
@@ -447,7 +570,9 @@  discard block
 block discarded – undo
447 570
 		    //$ignoreImport = false;
448 571
 		}
449 572
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
450
-		if ($send) return $this->all_tracked[$id];
573
+		if ($send) {
574
+			return $this->all_tracked[$id];
575
+		}
451 576
 	    }
452 577
 	}
453 578
     }
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,160 +192,160 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
221 221
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
222 222
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
223 223
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
224
-		    }
224
+			}
225 225
 		}
226 226
 		if (isset($line['last_update']) && $line['last_update'] != '') {
227
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
228
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
227
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
228
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229 229
 		}
230 230
 		if (isset($line['format_source']) && $line['format_source'] != '') {
231
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
231
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
232 232
 		}
233 233
 		if (isset($line['source_name']) && $line['source_name'] != '') {
234
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
234
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
235 235
 		}
236 236
 		if (isset($line['comment']) && $line['comment'] != '') {
237
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
238
-		    //$dataFound = true;
237
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
238
+			//$dataFound = true;
239 239
 		}
240 240
 		if (isset($line['type']) && $line['type'] != '') {
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
242
-		    //$dataFound = true;
241
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
242
+			//$dataFound = true;
243 243
 		}
244 244
 
245 245
 		if (isset($line['altitude']) && $line['altitude'] != '') {
246
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
247 247
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
248 248
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
249 249
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
250 250
 			//$dataFound = true;
251
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
251
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
252 252
   		}
253 253
 
254 254
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
255
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
255
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
256 256
 		}
257 257
 		
258 258
 		if (isset($line['heading']) && $line['heading'] != '') {
259
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
261
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
262
-		    //$dataFound = true;
259
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
261
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
262
+			//$dataFound = true;
263 263
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
264
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
266
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
267
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
264
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
265
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
266
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
267
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
268 268
   		}
269 269
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
270 270
 
271 271
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
272
-		    $this->all_tracked[$id]['lastupdate'] = time();
273
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
274
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
272
+			$this->all_tracked[$id]['lastupdate'] = time();
273
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
274
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
276 276
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
277 277
 				$timeelapsed = microtime(true);
278 278
 				$TrackerLive = new TrackerLive($this->db);
279 279
 				if (isset($line['id'])) {
280
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
281
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
280
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
281
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282 282
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
283
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
284
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
284
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285 285
 				} else $recent_ident = '';
286 286
 				$TrackerLive->db=null;
287 287
 
288 288
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
289 289
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
290
-			    } else {
290
+				} else {
291 291
 				$recent_ident = '';
292 292
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
293
-			    }
294
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
295
-			    if($recent_ident == "")
296
-			    {
293
+				}
294
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
295
+				if($recent_ident == "")
296
+				{
297 297
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
298 298
 				//adds the spotter data for the archive
299
-				    $highlight = '';
300
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
301
-				    $timeelapsed = microtime(true);
302
-				    $Tracker = new Tracker($this->db);
303
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
304
-				    $Tracker->db = null;
305
-				    if ($globalDebug && isset($result)) echo $result."\n";
306
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
299
+					$highlight = '';
300
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
301
+					$timeelapsed = microtime(true);
302
+					$Tracker = new Tracker($this->db);
303
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
304
+					$Tracker->db = null;
305
+					if ($globalDebug && isset($result)) echo $result."\n";
306
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
307 307
 				    
308 308
 				    
309
-				    // Add source stat in DB
310
-				    $Stats = new Stats($this->db);
311
-				    if (!empty($this->stats)) {
309
+					// Add source stat in DB
310
+					$Stats = new Stats($this->db);
311
+					if (!empty($this->stats)) {
312 312
 					if ($globalDebug) echo 'Add source stats : ';
313
-				        foreach($this->stats as $date => $data) {
314
-					    foreach($data as $source => $sourced) {
315
-					        //print_r($sourced);
316
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
317
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
-				    		if (isset($sourced['msg'])) {
319
-				    		    if (time() - $sourced['msg']['date'] > 10) {
320
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
321
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
322
-			    			        unset($this->stats[$date][$source]['msg']);
323
-			    			    }
324
-			    			}
325
-			    		    }
326
-			    		    if ($date != date('Y-m-d')) {
327
-			    			unset($this->stats[$date]);
328
-			    		    }
329
-				    	}
330
-				    	if ($globalDebug) echo 'Done'."\n";
313
+						foreach($this->stats as $date => $data) {
314
+						foreach($data as $source => $sourced) {
315
+							//print_r($sourced);
316
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
317
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+							if (isset($sourced['msg'])) {
319
+								if (time() - $sourced['msg']['date'] > 10) {
320
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
321
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
322
+									unset($this->stats[$date][$source]['msg']);
323
+								}
324
+							}
325
+							}
326
+							if ($date != date('Y-m-d')) {
327
+							unset($this->stats[$date]);
328
+							}
329
+						}
330
+						if ($globalDebug) echo 'Done'."\n";
331 331
 
332
-				    }
333
-				    $Stats->db = null;
332
+					}
333
+					$Stats->db = null;
334 334
 				    
335
-				    $this->del();
335
+					$this->del();
336 336
 				//$ignoreImport = false;
337 337
 				$this->all_tracked[$id]['addedTracker'] = 1;
338 338
 				//print_r($this->all_tracked[$id]);
339 339
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
340
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
341
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
342
-				    $TrackerLive = new TrackerLive($this->db);
343
-				    $TrackerLive->deleteLiveTrackerData();
344
-				    $TrackerLive->db=null;
345
-				    if ($globalDebug) echo " Done\n";
346
-				    $this->last_delete = time();
340
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
341
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
342
+					$TrackerLive = new TrackerLive($this->db);
343
+					$TrackerLive->deleteLiveTrackerData();
344
+					$TrackerLive->db=null;
345
+					if ($globalDebug) echo " Done\n";
346
+					$this->last_delete = time();
347 347
 				}
348
-			    } else {
348
+				} else {
349 349
 				$this->all_tracked[$id]['id'] = $recent_ident;
350 350
 				$this->all_tracked[$id]['addedTracker'] = 1;
351 351
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
 					$Tracker->db = null;
355 355
 				}
356 356
 				
357
-			    }
357
+				}
358 358
 			}
359
-		    }
360
-		    //adds the spotter LIVE data
361
-		    if ($globalDebug) {
359
+			}
360
+			//adds the spotter LIVE data
361
+			if ($globalDebug) {
362 362
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
363
-		    }
364
-		    $ignoreImport = false;
363
+			}
364
+			$ignoreImport = false;
365 365
 
366
-		    if (!$ignoreImport) {
366
+			if (!$ignoreImport) {
367 367
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
368 368
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
369 369
 				$timeelapsed = microtime(true);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 					if ($stats_heading == 16) $stats_heading = 0;
402 402
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
403 403
 						for ($i=0;$i<=15;$i++) {
404
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
404
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
405 405
 						}
406 406
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
407 407
 					} else {
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 					//var_dump($this->stats);
415 415
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
416 416
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
417
-						    end($this->stats[$current_date][$source]['hist']);
418
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
417
+							end($this->stats[$current_date][$source]['hist']);
418
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
419 419
 						} else $mini = 0;
420 420
 						for ($i=$mini;$i<=$distance;$i+=10) {
421
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
421
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
422 422
 						}
423 423
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
424 424
 					} else {
@@ -434,22 +434,22 @@  discard block
 block discarded – undo
434 434
 			
435 435
 			
436 436
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
437
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
438
-			    $TrackerLive = new TrackerLive($this->db);
439
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
440
-			    $TrackerLive->db = null;
441
-			    //TrackerLive->deleteLiveTrackerData();
442
-			    if ($globalDebug) echo " Done\n";
443
-			    $this->last_delete_hourly = time();
437
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
438
+				$TrackerLive = new TrackerLive($this->db);
439
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
440
+				$TrackerLive->db = null;
441
+				//TrackerLive->deleteLiveTrackerData();
442
+				if ($globalDebug) echo " Done\n";
443
+				$this->last_delete_hourly = time();
444 444
 			}
445 445
 			
446
-		    }
447
-		    //$ignoreImport = false;
446
+			}
447
+			//$ignoreImport = false;
448 448
 		}
449 449
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
450 450
 		if ($send) return $this->all_tracked[$id];
451
-	    }
451
+		}
452
+	}
452 453
 	}
453
-    }
454 454
 }
455 455
 ?>
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +622 added lines, -622 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
 			} catch(PDOException $e) {
1720 1720
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1721 1721
 			}
1722
-                }
1722
+				}
1723 1723
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1724 1724
 		try {
1725 1725
 			$sth = $Connection->db->prepare($query);
@@ -1937,185 +1937,185 @@  discard block
 block discarded – undo
1937 1937
 	}
1938 1938
 
1939 1939
 
1940
-    	public static function check_version($update = false) {
1941
-    	    global $globalDBname;
1942
-    	    $version = 0;
1943
-    	    $Connection = new Connection();
1944
-    	    if ($Connection->tableExists('aircraft')) {
1945
-    		if (!$Connection->tableExists('config')) {
1946
-    		    $version = '1';
1947
-    		    if ($update) return self::update_from_1();
1948
-    		    else return $version;
1940
+		public static function check_version($update = false) {
1941
+			global $globalDBname;
1942
+			$version = 0;
1943
+			$Connection = new Connection();
1944
+			if ($Connection->tableExists('aircraft')) {
1945
+			if (!$Connection->tableExists('config')) {
1946
+				$version = '1';
1947
+				if ($update) return self::update_from_1();
1948
+				else return $version;
1949 1949
 		} else {
1950
-    		    $Connection = new Connection();
1951
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1952
-		    try {
1953
-            		$sth = $Connection->db->prepare($query);
1954
-		        $sth->execute();
1955
-		    } catch(PDOException $e) {
1950
+				$Connection = new Connection();
1951
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1952
+			try {
1953
+					$sth = $Connection->db->prepare($query);
1954
+				$sth->execute();
1955
+			} catch(PDOException $e) {
1956 1956
 			return "error : ".$e->getMessage()."\n";
1957
-    		    }
1958
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1959
-    		    if ($update) {
1960
-    			if ($result['value'] == '2') {
1961
-    			    $error = self::update_from_2();
1962
-    			    if ($error != '') return $error;
1963
-    			    else return self::check_version(true);
1964
-    			} elseif ($result['value'] == '3') {
1965
-    			    $error = self::update_from_3();
1966
-    			    if ($error != '') return $error;
1967
-    			    else return self::check_version(true);
1968
-    			} elseif ($result['value'] == '4') {
1969
-    			    $error = self::update_from_4();
1970
-    			    if ($error != '') return $error;
1971
-    			    else return self::check_version(true);
1972
-    			} elseif ($result['value'] == '5') {
1973
-    			    $error = self::update_from_5();
1974
-    			    if ($error != '') return $error;
1975
-    			    else return self::check_version(true);
1976
-    			} elseif ($result['value'] == '6') {
1977
-    			    $error = self::update_from_6();
1978
-    			    if ($error != '') return $error;
1979
-    			    else return self::check_version(true);
1980
-    			} elseif ($result['value'] == '7') {
1981
-    			    $error = self::update_from_7();
1982
-    			    if ($error != '') return $error;
1983
-    			    else return self::check_version(true);
1984
-    			} elseif ($result['value'] == '8') {
1985
-    			    $error = self::update_from_8();
1986
-    			    if ($error != '') return $error;
1987
-    			    else return self::check_version(true);
1988
-    			} elseif ($result['value'] == '9') {
1989
-    			    $error = self::update_from_9();
1990
-    			    if ($error != '') return $error;
1991
-    			    else return self::check_version(true);
1992
-    			} elseif ($result['value'] == '10') {
1993
-    			    $error = self::update_from_10();
1994
-    			    if ($error != '') return $error;
1995
-    			    else return self::check_version(true);
1996
-    			} elseif ($result['value'] == '11') {
1997
-    			    $error = self::update_from_11();
1998
-    			    if ($error != '') return $error;
1999
-    			    else return self::check_version(true);
2000
-    			} elseif ($result['value'] == '12') {
2001
-    			    $error = self::update_from_12();
2002
-    			    if ($error != '') return $error;
2003
-    			    else return self::check_version(true);
2004
-    			} elseif ($result['value'] == '13') {
2005
-    			    $error = self::update_from_13();
2006
-    			    if ($error != '') return $error;
2007
-    			    else return self::check_version(true);
2008
-    			} elseif ($result['value'] == '14') {
2009
-    			    $error = self::update_from_14();
2010
-    			    if ($error != '') return $error;
2011
-    			    else return self::check_version(true);
2012
-    			} elseif ($result['value'] == '15') {
2013
-    			    $error = self::update_from_15();
2014
-    			    if ($error != '') return $error;
2015
-    			    else return self::check_version(true);
2016
-    			} elseif ($result['value'] == '16') {
2017
-    			    $error = self::update_from_16();
2018
-    			    if ($error != '') return $error;
2019
-    			    else return self::check_version(true);
2020
-    			} elseif ($result['value'] == '17') {
2021
-    			    $error = self::update_from_17();
2022
-    			    if ($error != '') return $error;
2023
-    			    else return self::check_version(true);
2024
-    			} elseif ($result['value'] == '18') {
2025
-    			    $error = self::update_from_18();
2026
-    			    if ($error != '') return $error;
2027
-    			    else return self::check_version(true);
2028
-    			} elseif ($result['value'] == '19') {
2029
-    			    $error = self::update_from_19();
2030
-    			    if ($error != '') return $error;
2031
-    			    else return self::check_version(true);
2032
-    			} elseif ($result['value'] == '20') {
2033
-    			    $error = self::update_from_20();
2034
-    			    if ($error != '') return $error;
2035
-    			    else return self::check_version(true);
2036
-    			} elseif ($result['value'] == '21') {
2037
-    			    $error = self::update_from_21();
2038
-    			    if ($error != '') return $error;
2039
-    			    else return self::check_version(true);
2040
-    			} elseif ($result['value'] == '22') {
2041
-    			    $error = self::update_from_22();
2042
-    			    if ($error != '') return $error;
2043
-    			    else return self::check_version(true);
2044
-    			} elseif ($result['value'] == '23') {
2045
-    			    $error = self::update_from_23();
2046
-    			    if ($error != '') return $error;
2047
-    			    else return self::check_version(true);
2048
-    			} elseif ($result['value'] == '24') {
2049
-    			    $error = self::update_from_24();
2050
-    			    if ($error != '') return $error;
2051
-    			    else return self::check_version(true);
2052
-    			} elseif ($result['value'] == '25') {
2053
-    			    $error = self::update_from_25();
2054
-    			    if ($error != '') return $error;
2055
-    			    else return self::check_version(true);
2056
-    			} elseif ($result['value'] == '26') {
2057
-    			    $error = self::update_from_26();
2058
-    			    if ($error != '') return $error;
2059
-    			    else return self::check_version(true);
2060
-    			} elseif ($result['value'] == '27') {
2061
-    			    $error = self::update_from_27();
2062
-    			    if ($error != '') return $error;
2063
-    			    else return self::check_version(true);
2064
-    			} elseif ($result['value'] == '28') {
2065
-    			    $error = self::update_from_28();
2066
-    			    if ($error != '') return $error;
2067
-    			    else return self::check_version(true);
2068
-    			} elseif ($result['value'] == '29') {
2069
-    			    $error = self::update_from_29();
2070
-    			    if ($error != '') return $error;
2071
-    			    else return self::check_version(true);
2072
-    			} elseif ($result['value'] == '30') {
2073
-    			    $error = self::update_from_30();
2074
-    			    if ($error != '') return $error;
2075
-    			    else return self::check_version(true);
2076
-    			} elseif ($result['value'] == '31') {
2077
-    			    $error = self::update_from_31();
2078
-    			    if ($error != '') return $error;
2079
-    			    else return self::check_version(true);
2080
-    			} elseif ($result['value'] == '32') {
2081
-    			    $error = self::update_from_32();
2082
-    			    if ($error != '') return $error;
2083
-    			    else return self::check_version(true);
2084
-    			} elseif ($result['value'] == '33') {
2085
-    			    $error = self::update_from_33();
2086
-    			    if ($error != '') return $error;
2087
-    			    else return self::check_version(true);
2088
-    			} elseif ($result['value'] == '34') {
2089
-    			    $error = self::update_from_34();
2090
-    			    if ($error != '') return $error;
2091
-    			    else return self::check_version(true);
2092
-    			} elseif ($result['value'] == '35') {
2093
-    			    $error = self::update_from_35();
2094
-    			    if ($error != '') return $error;
2095
-    			    else return self::check_version(true);
2096
-    			} elseif ($result['value'] == '36') {
2097
-    			    $error = self::update_from_36();
2098
-    			    if ($error != '') return $error;
2099
-    			    else return self::check_version(true);
2100
-    			} elseif ($result['value'] == '37') {
2101
-    			    $error = self::update_from_37();
2102
-    			    if ($error != '') return $error;
2103
-    			    else return self::check_version(true);
2104
-    			} elseif ($result['value'] == '38') {
2105
-    			    $error = self::update_from_38();
2106
-    			    if ($error != '') return $error;
2107
-    			    else return self::check_version(true);
2108
-    			} elseif ($result['value'] == '39') {
2109
-    			    $error = self::update_from_39();
2110
-    			    if ($error != '') return $error;
2111
-    			    else return self::check_version(true);
2112
-    			} else return '';
2113
-    		    }
2114
-    		    else return $result['value'];
1957
+				}
1958
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1959
+				if ($update) {
1960
+				if ($result['value'] == '2') {
1961
+					$error = self::update_from_2();
1962
+					if ($error != '') return $error;
1963
+					else return self::check_version(true);
1964
+				} elseif ($result['value'] == '3') {
1965
+					$error = self::update_from_3();
1966
+					if ($error != '') return $error;
1967
+					else return self::check_version(true);
1968
+				} elseif ($result['value'] == '4') {
1969
+					$error = self::update_from_4();
1970
+					if ($error != '') return $error;
1971
+					else return self::check_version(true);
1972
+				} elseif ($result['value'] == '5') {
1973
+					$error = self::update_from_5();
1974
+					if ($error != '') return $error;
1975
+					else return self::check_version(true);
1976
+				} elseif ($result['value'] == '6') {
1977
+					$error = self::update_from_6();
1978
+					if ($error != '') return $error;
1979
+					else return self::check_version(true);
1980
+				} elseif ($result['value'] == '7') {
1981
+					$error = self::update_from_7();
1982
+					if ($error != '') return $error;
1983
+					else return self::check_version(true);
1984
+				} elseif ($result['value'] == '8') {
1985
+					$error = self::update_from_8();
1986
+					if ($error != '') return $error;
1987
+					else return self::check_version(true);
1988
+				} elseif ($result['value'] == '9') {
1989
+					$error = self::update_from_9();
1990
+					if ($error != '') return $error;
1991
+					else return self::check_version(true);
1992
+				} elseif ($result['value'] == '10') {
1993
+					$error = self::update_from_10();
1994
+					if ($error != '') return $error;
1995
+					else return self::check_version(true);
1996
+				} elseif ($result['value'] == '11') {
1997
+					$error = self::update_from_11();
1998
+					if ($error != '') return $error;
1999
+					else return self::check_version(true);
2000
+				} elseif ($result['value'] == '12') {
2001
+					$error = self::update_from_12();
2002
+					if ($error != '') return $error;
2003
+					else return self::check_version(true);
2004
+				} elseif ($result['value'] == '13') {
2005
+					$error = self::update_from_13();
2006
+					if ($error != '') return $error;
2007
+					else return self::check_version(true);
2008
+				} elseif ($result['value'] == '14') {
2009
+					$error = self::update_from_14();
2010
+					if ($error != '') return $error;
2011
+					else return self::check_version(true);
2012
+				} elseif ($result['value'] == '15') {
2013
+					$error = self::update_from_15();
2014
+					if ($error != '') return $error;
2015
+					else return self::check_version(true);
2016
+				} elseif ($result['value'] == '16') {
2017
+					$error = self::update_from_16();
2018
+					if ($error != '') return $error;
2019
+					else return self::check_version(true);
2020
+				} elseif ($result['value'] == '17') {
2021
+					$error = self::update_from_17();
2022
+					if ($error != '') return $error;
2023
+					else return self::check_version(true);
2024
+				} elseif ($result['value'] == '18') {
2025
+					$error = self::update_from_18();
2026
+					if ($error != '') return $error;
2027
+					else return self::check_version(true);
2028
+				} elseif ($result['value'] == '19') {
2029
+					$error = self::update_from_19();
2030
+					if ($error != '') return $error;
2031
+					else return self::check_version(true);
2032
+				} elseif ($result['value'] == '20') {
2033
+					$error = self::update_from_20();
2034
+					if ($error != '') return $error;
2035
+					else return self::check_version(true);
2036
+				} elseif ($result['value'] == '21') {
2037
+					$error = self::update_from_21();
2038
+					if ($error != '') return $error;
2039
+					else return self::check_version(true);
2040
+				} elseif ($result['value'] == '22') {
2041
+					$error = self::update_from_22();
2042
+					if ($error != '') return $error;
2043
+					else return self::check_version(true);
2044
+				} elseif ($result['value'] == '23') {
2045
+					$error = self::update_from_23();
2046
+					if ($error != '') return $error;
2047
+					else return self::check_version(true);
2048
+				} elseif ($result['value'] == '24') {
2049
+					$error = self::update_from_24();
2050
+					if ($error != '') return $error;
2051
+					else return self::check_version(true);
2052
+				} elseif ($result['value'] == '25') {
2053
+					$error = self::update_from_25();
2054
+					if ($error != '') return $error;
2055
+					else return self::check_version(true);
2056
+				} elseif ($result['value'] == '26') {
2057
+					$error = self::update_from_26();
2058
+					if ($error != '') return $error;
2059
+					else return self::check_version(true);
2060
+				} elseif ($result['value'] == '27') {
2061
+					$error = self::update_from_27();
2062
+					if ($error != '') return $error;
2063
+					else return self::check_version(true);
2064
+				} elseif ($result['value'] == '28') {
2065
+					$error = self::update_from_28();
2066
+					if ($error != '') return $error;
2067
+					else return self::check_version(true);
2068
+				} elseif ($result['value'] == '29') {
2069
+					$error = self::update_from_29();
2070
+					if ($error != '') return $error;
2071
+					else return self::check_version(true);
2072
+				} elseif ($result['value'] == '30') {
2073
+					$error = self::update_from_30();
2074
+					if ($error != '') return $error;
2075
+					else return self::check_version(true);
2076
+				} elseif ($result['value'] == '31') {
2077
+					$error = self::update_from_31();
2078
+					if ($error != '') return $error;
2079
+					else return self::check_version(true);
2080
+				} elseif ($result['value'] == '32') {
2081
+					$error = self::update_from_32();
2082
+					if ($error != '') return $error;
2083
+					else return self::check_version(true);
2084
+				} elseif ($result['value'] == '33') {
2085
+					$error = self::update_from_33();
2086
+					if ($error != '') return $error;
2087
+					else return self::check_version(true);
2088
+				} elseif ($result['value'] == '34') {
2089
+					$error = self::update_from_34();
2090
+					if ($error != '') return $error;
2091
+					else return self::check_version(true);
2092
+				} elseif ($result['value'] == '35') {
2093
+					$error = self::update_from_35();
2094
+					if ($error != '') return $error;
2095
+					else return self::check_version(true);
2096
+				} elseif ($result['value'] == '36') {
2097
+					$error = self::update_from_36();
2098
+					if ($error != '') return $error;
2099
+					else return self::check_version(true);
2100
+				} elseif ($result['value'] == '37') {
2101
+					$error = self::update_from_37();
2102
+					if ($error != '') return $error;
2103
+					else return self::check_version(true);
2104
+				} elseif ($result['value'] == '38') {
2105
+					$error = self::update_from_38();
2106
+					if ($error != '') return $error;
2107
+					else return self::check_version(true);
2108
+				} elseif ($result['value'] == '39') {
2109
+					$error = self::update_from_39();
2110
+					if ($error != '') return $error;
2111
+					else return self::check_version(true);
2112
+				} else return '';
2113
+				}
2114
+				else return $result['value'];
2115 2115
 		}
2116 2116
 		
2117
-	    } else return $version;
2118
-    	}
2117
+		} else return $version;
2118
+		}
2119 2119
     	
2120 2120
 }
2121 2121
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
 		global $globalDBdriver;
1578 1578
 		$Connection = new Connection();
1579 1579
 		$error = '';
1580
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1580
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1581 1581
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584 1584
 				$sth->execute();
1585
-			} catch(PDOException $e) {
1585
+			} catch (PDOException $e) {
1586 1586
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1587 1587
 			}
1588 1588
 		}
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		try {
1649 1649
 			$sth = $Connection->db->prepare($query);
1650 1650
 			$sth->execute();
1651
-		} catch(PDOException $e) {
1651
+		} catch (PDOException $e) {
1652 1652
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1653 1653
 		}
1654 1654
 		return $error;
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 			try {
1697 1697
 				$sth = $Connection->db->prepare($query);
1698 1698
 				$sth->execute();
1699
-			} catch(PDOException $e) {
1699
+			} catch (PDOException $e) {
1700 1700
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1701 1701
 			}
1702 1702
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1705,18 +1705,18 @@  discard block
 block discarded – undo
1705 1705
 				try {
1706 1706
 					$sth = $Connection->db->prepare($query);
1707 1707
 					$sth->execute();
1708
-				} catch(PDOException $e) {
1708
+				} catch (PDOException $e) {
1709 1709
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1710 1710
 				}
1711 1711
 			}
1712 1712
 		}
1713
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1713
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1714 1714
 			// Add index key
1715 1715
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1716 1716
 			try {
1717 1717
 				$sth = $Connection->db->prepare($query);
1718 1718
 				$sth->execute();
1719
-			} catch(PDOException $e) {
1719
+			} catch (PDOException $e) {
1720 1720
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1721 1721
 			}
1722 1722
                 }
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 		try {
1725 1725
 			$sth = $Connection->db->prepare($query);
1726 1726
 			$sth->execute();
1727
-		} catch(PDOException $e) {
1727
+		} catch (PDOException $e) {
1728 1728
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1729 1729
 		}
1730 1730
 		return $error;
@@ -1735,148 +1735,148 @@  discard block
 block discarded – undo
1735 1735
 		$Connection = new Connection();
1736 1736
 		$error = '';
1737 1737
 		if ($globalDBdriver == 'mysql') {
1738
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1738
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1739 1739
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1740 1740
 				try {
1741 1741
 					$sth = $Connection->db->prepare($query);
1742 1742
 					$sth->execute();
1743
-				} catch(PDOException $e) {
1743
+				} catch (PDOException $e) {
1744 1744
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1745 1745
 				}
1746 1746
 			}
1747
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1747
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1748 1748
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1749 1749
 				try {
1750 1750
 					$sth = $Connection->db->prepare($query);
1751 1751
 					$sth->execute();
1752
-				} catch(PDOException $e) {
1752
+				} catch (PDOException $e) {
1753 1753
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1754 1754
 				}
1755 1755
 			}
1756
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1756
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1757 1757
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1758 1758
 				try {
1759 1759
 					$sth = $Connection->db->prepare($query);
1760 1760
 					$sth->execute();
1761
-				} catch(PDOException $e) {
1761
+				} catch (PDOException $e) {
1762 1762
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1763 1763
 				}
1764 1764
 			}
1765
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1765
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1766 1766
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1767 1767
 				try {
1768 1768
 					$sth = $Connection->db->prepare($query);
1769 1769
 					$sth->execute();
1770
-				} catch(PDOException $e) {
1770
+				} catch (PDOException $e) {
1771 1771
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1772 1772
 				}
1773 1773
 			}
1774
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1774
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1775 1775
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1776 1776
 				try {
1777 1777
 					$sth = $Connection->db->prepare($query);
1778 1778
 					$sth->execute();
1779
-				} catch(PDOException $e) {
1779
+				} catch (PDOException $e) {
1780 1780
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1781 1781
 				}
1782 1782
 			}
1783
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1783
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1784 1784
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1785 1785
 				try {
1786 1786
 					$sth = $Connection->db->prepare($query);
1787 1787
 					$sth->execute();
1788
-				} catch(PDOException $e) {
1788
+				} catch (PDOException $e) {
1789 1789
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1790 1790
 				}
1791 1791
 			}
1792
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1792
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1793 1793
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1794 1794
 				try {
1795 1795
 					$sth = $Connection->db->prepare($query);
1796 1796
 					$sth->execute();
1797
-				} catch(PDOException $e) {
1797
+				} catch (PDOException $e) {
1798 1798
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1799 1799
 				}
1800 1800
 			}
1801
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1801
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1802 1802
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1803 1803
 				try {
1804 1804
 					$sth = $Connection->db->prepare($query);
1805 1805
 					$sth->execute();
1806
-				} catch(PDOException $e) {
1806
+				} catch (PDOException $e) {
1807 1807
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1808 1808
 				}
1809 1809
 			}
1810 1810
 		} else {
1811
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1811
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1812 1812
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1813 1813
 				try {
1814 1814
 					$sth = $Connection->db->prepare($query);
1815 1815
 					$sth->execute();
1816
-				} catch(PDOException $e) {
1816
+				} catch (PDOException $e) {
1817 1817
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1818 1818
 				}
1819 1819
 			}
1820
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1820
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1821 1821
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1822 1822
 				try {
1823 1823
 					$sth = $Connection->db->prepare($query);
1824 1824
 					$sth->execute();
1825
-				} catch(PDOException $e) {
1825
+				} catch (PDOException $e) {
1826 1826
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1827 1827
 				}
1828 1828
 			}
1829
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1829
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1830 1830
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1831 1831
 				try {
1832 1832
 					$sth = $Connection->db->prepare($query);
1833 1833
 					$sth->execute();
1834
-				} catch(PDOException $e) {
1834
+				} catch (PDOException $e) {
1835 1835
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1836 1836
 				}
1837 1837
 			}
1838
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1838
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1839 1839
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1840 1840
 				try {
1841 1841
 					$sth = $Connection->db->prepare($query);
1842 1842
 					$sth->execute();
1843
-				} catch(PDOException $e) {
1843
+				} catch (PDOException $e) {
1844 1844
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1845 1845
 				}
1846 1846
 			}
1847
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1847
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1848 1848
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1849 1849
 				try {
1850 1850
 					$sth = $Connection->db->prepare($query);
1851 1851
 					$sth->execute();
1852
-				} catch(PDOException $e) {
1852
+				} catch (PDOException $e) {
1853 1853
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1854 1854
 				}
1855 1855
 			}
1856
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1856
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1857 1857
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1858 1858
 				try {
1859 1859
 					$sth = $Connection->db->prepare($query);
1860 1860
 					$sth->execute();
1861
-				} catch(PDOException $e) {
1861
+				} catch (PDOException $e) {
1862 1862
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1863 1863
 				}
1864 1864
 			}
1865
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1865
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1866 1866
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1867 1867
 				try {
1868 1868
 					$sth = $Connection->db->prepare($query);
1869 1869
 					$sth->execute();
1870
-				} catch(PDOException $e) {
1870
+				} catch (PDOException $e) {
1871 1871
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1872 1872
 				}
1873 1873
 			}
1874
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1874
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1875 1875
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1876 1876
 				try {
1877 1877
 					$sth = $Connection->db->prepare($query);
1878 1878
 					$sth->execute();
1879
-				} catch(PDOException $e) {
1879
+				} catch (PDOException $e) {
1880 1880
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1881 1881
 				}
1882 1882
 			}
@@ -1885,7 +1885,7 @@  discard block
 block discarded – undo
1885 1885
 		try {
1886 1886
 			$sth = $Connection->db->prepare($query);
1887 1887
 			$sth->execute();
1888
-		} catch(PDOException $e) {
1888
+		} catch (PDOException $e) {
1889 1889
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1890 1890
 		}
1891 1891
 		return $error;
@@ -1900,14 +1900,14 @@  discard block
 block discarded – undo
1900 1900
 			try {
1901 1901
 				$sth = $Connection->db->prepare($query);
1902 1902
 				$sth->execute();
1903
-			} catch(PDOException $e) {
1903
+			} catch (PDOException $e) {
1904 1904
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1905 1905
 			}
1906 1906
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1907 1907
 			try {
1908 1908
 				$sth = $Connection->db->prepare($query);
1909 1909
 				$sth->execute();
1910
-			} catch(PDOException $e) {
1910
+			} catch (PDOException $e) {
1911 1911
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1912 1912
 			}
1913 1913
 		} else {
@@ -1915,14 +1915,14 @@  discard block
 block discarded – undo
1915 1915
 			try {
1916 1916
 				$sth = $Connection->db->prepare($query);
1917 1917
 				$sth->execute();
1918
-			} catch(PDOException $e) {
1918
+			} catch (PDOException $e) {
1919 1919
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1920 1920
 			}
1921 1921
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1922 1922
 			try {
1923 1923
 				$sth = $Connection->db->prepare($query);
1924 1924
 				$sth->execute();
1925
-			} catch(PDOException $e) {
1925
+			} catch (PDOException $e) {
1926 1926
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1927 1927
 			}
1928 1928
 		}
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 		try {
1931 1931
 			$sth = $Connection->db->prepare($query);
1932 1932
 			$sth->execute();
1933
-		} catch(PDOException $e) {
1933
+		} catch (PDOException $e) {
1934 1934
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1935 1935
 		}
1936 1936
 		return $error;
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 		    try {
1953 1953
             		$sth = $Connection->db->prepare($query);
1954 1954
 		        $sth->execute();
1955
-		    } catch(PDOException $e) {
1955
+		    } catch (PDOException $e) {
1956 1956
 			return "error : ".$e->getMessage()."\n";
1957 1957
     		    }
1958 1958
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +368 added lines, -136 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,35 +1751,55 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('marine_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 		} else {
1683 1783
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1684
-			if ($error != '') return $error;
1784
+			if ($error != '') {
1785
+				return $error;
1786
+			}
1685 1787
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1686
-			if ($error != '') return $error;
1788
+			if ($error != '') {
1789
+				return $error;
1790
+			}
1687 1791
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1688
-			if ($error != '') return $error;
1792
+			if ($error != '') {
1793
+				return $error;
1794
+			}
1689 1795
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1690
-			if ($error != '') return $error;
1796
+			if ($error != '') {
1797
+				return $error;
1798
+			}
1691 1799
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1692
-			if ($error != '') return $error;
1800
+			if ($error != '') {
1801
+				return $error;
1802
+			}
1693 1803
 		}
1694 1804
 		if ($globalDBdriver == 'mysql') {
1695 1805
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -1944,8 +2054,11 @@  discard block
 block discarded – undo
1944 2054
     	    if ($Connection->tableExists('aircraft')) {
1945 2055
     		if (!$Connection->tableExists('config')) {
1946 2056
     		    $version = '1';
1947
-    		    if ($update) return self::update_from_1();
1948
-    		    else return $version;
2057
+    		    if ($update) {
2058
+    		    	return self::update_from_1();
2059
+    		    } else {
2060
+    		    	return $version;
2061
+    		    }
1949 2062
 		} else {
1950 2063
     		    $Connection = new Connection();
1951 2064
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1959,162 +2072,281 @@  discard block
 block discarded – undo
1959 2072
     		    if ($update) {
1960 2073
     			if ($result['value'] == '2') {
1961 2074
     			    $error = self::update_from_2();
1962
-    			    if ($error != '') return $error;
1963
-    			    else return self::check_version(true);
2075
+    			    if ($error != '') {
2076
+    			    	return $error;
2077
+    			    } else {
2078
+    			    	return self::check_version(true);
2079
+    			    }
1964 2080
     			} elseif ($result['value'] == '3') {
1965 2081
     			    $error = self::update_from_3();
1966
-    			    if ($error != '') return $error;
1967
-    			    else return self::check_version(true);
2082
+    			    if ($error != '') {
2083
+    			    	return $error;
2084
+    			    } else {
2085
+    			    	return self::check_version(true);
2086
+    			    }
1968 2087
     			} elseif ($result['value'] == '4') {
1969 2088
     			    $error = self::update_from_4();
1970
-    			    if ($error != '') return $error;
1971
-    			    else return self::check_version(true);
2089
+    			    if ($error != '') {
2090
+    			    	return $error;
2091
+    			    } else {
2092
+    			    	return self::check_version(true);
2093
+    			    }
1972 2094
     			} elseif ($result['value'] == '5') {
1973 2095
     			    $error = self::update_from_5();
1974
-    			    if ($error != '') return $error;
1975
-    			    else return self::check_version(true);
2096
+    			    if ($error != '') {
2097
+    			    	return $error;
2098
+    			    } else {
2099
+    			    	return self::check_version(true);
2100
+    			    }
1976 2101
     			} elseif ($result['value'] == '6') {
1977 2102
     			    $error = self::update_from_6();
1978
-    			    if ($error != '') return $error;
1979
-    			    else return self::check_version(true);
2103
+    			    if ($error != '') {
2104
+    			    	return $error;
2105
+    			    } else {
2106
+    			    	return self::check_version(true);
2107
+    			    }
1980 2108
     			} elseif ($result['value'] == '7') {
1981 2109
     			    $error = self::update_from_7();
1982
-    			    if ($error != '') return $error;
1983
-    			    else return self::check_version(true);
2110
+    			    if ($error != '') {
2111
+    			    	return $error;
2112
+    			    } else {
2113
+    			    	return self::check_version(true);
2114
+    			    }
1984 2115
     			} elseif ($result['value'] == '8') {
1985 2116
     			    $error = self::update_from_8();
1986
-    			    if ($error != '') return $error;
1987
-    			    else return self::check_version(true);
2117
+    			    if ($error != '') {
2118
+    			    	return $error;
2119
+    			    } else {
2120
+    			    	return self::check_version(true);
2121
+    			    }
1988 2122
     			} elseif ($result['value'] == '9') {
1989 2123
     			    $error = self::update_from_9();
1990
-    			    if ($error != '') return $error;
1991
-    			    else return self::check_version(true);
2124
+    			    if ($error != '') {
2125
+    			    	return $error;
2126
+    			    } else {
2127
+    			    	return self::check_version(true);
2128
+    			    }
1992 2129
     			} elseif ($result['value'] == '10') {
1993 2130
     			    $error = self::update_from_10();
1994
-    			    if ($error != '') return $error;
1995
-    			    else return self::check_version(true);
2131
+    			    if ($error != '') {
2132
+    			    	return $error;
2133
+    			    } else {
2134
+    			    	return self::check_version(true);
2135
+    			    }
1996 2136
     			} elseif ($result['value'] == '11') {
1997 2137
     			    $error = self::update_from_11();
1998
-    			    if ($error != '') return $error;
1999
-    			    else return self::check_version(true);
2138
+    			    if ($error != '') {
2139
+    			    	return $error;
2140
+    			    } else {
2141
+    			    	return self::check_version(true);
2142
+    			    }
2000 2143
     			} elseif ($result['value'] == '12') {
2001 2144
     			    $error = self::update_from_12();
2002
-    			    if ($error != '') return $error;
2003
-    			    else return self::check_version(true);
2145
+    			    if ($error != '') {
2146
+    			    	return $error;
2147
+    			    } else {
2148
+    			    	return self::check_version(true);
2149
+    			    }
2004 2150
     			} elseif ($result['value'] == '13') {
2005 2151
     			    $error = self::update_from_13();
2006
-    			    if ($error != '') return $error;
2007
-    			    else return self::check_version(true);
2152
+    			    if ($error != '') {
2153
+    			    	return $error;
2154
+    			    } else {
2155
+    			    	return self::check_version(true);
2156
+    			    }
2008 2157
     			} elseif ($result['value'] == '14') {
2009 2158
     			    $error = self::update_from_14();
2010
-    			    if ($error != '') return $error;
2011
-    			    else return self::check_version(true);
2159
+    			    if ($error != '') {
2160
+    			    	return $error;
2161
+    			    } else {
2162
+    			    	return self::check_version(true);
2163
+    			    }
2012 2164
     			} elseif ($result['value'] == '15') {
2013 2165
     			    $error = self::update_from_15();
2014
-    			    if ($error != '') return $error;
2015
-    			    else return self::check_version(true);
2166
+    			    if ($error != '') {
2167
+    			    	return $error;
2168
+    			    } else {
2169
+    			    	return self::check_version(true);
2170
+    			    }
2016 2171
     			} elseif ($result['value'] == '16') {
2017 2172
     			    $error = self::update_from_16();
2018
-    			    if ($error != '') return $error;
2019
-    			    else return self::check_version(true);
2173
+    			    if ($error != '') {
2174
+    			    	return $error;
2175
+    			    } else {
2176
+    			    	return self::check_version(true);
2177
+    			    }
2020 2178
     			} elseif ($result['value'] == '17') {
2021 2179
     			    $error = self::update_from_17();
2022
-    			    if ($error != '') return $error;
2023
-    			    else return self::check_version(true);
2180
+    			    if ($error != '') {
2181
+    			    	return $error;
2182
+    			    } else {
2183
+    			    	return self::check_version(true);
2184
+    			    }
2024 2185
     			} elseif ($result['value'] == '18') {
2025 2186
     			    $error = self::update_from_18();
2026
-    			    if ($error != '') return $error;
2027
-    			    else return self::check_version(true);
2187
+    			    if ($error != '') {
2188
+    			    	return $error;
2189
+    			    } else {
2190
+    			    	return self::check_version(true);
2191
+    			    }
2028 2192
     			} elseif ($result['value'] == '19') {
2029 2193
     			    $error = self::update_from_19();
2030
-    			    if ($error != '') return $error;
2031
-    			    else return self::check_version(true);
2194
+    			    if ($error != '') {
2195
+    			    	return $error;
2196
+    			    } else {
2197
+    			    	return self::check_version(true);
2198
+    			    }
2032 2199
     			} elseif ($result['value'] == '20') {
2033 2200
     			    $error = self::update_from_20();
2034
-    			    if ($error != '') return $error;
2035
-    			    else return self::check_version(true);
2201
+    			    if ($error != '') {
2202
+    			    	return $error;
2203
+    			    } else {
2204
+    			    	return self::check_version(true);
2205
+    			    }
2036 2206
     			} elseif ($result['value'] == '21') {
2037 2207
     			    $error = self::update_from_21();
2038
-    			    if ($error != '') return $error;
2039
-    			    else return self::check_version(true);
2208
+    			    if ($error != '') {
2209
+    			    	return $error;
2210
+    			    } else {
2211
+    			    	return self::check_version(true);
2212
+    			    }
2040 2213
     			} elseif ($result['value'] == '22') {
2041 2214
     			    $error = self::update_from_22();
2042
-    			    if ($error != '') return $error;
2043
-    			    else return self::check_version(true);
2215
+    			    if ($error != '') {
2216
+    			    	return $error;
2217
+    			    } else {
2218
+    			    	return self::check_version(true);
2219
+    			    }
2044 2220
     			} elseif ($result['value'] == '23') {
2045 2221
     			    $error = self::update_from_23();
2046
-    			    if ($error != '') return $error;
2047
-    			    else return self::check_version(true);
2222
+    			    if ($error != '') {
2223
+    			    	return $error;
2224
+    			    } else {
2225
+    			    	return self::check_version(true);
2226
+    			    }
2048 2227
     			} elseif ($result['value'] == '24') {
2049 2228
     			    $error = self::update_from_24();
2050
-    			    if ($error != '') return $error;
2051
-    			    else return self::check_version(true);
2229
+    			    if ($error != '') {
2230
+    			    	return $error;
2231
+    			    } else {
2232
+    			    	return self::check_version(true);
2233
+    			    }
2052 2234
     			} elseif ($result['value'] == '25') {
2053 2235
     			    $error = self::update_from_25();
2054
-    			    if ($error != '') return $error;
2055
-    			    else return self::check_version(true);
2236
+    			    if ($error != '') {
2237
+    			    	return $error;
2238
+    			    } else {
2239
+    			    	return self::check_version(true);
2240
+    			    }
2056 2241
     			} elseif ($result['value'] == '26') {
2057 2242
     			    $error = self::update_from_26();
2058
-    			    if ($error != '') return $error;
2059
-    			    else return self::check_version(true);
2243
+    			    if ($error != '') {
2244
+    			    	return $error;
2245
+    			    } else {
2246
+    			    	return self::check_version(true);
2247
+    			    }
2060 2248
     			} elseif ($result['value'] == '27') {
2061 2249
     			    $error = self::update_from_27();
2062
-    			    if ($error != '') return $error;
2063
-    			    else return self::check_version(true);
2250
+    			    if ($error != '') {
2251
+    			    	return $error;
2252
+    			    } else {
2253
+    			    	return self::check_version(true);
2254
+    			    }
2064 2255
     			} elseif ($result['value'] == '28') {
2065 2256
     			    $error = self::update_from_28();
2066
-    			    if ($error != '') return $error;
2067
-    			    else return self::check_version(true);
2257
+    			    if ($error != '') {
2258
+    			    	return $error;
2259
+    			    } else {
2260
+    			    	return self::check_version(true);
2261
+    			    }
2068 2262
     			} elseif ($result['value'] == '29') {
2069 2263
     			    $error = self::update_from_29();
2070
-    			    if ($error != '') return $error;
2071
-    			    else return self::check_version(true);
2264
+    			    if ($error != '') {
2265
+    			    	return $error;
2266
+    			    } else {
2267
+    			    	return self::check_version(true);
2268
+    			    }
2072 2269
     			} elseif ($result['value'] == '30') {
2073 2270
     			    $error = self::update_from_30();
2074
-    			    if ($error != '') return $error;
2075
-    			    else return self::check_version(true);
2271
+    			    if ($error != '') {
2272
+    			    	return $error;
2273
+    			    } else {
2274
+    			    	return self::check_version(true);
2275
+    			    }
2076 2276
     			} elseif ($result['value'] == '31') {
2077 2277
     			    $error = self::update_from_31();
2078
-    			    if ($error != '') return $error;
2079
-    			    else return self::check_version(true);
2278
+    			    if ($error != '') {
2279
+    			    	return $error;
2280
+    			    } else {
2281
+    			    	return self::check_version(true);
2282
+    			    }
2080 2283
     			} elseif ($result['value'] == '32') {
2081 2284
     			    $error = self::update_from_32();
2082
-    			    if ($error != '') return $error;
2083
-    			    else return self::check_version(true);
2285
+    			    if ($error != '') {
2286
+    			    	return $error;
2287
+    			    } else {
2288
+    			    	return self::check_version(true);
2289
+    			    }
2084 2290
     			} elseif ($result['value'] == '33') {
2085 2291
     			    $error = self::update_from_33();
2086
-    			    if ($error != '') return $error;
2087
-    			    else return self::check_version(true);
2292
+    			    if ($error != '') {
2293
+    			    	return $error;
2294
+    			    } else {
2295
+    			    	return self::check_version(true);
2296
+    			    }
2088 2297
     			} elseif ($result['value'] == '34') {
2089 2298
     			    $error = self::update_from_34();
2090
-    			    if ($error != '') return $error;
2091
-    			    else return self::check_version(true);
2299
+    			    if ($error != '') {
2300
+    			    	return $error;
2301
+    			    } else {
2302
+    			    	return self::check_version(true);
2303
+    			    }
2092 2304
     			} elseif ($result['value'] == '35') {
2093 2305
     			    $error = self::update_from_35();
2094
-    			    if ($error != '') return $error;
2095
-    			    else return self::check_version(true);
2306
+    			    if ($error != '') {
2307
+    			    	return $error;
2308
+    			    } else {
2309
+    			    	return self::check_version(true);
2310
+    			    }
2096 2311
     			} elseif ($result['value'] == '36') {
2097 2312
     			    $error = self::update_from_36();
2098
-    			    if ($error != '') return $error;
2099
-    			    else return self::check_version(true);
2313
+    			    if ($error != '') {
2314
+    			    	return $error;
2315
+    			    } else {
2316
+    			    	return self::check_version(true);
2317
+    			    }
2100 2318
     			} elseif ($result['value'] == '37') {
2101 2319
     			    $error = self::update_from_37();
2102
-    			    if ($error != '') return $error;
2103
-    			    else return self::check_version(true);
2320
+    			    if ($error != '') {
2321
+    			    	return $error;
2322
+    			    } else {
2323
+    			    	return self::check_version(true);
2324
+    			    }
2104 2325
     			} elseif ($result['value'] == '38') {
2105 2326
     			    $error = self::update_from_38();
2106
-    			    if ($error != '') return $error;
2107
-    			    else return self::check_version(true);
2327
+    			    if ($error != '') {
2328
+    			    	return $error;
2329
+    			    } else {
2330
+    			    	return self::check_version(true);
2331
+    			    }
2108 2332
     			} elseif ($result['value'] == '39') {
2109 2333
     			    $error = self::update_from_39();
2110
-    			    if ($error != '') return $error;
2111
-    			    else return self::check_version(true);
2112
-    			} else return '';
2334
+    			    if ($error != '') {
2335
+    			    	return $error;
2336
+    			    } else {
2337
+    			    	return self::check_version(true);
2338
+    			    }
2339
+    			} else {
2340
+    				return '';
2341
+    			}
2342
+    		    } else {
2343
+    		    	return $result['value'];
2113 2344
     		    }
2114
-    		    else return $result['value'];
2115 2345
 		}
2116 2346
 		
2117
-	    } else return $version;
2347
+	    } else {
2348
+	    	return $version;
2349
+	    }
2118 2350
     	}
2119 2351
     	
2120 2352
 }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +861 added lines, -861 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+	else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60
-    $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
60
+	$globalSources = array();
61
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+	else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
65 65
 	$globalServerAPRS = TRUE;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 if (isset($options['idsource'])) $id_source = $options['idsource'];
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
77
+	if ($globalDebug) echo "Using Server Mode\n";
78
+	$SI=new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 } else $SI=new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87
-    $AIS = new AIS();
88
-    $MI = new MarineImport($Connection->db);
87
+	$AIS = new AIS();
88
+	$MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91 91
 $SBS=new SBS();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
99
-        global $sockets;
100
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
-        die("Bye!\n");
102
-    });
103
-    pcntl_signal_dispatch();
98
+	pcntl_signal(SIGINT,  function() {
99
+		global $sockets;
100
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
+		die("Bye!\n");
102
+	});
103
+	pcntl_signal_dispatch();
104 104
 }
105 105
 
106 106
 // let's try and connect
@@ -110,36 +110,36 @@  discard block
 block discarded – undo
110 110
 $reset = 0;
111 111
 
112 112
 function connect_all($hosts) {
113
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
-    $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
113
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
+	$reset++;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    /*
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			/*
143 143
     	    // Disabled for now, site change source format
144 144
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
@@ -151,115 +151,115 @@  discard block
 block discarded – undo
151 151
         	    exit(0);
152 152
         	}
153 153
     	    */
154
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
155
-        	//$formats[$id] = 'planeupdatefaa';
156
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
157
-        	//$last_exec['planeupdatefaa'] = 0;
158
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
159
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
-        	    exit(0);
162
-        	}
163
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
164
-        	//$formats[$id] = 'phpvmacars';
165
-        	$globalSources[$id]['format'] = 'phpvmacars';
166
-        	//$last_exec['phpvmacars'] = 0;
167
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
169
-        	//$formats[$id] = 'phpvmacars';
170
-        	$globalSources[$id]['format'] = 'vam';
171
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
-            } else if (preg_match('/whazzup/i',$host)) {
173
-        	//$formats[$id] = 'whazzup';
174
-        	$globalSources[$id]['format'] = 'whazzup';
175
-        	//$last_exec['whazzup'] = 0;
176
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
-            } else if (preg_match('/recentpireps/i',$host)) {
178
-        	//$formats[$id] = 'pirepsjson';
179
-        	$globalSources[$id]['format'] = 'pirepsjson';
180
-        	//$last_exec['pirepsjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183
-        	//$formats[$id] = 'fr24json';
184
-        	$globalSources[$id]['format'] = 'fr24json';
185
-        	//$last_exec['fr24json'] = 0;
186
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
187
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189
-        	    exit(0);
190
-        	}
191
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
192
-        	//$formats[$id] = 'fr24json';
193
-        	$globalSources[$id]['format'] = 'myshiptracking';
194
-        	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
196
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
-        	    exit(0);
199
-        	}
200
-            //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
-        	//$formats[$id] = 'tsv';
203
-        	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
-            }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
-    		    if ($idf !== false) {
210
-    			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-    		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
217
-	    if (isset($hostport[1])) {
154
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
155
+			//$formats[$id] = 'planeupdatefaa';
156
+			$globalSources[$id]['format'] = 'planeupdatefaa';
157
+			//$last_exec['planeupdatefaa'] = 0;
158
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
159
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
+				exit(0);
162
+			}
163
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
164
+			//$formats[$id] = 'phpvmacars';
165
+			$globalSources[$id]['format'] = 'phpvmacars';
166
+			//$last_exec['phpvmacars'] = 0;
167
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
169
+			//$formats[$id] = 'phpvmacars';
170
+			$globalSources[$id]['format'] = 'vam';
171
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
+			} else if (preg_match('/whazzup/i',$host)) {
173
+			//$formats[$id] = 'whazzup';
174
+			$globalSources[$id]['format'] = 'whazzup';
175
+			//$last_exec['whazzup'] = 0;
176
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
+			} else if (preg_match('/recentpireps/i',$host)) {
178
+			//$formats[$id] = 'pirepsjson';
179
+			$globalSources[$id]['format'] = 'pirepsjson';
180
+			//$last_exec['pirepsjson'] = 0;
181
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183
+			//$formats[$id] = 'fr24json';
184
+			$globalSources[$id]['format'] = 'fr24json';
185
+			//$last_exec['fr24json'] = 0;
186
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
187
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189
+				exit(0);
190
+			}
191
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
192
+			//$formats[$id] = 'fr24json';
193
+			$globalSources[$id]['format'] = 'myshiptracking';
194
+			//$last_exec['fr24json'] = 0;
195
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
196
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
+				exit(0);
199
+			}
200
+			//} else if (preg_match('/10001/',$host)) {
201
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
+			//$formats[$id] = 'tsv';
203
+			$globalSources[$id]['format'] = 'tsv';
204
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
+			}
206
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
+				if ($idf !== false) {
210
+				$httpfeeds[$id] = $idf;
211
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+				}
213
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
+		$hostport = explode(':',$host);
217
+		if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
220
-	    } else {
220
+		} else {
221 221
 		$port = $globalSources[$id]['port'];
222 222
 		$hostn = $globalSources[$id]['host'];
223
-	    }
224
-	    $Common = new Common();
225
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
227
-    	    } else {
228
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
229
-	    }
230
-	    if ($s) {
231
-    	        $sockets[$id] = $s;
232
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
223
+		}
224
+		$Common = new Common();
225
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
227
+			} else {
228
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
229
+		}
230
+		if ($s) {
231
+				$sockets[$id] = $s;
232
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
234 234
 			//$formats[$id] = 'aprs';
235 235
 			$globalSources[$id]['format'] = 'aprs';
236 236
 			//$aprs_connect = 0;
237 237
 			//$use_aprs = true;
238
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
238
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
239 239
 			$globalSources[$id]['format'] = 'vrstcp';
240
-    		    } elseif ($port == '10001') {
241
-        		//$formats[$id] = 'tsv';
242
-        		$globalSources[$id]['format'] = 'tsv';
243
-		    } elseif ($port == '30002') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'raw';
246
-		    } elseif ($port == '5001') {
247
-        		//$formats[$id] = 'raw';
248
-        		$globalSources[$id]['format'] = 'flightgearmp';
249
-		    } elseif ($port == '30005') {
240
+				} elseif ($port == '10001') {
241
+				//$formats[$id] = 'tsv';
242
+				$globalSources[$id]['format'] = 'tsv';
243
+			} elseif ($port == '30002') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'raw';
246
+			} elseif ($port == '5001') {
247
+				//$formats[$id] = 'raw';
248
+				$globalSources[$id]['format'] = 'flightgearmp';
249
+			} elseif ($port == '30005') {
250 250
 			// Not yet supported
251
-        		//$formats[$id] = 'beast';
252
-        		$globalSources[$id]['format'] = 'beast';
253
-		    //} else $formats[$id] = 'sbs';
254
-		    } else $globalSources[$id]['format'] = 'sbs';
255
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
251
+				//$formats[$id] = 'beast';
252
+				$globalSources[$id]['format'] = 'beast';
253
+			//} else $formats[$id] = 'sbs';
254
+			} else $globalSources[$id]['format'] = 'sbs';
255
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256 256
 		}
257 257
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
258
-            } else {
258
+			} else {
259 259
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
260
-    	    }
261
-        }
262
-    }
260
+			}
261
+		}
262
+	}
263 263
 }
264 264
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
265 265
 
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 //connect_all($globalSources);
283 283
 
284 284
 if (isset($globalProxy) && $globalProxy) {
285
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
285
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
286 286
 } else {
287
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
287
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
288 288
 }
289 289
 
290 290
 // APRS Configuration
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
 	die;
294 294
 }
295 295
 foreach ($globalSources as $key => $source) {
296
-    if (!isset($source['format'])) {
297
-        $globalSources[$key]['format'] = 'auto';
298
-    }
296
+	if (!isset($source['format'])) {
297
+		$globalSources[$key]['format'] = 'auto';
298
+	}
299 299
 }
300 300
 connect_all($globalSources);
301 301
 foreach ($globalSources as $key => $source) {
302
-    if (isset($source['format']) && $source['format'] == 'aprs') {
302
+	if (isset($source['format']) && $source['format'] == 'aprs') {
303 303
 	$aprs_connect = 0;
304 304
 	$use_aprs = true;
305 305
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
306 306
 	break;
307
-    }
307
+	}
308 308
 }
309 309
 
310 310
 if ($use_aprs) {
@@ -345,116 +345,116 @@  discard block
 block discarded – undo
345 345
 
346 346
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 347
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
349
-    // Delete old ATC
350
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
+	if (!$globalDaemon) $i = $endtime-time();
349
+	// Delete old ATC
350
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
352
-        $ATC->deleteOldATC();
353
-    }
352
+		$ATC->deleteOldATC();
353
+	}
354 354
     
355
-    //if (count($last_exec) > 0) {
356
-    if (count($last_exec) == count($globalSources)) {
355
+	//if (count($last_exec) > 0) {
356
+	if (count($last_exec) == count($globalSources)) {
357 357
 	$max = $globalMinFetch;
358 358
 	foreach ($last_exec as $last) {
359
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
359
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
360 360
 	}
361 361
 	if ($max != $globalMinFetch) {
362
-	    if ($globalDebug) echo 'Sleeping...'."\n";
363
-	    sleep($globalMinFetch-$max+2);
362
+		if ($globalDebug) echo 'Sleeping...'."\n";
363
+		sleep($globalMinFetch-$max+2);
364
+	}
364 365
 	}
365
-    }
366 366
 
367 367
     
368
-    //foreach ($formats as $id => $value) {
369
-    foreach ($globalSources as $id => $value) {
368
+	//foreach ($formats as $id => $value) {
369
+	foreach ($globalSources as $id => $value) {
370 370
 	date_default_timezone_set('UTC');
371 371
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
372 372
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
373
-	    //$buffer = $Common->getData($hosts[$id]);
374
-	    $buffer = $Common->getData($value['host']);
375
-	    if ($buffer != '') $reset = 0;
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    foreach ($buffer as $line) {
379
-    		if ($line != '' && count($line) > 7) {
380
-    		    $line = explode(',', $line);
381
-	            $data = array();
382
-	            $data['hex'] = $line[1]; // hex
383
-	            $data['ident'] = $line[2]; // ident
384
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
389
-	            $data['verticalrate'] = ''; // vertical rate
390
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391
-	            $data['emergency'] = ''; // emergency
392
-		    $data['datetime'] = date('Y-m-d H:i:s');
393
-		    $data['format_source'] = 'deltadbtxt';
394
-    		    $data['id_source'] = $id_source;
395
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
398
-    		    $SI->add($data);
399
-		    unset($data);
400
-    		}
401
-    	    }
402
-    	    $last_exec[$id]['last'] = time();
373
+		//$buffer = $Common->getData($hosts[$id]);
374
+		$buffer = $Common->getData($value['host']);
375
+		if ($buffer != '') $reset = 0;
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		foreach ($buffer as $line) {
379
+			if ($line != '' && count($line) > 7) {
380
+				$line = explode(',', $line);
381
+				$data = array();
382
+				$data['hex'] = $line[1]; // hex
383
+				$data['ident'] = $line[2]; // ident
384
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
389
+				$data['verticalrate'] = ''; // vertical rate
390
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391
+				$data['emergency'] = ''; // emergency
392
+			$data['datetime'] = date('Y-m-d H:i:s');
393
+			$data['format_source'] = 'deltadbtxt';
394
+				$data['id_source'] = $id_source;
395
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
398
+				$SI->add($data);
399
+			unset($data);
400
+			}
401
+			}
402
+			$last_exec[$id]['last'] = time();
403 403
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
404
-	    date_default_timezone_set('CET');
405
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406
-	    date_default_timezone_set('UTC');
407
-	    if ($buffer != '') $reset = 0;
408
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
-	    $buffer = explode('\n',$buffer);
410
-	    foreach ($buffer as $line) {
404
+		date_default_timezone_set('CET');
405
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406
+		date_default_timezone_set('UTC');
407
+		if ($buffer != '') $reset = 0;
408
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
+		$buffer = explode('\n',$buffer);
410
+		foreach ($buffer as $line) {
411 411
 		if ($line != '') {
412
-		    echo "'".$line."'\n";
413
-		    $add = false;
414
-		    $ais_data = $AIS->parse_line(trim($line));
415
-		    $data = array();
416
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426
-		    if (isset($ais_data['timestamp'])) {
412
+			echo "'".$line."'\n";
413
+			$add = false;
414
+			$ais_data = $AIS->parse_line(trim($line));
415
+			$data = array();
416
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426
+			if (isset($ais_data['timestamp'])) {
427 427
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
428 428
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
429
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430
-			    $add = true;
429
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430
+				$add = true;
431 431
 			}
432
-		    } else {
432
+			} else {
433 433
 			$data['datetime'] = date('Y-m-d H:i:s');
434 434
 			$add = true;
435
-		    }
436
-		    $data['format_source'] = 'aisnmeatxt';
437
-    		    $data['id_source'] = $id_source;
438
-		    //print_r($data);
439
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
441
-		    unset($data);
435
+			}
436
+			$data['format_source'] = 'aisnmeatxt';
437
+				$data['id_source'] = $id_source;
438
+			//print_r($data);
439
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
441
+			unset($data);
442 442
 		}
443
-    	    }
444
-    	    $last_exec[$id]['last'] = time();
443
+			}
444
+			$last_exec[$id]['last'] = time();
445 445
 	} elseif ($value['format'] == 'aisnmeahttp') {
446
-	    $arr = $httpfeeds;
447
-	    $w = $e = null;
446
+		$arr = $httpfeeds;
447
+		$w = $e = null;
448 448
 	    
449
-	    if (isset($arr[$id])) {
449
+		if (isset($arr[$id])) {
450 450
 		$nn = stream_select($arr,$w,$e,$timeout);
451 451
 		if ($nn > 0) {
452
-		    foreach ($httpfeeds as $feed) {
452
+			foreach ($httpfeeds as $feed) {
453 453
 			$buffer = stream_get_line($feed,2000,"\n");
454 454
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455 455
 			$buffer = explode('\n',$buffer);
456 456
 			foreach ($buffer as $line) {
457
-			    if ($line != '') {
457
+				if ($line != '') {
458 458
 				$ais_data = $AIS->parse_line(trim($line));
459 459
 				$data = array();
460 460
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -472,40 +472,40 @@  discard block
 block discarded – undo
472 472
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473 473
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
474 474
 				if (isset($ais_data['timestamp'])) {
475
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
475
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
476 476
 				} else {
477
-				    $data['datetime'] = date('Y-m-d H:i:s');
477
+					$data['datetime'] = date('Y-m-d H:i:s');
478 478
 				}
479 479
 				$data['format_source'] = 'aisnmeahttp';
480 480
 				$data['id_source'] = $id_source;
481 481
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482 482
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
483 483
 				unset($data);
484
-			    }
484
+				}
485
+			}
485 486
 			}
486
-		    }
487 487
 		} else {
488
-		    $format = $value['format'];
489
-		    if (isset($tt[$format])) $tt[$format]++;
490
-		    else $tt[$format] = 0;
491
-		    if ($tt[$format] > 30) {
488
+			$format = $value['format'];
489
+			if (isset($tt[$format])) $tt[$format]++;
490
+			else $tt[$format] = 0;
491
+			if ($tt[$format] > 30) {
492 492
 			if ($globalDebug) echo 'Reconnect...'."\n";
493 493
 			sleep(2);
494 494
 			$sourceeen[] = $value;
495 495
 			connect_all($sourceeen);
496 496
 			$sourceeen = array();
497
-		    }
497
+			}
498
+		}
498 499
 		}
499
-	    }
500 500
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
501
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
502
-	    if ($buffer != '') {
501
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
502
+		if ($buffer != '') {
503 503
 		//echo $buffer;
504 504
 		$all_data = json_decode($buffer,true);
505 505
 		//print_r($all_data);
506 506
 		if (isset($all_data[0]['DATA'])) {
507 507
 		foreach ($all_data[0]['DATA'] as $line) {
508
-		    if ($line != '') {
508
+			if ($line != '') {
509 509
 			$data = array();
510 510
 			$data['ident'] = $line['NAME'];
511 511
 			$data['mmsi'] = $line['MMSI'];
@@ -522,89 +522,89 @@  discard block
 block discarded – undo
522 522
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
523 523
 			$MI->add($data);
524 524
 			unset($data);
525
-		    }
525
+			}
526 526
 		}
527 527
 		}
528 528
 		
529
-	    }
530
-    	    $last_exec[$id]['last'] = time();
529
+		}
530
+			$last_exec[$id]['last'] = time();
531 531
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
532
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
533
-	    if ($buffer != '') {
532
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
533
+		if ($buffer != '') {
534 534
 		$all_data = json_decode($buffer,true);
535 535
 		if (isset($all_data[0]['mmsi'])) {
536
-		    foreach ($all_data as $line) {
536
+			foreach ($all_data as $line) {
537 537
 			if ($line != '') {
538
-			    $data = array();
539
-			    $data['ident'] = $line['shipname'];
540
-			    $data['callsign'] = $line['callsign'];
541
-			    $data['mmsi'] = $line['mmsi'];
542
-			    $data['speed'] = $line['sog'];
543
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
544
-			    $data['latitude'] = $line['latitude'];
545
-			    $data['longitude'] = $line['longitude'];
546
-			    $data['type_id'] = $line['shiptype'];
547
-			    $data['arrival_code'] = $line['destination'];
548
-			    $data['datetime'] = $line['time'];
549
-			    $data['format_source'] = 'boatbeaconapp';
550
-			    $data['id_source'] = $id_source;
551
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
552
-			    $MI->add($data);
553
-			    unset($data);
538
+				$data = array();
539
+				$data['ident'] = $line['shipname'];
540
+				$data['callsign'] = $line['callsign'];
541
+				$data['mmsi'] = $line['mmsi'];
542
+				$data['speed'] = $line['sog'];
543
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
544
+				$data['latitude'] = $line['latitude'];
545
+				$data['longitude'] = $line['longitude'];
546
+				$data['type_id'] = $line['shiptype'];
547
+				$data['arrival_code'] = $line['destination'];
548
+				$data['datetime'] = $line['time'];
549
+				$data['format_source'] = 'boatbeaconapp';
550
+				$data['id_source'] = $id_source;
551
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
552
+				$MI->add($data);
553
+				unset($data);
554
+			}
554 555
 			}
555
-		    }
556 556
 		}
557 557
 		
558
-	    }
559
-    	    $last_exec[$id]['last'] = time();
558
+		}
559
+			$last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
561
-	    echo 'download...';
562
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
563
-	    echo 'done !'."\n";
564
-	    if ($buffer != '') $reset = 0;
565
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
566
-	    $buffer = explode('\n',$buffer);
567
-	    foreach ($buffer as $line) {
561
+		echo 'download...';
562
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
563
+		echo 'done !'."\n";
564
+		if ($buffer != '') $reset = 0;
565
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
566
+		$buffer = explode('\n',$buffer);
567
+		foreach ($buffer as $line) {
568 568
 		if ($line != '') {
569
-		    $data = array();
570
-		    $data['mmsi'] = (int)substr($line,0,9);
571
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
572
-		    //$data['status'] = substr($line,21,2);
573
-		    //$data['type'] = substr($line,24,3);
574
-		    $data['latitude'] = substr($line,29,9);
575
-		    $data['longitude'] = substr($line,41,9);
576
-		    $data['speed'] = round(substr($line,51,5));
577
-		    //$data['course'] = substr($line,57,5);
578
-		    $data['heading'] = round(substr($line,63,3));
579
-		    //$data['draft'] = substr($line,67,4);
580
-		    //$data['length'] = substr($line,72,3);
581
-		    //$data['beam'] = substr($line,76,2);
582
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
583
-		    //$data['callsign'] = trim(substr($line,100,7);
584
-		    //$data['dest'] = substr($line,108,20);
585
-		    //$data['etaDate'] = substr($line,129,5);
586
-		    //$data['etaTime'] = substr($line,135,5);
587
-		    $data['format_source'] = 'shipplotter';
588
-    		    $data['id_source'] = $id_source;
589
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
590
-		    //print_r($data);
591
-		    echo 'Add...'."\n";
592
-		    $MI->add($data);
593
-		    unset($data);
569
+			$data = array();
570
+			$data['mmsi'] = (int)substr($line,0,9);
571
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
572
+			//$data['status'] = substr($line,21,2);
573
+			//$data['type'] = substr($line,24,3);
574
+			$data['latitude'] = substr($line,29,9);
575
+			$data['longitude'] = substr($line,41,9);
576
+			$data['speed'] = round(substr($line,51,5));
577
+			//$data['course'] = substr($line,57,5);
578
+			$data['heading'] = round(substr($line,63,3));
579
+			//$data['draft'] = substr($line,67,4);
580
+			//$data['length'] = substr($line,72,3);
581
+			//$data['beam'] = substr($line,76,2);
582
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
583
+			//$data['callsign'] = trim(substr($line,100,7);
584
+			//$data['dest'] = substr($line,108,20);
585
+			//$data['etaDate'] = substr($line,129,5);
586
+			//$data['etaTime'] = substr($line,135,5);
587
+			$data['format_source'] = 'shipplotter';
588
+				$data['id_source'] = $id_source;
589
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
590
+			//print_r($data);
591
+			echo 'Add...'."\n";
592
+			$MI->add($data);
593
+			unset($data);
594 594
 		}
595
-    	    }
596
-    	    $last_exec[$id]['last'] = time();
595
+			}
596
+			$last_exec[$id]['last'] = time();
597 597
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
598 598
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
599
-	    //$buffer = $Common->getData($hosts[$id]);
600
-	    $buffer = $Common->getData($value['host']);
601
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
602
-	    $buffer = explode('\n',$buffer);
603
-	    $reset = 0;
604
-	    foreach ($buffer as $line) {
605
-    		if ($line != '') {
606
-    		    $line = explode(':', $line);
607
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
599
+		//$buffer = $Common->getData($hosts[$id]);
600
+		$buffer = $Common->getData($value['host']);
601
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
602
+		$buffer = explode('\n',$buffer);
603
+		$reset = 0;
604
+		foreach ($buffer as $line) {
605
+			if ($line != '') {
606
+				$line = explode(':', $line);
607
+				if (count($line) > 30 && $line[0] != 'callsign') {
608 608
 			$data = array();
609 609
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
610 610
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -617,37 +617,37 @@  discard block
 block discarded – undo
617 617
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
618 618
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
619 619
 			$data['latitude'] = $line[5]; // lat
620
-	        	$data['longitude'] = $line[6]; // long
621
-	        	$data['verticalrate'] = ''; // vertical rate
622
-	        	$data['squawk'] = ''; // squawk
623
-	        	$data['emergency'] = ''; // emergency
624
-	        	$data['waypoints'] = $line[30];
620
+				$data['longitude'] = $line[6]; // long
621
+				$data['verticalrate'] = ''; // vertical rate
622
+				$data['squawk'] = ''; // squawk
623
+				$data['emergency'] = ''; // emergency
624
+				$data['waypoints'] = $line[30];
625 625
 			$data['datetime'] = date('Y-m-d H:i:s');
626 626
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
627 627
 			//if (isset($line[37])) $data['last_update'] = $line[37];
628
-		        $data['departure_airport_icao'] = $line[11];
629
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
630
-		        $data['arrival_airport_icao'] = $line[13];
628
+				$data['departure_airport_icao'] = $line[11];
629
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
630
+				$data['arrival_airport_icao'] = $line[13];
631 631
 			$data['frequency'] = $line[4];
632 632
 			$data['type'] = $line[18];
633 633
 			$data['range'] = $line[19];
634 634
 			if (isset($line[35])) $data['info'] = $line[35];
635
-    			$data['id_source'] = $id_source;
636
-	    		//$data['arrival_airport_time'] = ;
637
-	    		if ($line[9] != '') {
638
-	    		    $aircraft_data = explode('/',$line[9]);
639
-	    		    if (isset($aircraft_data[1])) {
640
-	    			$data['aircraft_icao'] = $aircraft_data[1];
641
-	    		    }
642
-        		}
643
-	    		/*
635
+				$data['id_source'] = $id_source;
636
+				//$data['arrival_airport_time'] = ;
637
+				if ($line[9] != '') {
638
+					$aircraft_data = explode('/',$line[9]);
639
+					if (isset($aircraft_data[1])) {
640
+					$data['aircraft_icao'] = $aircraft_data[1];
641
+					}
642
+				}
643
+				/*
644 644
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
645 645
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
646 646
 	    		*/
647
-	    		$data['format_source'] = $value['format'];
647
+				$data['format_source'] = $value['format'];
648 648
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649 649
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
650
-    			if ($line[3] == 'PILOT') $SI->add($data);
650
+				if ($line[3] == 'PILOT') $SI->add($data);
651 651
 			elseif ($line[3] == 'ATC') {
652 652
 				//print_r($data);
653 653
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -665,255 +665,255 @@  discard block
 block discarded – undo
665 665
 				if (!isset($data['source_name'])) $data['source_name'] = '';
666 666
 				if (isset($ATC)) 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']);
667 667
 			}
668
-    			unset($data);
669
-    		    }
670
-    		}
671
-    	    }
672
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
673
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
674
-    	    $last_exec[$id]['last'] = time();
675
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
676
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
677
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
678
-	    if ($buffer != '') {
679
-	    $all_data = json_decode($buffer,true);
680
-	    if (isset($all_data['acList'])) {
668
+				unset($data);
669
+				}
670
+			}
671
+			}
672
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
673
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
674
+			$last_exec[$id]['last'] = time();
675
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
676
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
677
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
678
+		if ($buffer != '') {
679
+		$all_data = json_decode($buffer,true);
680
+		if (isset($all_data['acList'])) {
681 681
 		$reset = 0;
682 682
 		foreach ($all_data['acList'] as $line) {
683
-		    $data = array();
684
-		    $data['hex'] = $line['Icao']; // hex
685
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
686
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
687
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
688
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
689
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
690
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
691
-		    //$data['verticalrate'] = $line['']; // verticale rate
692
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
693
-		    $data['emergency'] = ''; // emergency
694
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
683
+			$data = array();
684
+			$data['hex'] = $line['Icao']; // hex
685
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
686
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
687
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
688
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
689
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
690
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
691
+			//$data['verticalrate'] = $line['']; // verticale rate
692
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
693
+			$data['emergency'] = ''; // emergency
694
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
695 695
 		    
696
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
697
-		    else $data['datetime'] = date('Y-m-d H:i:s');
696
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
697
+			else $data['datetime'] = date('Y-m-d H:i:s');
698 698
 		    
699
-		    //$data['datetime'] = date('Y-m-d H:i:s');
700
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
701
-	    	    $data['format_source'] = 'aircraftlistjson';
702
-		    $data['id_source'] = $id_source;
703
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
704
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
705
-		    if (isset($data['latitude'])) $SI->add($data);
706
-		    unset($data);
699
+			//$data['datetime'] = date('Y-m-d H:i:s');
700
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
701
+				$data['format_source'] = 'aircraftlistjson';
702
+			$data['id_source'] = $id_source;
703
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
704
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
705
+			if (isset($data['latitude'])) $SI->add($data);
706
+			unset($data);
707 707
 		}
708
-	    } elseif (is_array($all_data)) {
708
+		} elseif (is_array($all_data)) {
709 709
 		$reset = 0;
710 710
 		foreach ($all_data as $line) {
711
-		    $data = array();
712
-		    $data['hex'] = $line['hex']; // hex
713
-		    $data['ident'] = $line['flight']; // ident
714
-		    $data['altitude'] = $line['altitude']; // altitude
715
-		    $data['speed'] = $line['speed']; // speed
716
-		    $data['heading'] = $line['track']; // heading
717
-		    $data['latitude'] = $line['lat']; // lat
718
-		    $data['longitude'] = $line['lon']; // long
719
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
720
-		    $data['squawk'] = $line['squawk']; // squawk
721
-		    $data['emergency'] = ''; // emergency
722
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
723
-		    else $data['datetime'] = date('Y-m-d H:i:s');
724
-	    	    $data['format_source'] = 'aircraftlistjson';
725
-    		    $data['id_source'] = $id_source;
726
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
728
-		    $SI->add($data);
729
-		    unset($data);
711
+			$data = array();
712
+			$data['hex'] = $line['hex']; // hex
713
+			$data['ident'] = $line['flight']; // ident
714
+			$data['altitude'] = $line['altitude']; // altitude
715
+			$data['speed'] = $line['speed']; // speed
716
+			$data['heading'] = $line['track']; // heading
717
+			$data['latitude'] = $line['lat']; // lat
718
+			$data['longitude'] = $line['lon']; // long
719
+			$data['verticalrate'] = $line['vrt']; // verticale rate
720
+			$data['squawk'] = $line['squawk']; // squawk
721
+			$data['emergency'] = ''; // emergency
722
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
723
+			else $data['datetime'] = date('Y-m-d H:i:s');
724
+				$data['format_source'] = 'aircraftlistjson';
725
+				$data['id_source'] = $id_source;
726
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
728
+			$SI->add($data);
729
+			unset($data);
730
+		}
730 731
 		}
731
-	    }
732
-	    }
733
-    	    //$last_exec['aircraftlistjson'] = time();
734
-    	    $last_exec[$id]['last'] = time();
735
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
736
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
737
-	    $buffer = $Common->getData($value['host']);
738
-	    $all_data = json_decode($buffer,true);
739
-	    if (isset($all_data['planes'])) {
732
+		}
733
+			//$last_exec['aircraftlistjson'] = time();
734
+			$last_exec[$id]['last'] = time();
735
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
736
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
737
+		$buffer = $Common->getData($value['host']);
738
+		$all_data = json_decode($buffer,true);
739
+		if (isset($all_data['planes'])) {
740 740
 		$reset = 0;
741 741
 		foreach ($all_data['planes'] as $key => $line) {
742
-		    $data = array();
743
-		    $data['hex'] = $key; // hex
744
-		    $data['ident'] = $line[3]; // ident
745
-		    $data['altitude'] = $line[6]; // altitude
746
-		    $data['speed'] = $line[8]; // speed
747
-		    $data['heading'] = $line[7]; // heading
748
-		    $data['latitude'] = $line[4]; // lat
749
-		    $data['longitude'] = $line[5]; // long
750
-		    //$data['verticalrate'] = $line[]; // verticale rate
751
-		    $data['squawk'] = $line[10]; // squawk
752
-		    $data['emergency'] = ''; // emergency
753
-		    $data['registration'] = $line[2];
754
-		    $data['aircraft_icao'] = $line[0];
755
-		    $deparr = explode('-',$line[1]);
756
-		    if (count($deparr) == 2) {
742
+			$data = array();
743
+			$data['hex'] = $key; // hex
744
+			$data['ident'] = $line[3]; // ident
745
+			$data['altitude'] = $line[6]; // altitude
746
+			$data['speed'] = $line[8]; // speed
747
+			$data['heading'] = $line[7]; // heading
748
+			$data['latitude'] = $line[4]; // lat
749
+			$data['longitude'] = $line[5]; // long
750
+			//$data['verticalrate'] = $line[]; // verticale rate
751
+			$data['squawk'] = $line[10]; // squawk
752
+			$data['emergency'] = ''; // emergency
753
+			$data['registration'] = $line[2];
754
+			$data['aircraft_icao'] = $line[0];
755
+			$deparr = explode('-',$line[1]);
756
+			if (count($deparr) == 2) {
757 757
 			$data['departure_airport_icao'] = $deparr[0];
758 758
 			$data['arrival_airport_icao'] = $deparr[1];
759
-		    }
760
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
761
-	    	    $data['format_source'] = 'planeupdatefaa';
762
-    		    $data['id_source'] = $id_source;
763
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
764
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
765
-		    $SI->add($data);
766
-		    unset($data);
759
+			}
760
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
761
+				$data['format_source'] = 'planeupdatefaa';
762
+				$data['id_source'] = $id_source;
763
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
764
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
765
+			$SI->add($data);
766
+			unset($data);
767 767
 		}
768
-	    }
769
-    	    //$last_exec['planeupdatefaa'] = time();
770
-    	    $last_exec[$id]['last'] = time();
771
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
772
-	    $buffer = $Common->getData($value['host']);
773
-	    $all_data = json_decode($buffer,true);
774
-	    if (isset($all_data['states'])) {
768
+		}
769
+			//$last_exec['planeupdatefaa'] = time();
770
+			$last_exec[$id]['last'] = time();
771
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
772
+		$buffer = $Common->getData($value['host']);
773
+		$all_data = json_decode($buffer,true);
774
+		if (isset($all_data['states'])) {
775 775
 		$reset = 0;
776 776
 		foreach ($all_data['states'] as $key => $line) {
777
-		    $data = array();
778
-		    $data['hex'] = $line[0]; // hex
779
-		    $data['ident'] = trim($line[1]); // ident
780
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
781
-		    $data['speed'] = round($line[9]*1.94384); // speed
782
-		    $data['heading'] = round($line[10]); // heading
783
-		    $data['latitude'] = $line[6]; // lat
784
-		    $data['longitude'] = $line[5]; // long
785
-		    $data['verticalrate'] = $line[11]; // verticale rate
786
-		    //$data['squawk'] = $line[10]; // squawk
787
-		    //$data['emergency'] = ''; // emergency
788
-		    //$data['registration'] = $line[2];
789
-		    //$data['aircraft_icao'] = $line[0];
790
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
791
-	    	    $data['format_source'] = 'opensky';
792
-    		    $data['id_source'] = $id_source;
793
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
794
-		    $SI->add($data);
795
-		    unset($data);
777
+			$data = array();
778
+			$data['hex'] = $line[0]; // hex
779
+			$data['ident'] = trim($line[1]); // ident
780
+			$data['altitude'] = round($line[7]*3.28084); // altitude
781
+			$data['speed'] = round($line[9]*1.94384); // speed
782
+			$data['heading'] = round($line[10]); // heading
783
+			$data['latitude'] = $line[6]; // lat
784
+			$data['longitude'] = $line[5]; // long
785
+			$data['verticalrate'] = $line[11]; // verticale rate
786
+			//$data['squawk'] = $line[10]; // squawk
787
+			//$data['emergency'] = ''; // emergency
788
+			//$data['registration'] = $line[2];
789
+			//$data['aircraft_icao'] = $line[0];
790
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
791
+				$data['format_source'] = 'opensky';
792
+				$data['id_source'] = $id_source;
793
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
794
+			$SI->add($data);
795
+			unset($data);
796
+		}
796 797
 		}
797
-	    }
798
-    	    //$last_exec['planeupdatefaa'] = time();
799
-    	    $last_exec[$id]['last'] = time();
800
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
801
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
802
-	    //$buffer = $Common->getData($hosts[$id]);
803
-	    $buffer = $Common->getData($value['host']);
804
-	    $all_data = json_decode($buffer,true);
805
-	    if (!empty($all_data)) $reset = 0;
806
-	    foreach ($all_data as $key => $line) {
798
+			//$last_exec['planeupdatefaa'] = time();
799
+			$last_exec[$id]['last'] = time();
800
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
801
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
802
+		//$buffer = $Common->getData($hosts[$id]);
803
+		$buffer = $Common->getData($value['host']);
804
+		$all_data = json_decode($buffer,true);
805
+		if (!empty($all_data)) $reset = 0;
806
+		foreach ($all_data as $key => $line) {
807 807
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
808
-		    $data = array();
809
-		    $data['hex'] = $line[0];
810
-		    $data['ident'] = $line[16]; //$line[13]
811
-	    	    $data['altitude'] = $line[4]; // altitude
812
-	    	    $data['speed'] = $line[5]; // speed
813
-	    	    $data['heading'] = $line[3]; // heading
814
-	    	    $data['latitude'] = $line[1]; // lat
815
-	    	    $data['longitude'] = $line[2]; // long
816
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
817
-	    	    $data['squawk'] = $line[6]; // squawk
818
-	    	    $data['aircraft_icao'] = $line[8];
819
-	    	    $data['registration'] = $line[9];
820
-		    $data['departure_airport_iata'] = $line[11];
821
-		    $data['arrival_airport_iata'] = $line[12];
822
-	    	    $data['emergency'] = ''; // emergency
823
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
824
-	    	    $data['format_source'] = 'fr24json';
825
-    		    $data['id_source'] = $id_source;
826
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
827
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
828
-		    $SI->add($data);
829
-		    unset($data);
808
+			$data = array();
809
+			$data['hex'] = $line[0];
810
+			$data['ident'] = $line[16]; //$line[13]
811
+				$data['altitude'] = $line[4]; // altitude
812
+				$data['speed'] = $line[5]; // speed
813
+				$data['heading'] = $line[3]; // heading
814
+				$data['latitude'] = $line[1]; // lat
815
+				$data['longitude'] = $line[2]; // long
816
+				$data['verticalrate'] = $line[15]; // verticale rate
817
+				$data['squawk'] = $line[6]; // squawk
818
+				$data['aircraft_icao'] = $line[8];
819
+				$data['registration'] = $line[9];
820
+			$data['departure_airport_iata'] = $line[11];
821
+			$data['arrival_airport_iata'] = $line[12];
822
+				$data['emergency'] = ''; // emergency
823
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
824
+				$data['format_source'] = 'fr24json';
825
+				$data['id_source'] = $id_source;
826
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
827
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
828
+			$SI->add($data);
829
+			unset($data);
830
+		}
830 831
 		}
831
-	    }
832
-    	    //$last_exec['fr24json'] = time();
833
-    	    $last_exec[$id]['last'] = time();
834
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
835
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
836
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
837
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
838
-	    //echo $buffer;
839
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
840
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
841
-	    $all_data = json_decode($buffer,true);
842
-	    if (json_last_error() != JSON_ERROR_NONE) {
832
+			//$last_exec['fr24json'] = time();
833
+			$last_exec[$id]['last'] = time();
834
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
835
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
836
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
837
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
838
+		//echo $buffer;
839
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
840
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
841
+		$all_data = json_decode($buffer,true);
842
+		if (json_last_error() != JSON_ERROR_NONE) {
843 843
 		die(json_last_error_msg());
844
-	    }
845
-	    if (isset($all_data['mrkrs'])) {
844
+		}
845
+		if (isset($all_data['mrkrs'])) {
846 846
 		$reset = 0;
847 847
 		foreach ($all_data['mrkrs'] as $key => $line) {
848
-		    if (isset($line['inf'])) {
848
+			if (isset($line['inf'])) {
849 849
 			$data = array();
850 850
 			$data['hex'] = $line['inf']['ia'];
851 851
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
852
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
853
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
854
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
855
-	    		$data['latitude'] = $line['pt'][0]; // lat
856
-	    		$data['longitude'] = $line['pt'][1]; // long
857
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
858
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
859
-	    		//$data['aircraft_icao'] = $line[8];
860
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
852
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
853
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
854
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
855
+				$data['latitude'] = $line['pt'][0]; // lat
856
+				$data['longitude'] = $line['pt'][1]; // long
857
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
858
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
859
+				//$data['aircraft_icao'] = $line[8];
860
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
861 861
 			//$data['departure_airport_iata'] = $line[11];
862 862
 			//$data['arrival_airport_iata'] = $line[12];
863
-	    		//$data['emergency'] = ''; // emergency
863
+				//$data['emergency'] = ''; // emergency
864 864
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
865
-	    		$data['format_source'] = 'radarvirtueljson';
866
-    			$data['id_source'] = $id_source;
865
+				$data['format_source'] = 'radarvirtueljson';
866
+				$data['id_source'] = $id_source;
867 867
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
868 868
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
869 869
 			$SI->add($data);
870 870
 			unset($data);
871
-		    }
871
+			}
872
+		}
872 873
 		}
873
-	    }
874
-    	    //$last_exec['radarvirtueljson'] = time();
875
-    	    $last_exec[$id]['last'] = time();
876
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
877
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
878
-	    //$buffer = $Common->getData($hosts[$id]);
879
-	    $buffer = $Common->getData($value['host'].'?'.time());
880
-	    $all_data = json_decode(utf8_encode($buffer),true);
874
+			//$last_exec['radarvirtueljson'] = time();
875
+			$last_exec[$id]['last'] = time();
876
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
877
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
878
+		//$buffer = $Common->getData($hosts[$id]);
879
+		$buffer = $Common->getData($value['host'].'?'.time());
880
+		$all_data = json_decode(utf8_encode($buffer),true);
881 881
 	    
882
-	    if (isset($all_data['pireps'])) {
882
+		if (isset($all_data['pireps'])) {
883 883
 		$reset = 0;
884
-	        foreach ($all_data['pireps'] as $line) {
885
-		    $data = array();
886
-		    $data['id'] = $line['id'];
887
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
888
-		    $data['ident'] = $line['callsign']; // ident
889
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
890
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
891
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
892
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
893
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
894
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
895
-		    $data['latitude'] = $line['lat']; // lat
896
-		    $data['longitude'] = $line['lon']; // long
897
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
898
-		    //$data['squawk'] = $line['squawk']; // squawk
899
-		    //$data['emergency'] = ''; // emergency
900
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
901
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
902
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
903
-		    //$data['arrival_airport_time'] = $line['arrtime'];
904
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
905
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
906
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
907
-		    else $data['info'] = '';
908
-		    $data['format_source'] = 'pireps';
909
-    		    $data['id_source'] = $id_source;
910
-		    $data['datetime'] = date('Y-m-d H:i:s');
911
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
912
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
913
-		    if ($line['icon'] == 'plane') {
884
+			foreach ($all_data['pireps'] as $line) {
885
+			$data = array();
886
+			$data['id'] = $line['id'];
887
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
888
+			$data['ident'] = $line['callsign']; // ident
889
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
890
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
891
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
892
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
893
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
894
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
895
+			$data['latitude'] = $line['lat']; // lat
896
+			$data['longitude'] = $line['lon']; // long
897
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
898
+			//$data['squawk'] = $line['squawk']; // squawk
899
+			//$data['emergency'] = ''; // emergency
900
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
901
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
902
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
903
+			//$data['arrival_airport_time'] = $line['arrtime'];
904
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
905
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
906
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
907
+			else $data['info'] = '';
908
+			$data['format_source'] = 'pireps';
909
+				$data['id_source'] = $id_source;
910
+			$data['datetime'] = date('Y-m-d H:i:s');
911
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
912
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
913
+			if ($line['icon'] == 'plane') {
914 914
 			$SI->add($data);
915
-		    //    print_r($data);
916
-    		    } elseif ($line['icon'] == 'ct') {
915
+			//    print_r($data);
916
+				} elseif ($line['icon'] == 'ct') {
917 917
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
918 918
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
919 919
 			$typec = substr($data['ident'],-3);
@@ -928,199 +928,199 @@  discard block
 block discarded – undo
928 928
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
929 929
 			else $data['type'] = 'Observer';
930 930
 			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']);
931
-		    }
932
-		    unset($data);
931
+			}
932
+			unset($data);
933
+		}
933 934
 		}
934
-	    }
935
-    	    //$last_exec['pirepsjson'] = time();
936
-    	    $last_exec[$id]['last'] = time();
937
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
938
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
939
-	    //$buffer = $Common->getData($hosts[$id]);
940
-	    if ($globalDebug) echo 'Get Data...'."\n";
941
-	    $buffer = $Common->getData($value['host']);
942
-	    $all_data = json_decode($buffer,true);
943
-	    if ($buffer != '' && is_array($all_data)) {
935
+			//$last_exec['pirepsjson'] = time();
936
+			$last_exec[$id]['last'] = time();
937
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
938
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
939
+		//$buffer = $Common->getData($hosts[$id]);
940
+		if ($globalDebug) echo 'Get Data...'."\n";
941
+		$buffer = $Common->getData($value['host']);
942
+		$all_data = json_decode($buffer,true);
943
+		if ($buffer != '' && is_array($all_data)) {
944 944
 		$reset = 0;
945 945
 		foreach ($all_data as $line) {
946
-	    	    $data = array();
947
-	    	    //$data['id'] = $line['id']; // id not usable
948
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
949
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
950
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
951
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
952
-	    	    $data['ident'] = $line['flightnum']; // ident
953
-	    	    $data['altitude'] = $line['alt']; // altitude
954
-	    	    $data['speed'] = $line['gs']; // speed
955
-	    	    $data['heading'] = $line['heading']; // heading
956
-	    	    $data['latitude'] = $line['lat']; // lat
957
-	    	    $data['longitude'] = $line['lng']; // long
958
-	    	    $data['verticalrate'] = ''; // verticale rate
959
-	    	    $data['squawk'] = ''; // squawk
960
-	    	    $data['emergency'] = ''; // emergency
961
-	    	    //$data['datetime'] = $line['lastupdate'];
962
-	    	    $data['last_update'] = $line['lastupdate'];
963
-		    $data['datetime'] = date('Y-m-d H:i:s');
964
-	    	    $data['departure_airport_icao'] = $line['depicao'];
965
-	    	    $data['departure_airport_time'] = $line['deptime'];
966
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
967
-    		    $data['arrival_airport_time'] = $line['arrtime'];
968
-    		    $data['registration'] = $line['aircraft'];
969
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
970
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
971
-		    if (isset($line['aircraftname'])) {
946
+				$data = array();
947
+				//$data['id'] = $line['id']; // id not usable
948
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
949
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
950
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
951
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
952
+				$data['ident'] = $line['flightnum']; // ident
953
+				$data['altitude'] = $line['alt']; // altitude
954
+				$data['speed'] = $line['gs']; // speed
955
+				$data['heading'] = $line['heading']; // heading
956
+				$data['latitude'] = $line['lat']; // lat
957
+				$data['longitude'] = $line['lng']; // long
958
+				$data['verticalrate'] = ''; // verticale rate
959
+				$data['squawk'] = ''; // squawk
960
+				$data['emergency'] = ''; // emergency
961
+				//$data['datetime'] = $line['lastupdate'];
962
+				$data['last_update'] = $line['lastupdate'];
963
+			$data['datetime'] = date('Y-m-d H:i:s');
964
+				$data['departure_airport_icao'] = $line['depicao'];
965
+				$data['departure_airport_time'] = $line['deptime'];
966
+				$data['arrival_airport_icao'] = $line['arricao'];
967
+				$data['arrival_airport_time'] = $line['arrtime'];
968
+				$data['registration'] = $line['aircraft'];
969
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
970
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
971
+			if (isset($line['aircraftname'])) {
972 972
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
973 973
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
974
-	    		$aircraft_data = explode('-',$line['aircraftname']);
975
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
976
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
977
-	    		else {
978
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
979
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
980
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
981
-	    		}
982
-	    	    }
983
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
984
-    		    $data['id_source'] = $id_source;
985
-	    	    $data['format_source'] = 'phpvmacars';
986
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
987
-		    $SI->add($data);
988
-		    unset($data);
974
+				$aircraft_data = explode('-',$line['aircraftname']);
975
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
976
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
977
+				else {
978
+					$aircraft_data = explode(' ',$line['aircraftname']);
979
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
980
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
981
+				}
982
+				}
983
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
984
+				$data['id_source'] = $id_source;
985
+				$data['format_source'] = 'phpvmacars';
986
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
987
+			$SI->add($data);
988
+			unset($data);
989 989
 		}
990 990
 		if ($globalDebug) echo 'No more data...'."\n";
991 991
 		unset($buffer);
992 992
 		unset($all_data);
993
-	    }
994
-    	    //$last_exec['phpvmacars'] = time();
995
-    	    $last_exec[$id]['last'] = time();
996
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
997
-	    //$buffer = $Common->getData($hosts[$id]);
998
-	    if ($globalDebug) echo 'Get Data...'."\n";
999
-	    $buffer = $Common->getData($value['host']);
1000
-	    $all_data = json_decode($buffer,true);
1001
-	    if ($buffer != '' && is_array($all_data)) {
993
+		}
994
+			//$last_exec['phpvmacars'] = time();
995
+			$last_exec[$id]['last'] = time();
996
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
997
+		//$buffer = $Common->getData($hosts[$id]);
998
+		if ($globalDebug) echo 'Get Data...'."\n";
999
+		$buffer = $Common->getData($value['host']);
1000
+		$all_data = json_decode($buffer,true);
1001
+		if ($buffer != '' && is_array($all_data)) {
1002 1002
 		$reset = 0;
1003 1003
 		foreach ($all_data as $line) {
1004
-	    	    $data = array();
1005
-	    	    //$data['id'] = $line['id']; // id not usable
1006
-	    	    $data['id'] = trim($line['flight_id']);
1007
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1008
-	    	    $data['pilot_name'] = $line['pilot_name'];
1009
-	    	    $data['pilot_id'] = $line['pilot_id'];
1010
-	    	    $data['ident'] = trim($line['callsign']); // ident
1011
-	    	    $data['altitude'] = $line['altitude']; // altitude
1012
-	    	    $data['speed'] = $line['gs']; // speed
1013
-	    	    $data['heading'] = $line['heading']; // heading
1014
-	    	    $data['latitude'] = $line['latitude']; // lat
1015
-	    	    $data['longitude'] = $line['longitude']; // long
1016
-	    	    $data['verticalrate'] = ''; // verticale rate
1017
-	    	    $data['squawk'] = ''; // squawk
1018
-	    	    $data['emergency'] = ''; // emergency
1019
-	    	    //$data['datetime'] = $line['lastupdate'];
1020
-	    	    $data['last_update'] = $line['last_update'];
1021
-		    $data['datetime'] = date('Y-m-d H:i:s');
1022
-	    	    $data['departure_airport_icao'] = $line['departure'];
1023
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1024
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1025
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1026
-    		    //$data['registration'] = $line['aircraft'];
1027
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1028
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1029
-    		    $data['id_source'] = $id_source;
1030
-	    	    $data['format_source'] = 'vam';
1031
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1032
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1033
-		    $SI->add($data);
1034
-		    unset($data);
1004
+				$data = array();
1005
+				//$data['id'] = $line['id']; // id not usable
1006
+				$data['id'] = trim($line['flight_id']);
1007
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1008
+				$data['pilot_name'] = $line['pilot_name'];
1009
+				$data['pilot_id'] = $line['pilot_id'];
1010
+				$data['ident'] = trim($line['callsign']); // ident
1011
+				$data['altitude'] = $line['altitude']; // altitude
1012
+				$data['speed'] = $line['gs']; // speed
1013
+				$data['heading'] = $line['heading']; // heading
1014
+				$data['latitude'] = $line['latitude']; // lat
1015
+				$data['longitude'] = $line['longitude']; // long
1016
+				$data['verticalrate'] = ''; // verticale rate
1017
+				$data['squawk'] = ''; // squawk
1018
+				$data['emergency'] = ''; // emergency
1019
+				//$data['datetime'] = $line['lastupdate'];
1020
+				$data['last_update'] = $line['last_update'];
1021
+			$data['datetime'] = date('Y-m-d H:i:s');
1022
+				$data['departure_airport_icao'] = $line['departure'];
1023
+				//$data['departure_airport_time'] = $line['departure_time'];
1024
+				$data['arrival_airport_icao'] = $line['arrival'];
1025
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1026
+				//$data['registration'] = $line['aircraft'];
1027
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1028
+				$data['aircraft_icao'] = $line['plane_type'];
1029
+				$data['id_source'] = $id_source;
1030
+				$data['format_source'] = 'vam';
1031
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1032
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1033
+			$SI->add($data);
1034
+			unset($data);
1035 1035
 		}
1036 1036
 		if ($globalDebug) echo 'No more data...'."\n";
1037 1037
 		unset($buffer);
1038 1038
 		unset($all_data);
1039
-	    }
1040
-    	    //$last_exec['phpvmacars'] = time();
1041
-    	    $last_exec[$id]['last'] = time();
1039
+		}
1040
+			//$last_exec['phpvmacars'] = time();
1041
+			$last_exec[$id]['last'] = time();
1042 1042
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1043 1043
 	} 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') {
1044
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1045
-    	    //$last_exec[$id]['last'] = time();
1044
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1045
+			//$last_exec[$id]['last'] = time();
1046 1046
 
1047
-	    //$read = array( $sockets[$id] );
1048
-	    $read = $sockets;
1049
-	    $write = NULL;
1050
-	    $e = NULL;
1051
-	    $n = socket_select($read, $write, $e, $timeout);
1052
-	    if ($e != NULL) var_dump($e);
1053
-	    if ($n > 0) {
1047
+		//$read = array( $sockets[$id] );
1048
+		$read = $sockets;
1049
+		$write = NULL;
1050
+		$e = NULL;
1051
+		$n = socket_select($read, $write, $e, $timeout);
1052
+		if ($e != NULL) var_dump($e);
1053
+		if ($n > 0) {
1054 1054
 		$reset = 0;
1055 1055
 		foreach ($read as $nb => $r) {
1056
-		    //$value = $formats[$nb];
1057
-		    $format = $globalSources[$nb]['format'];
1058
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1056
+			//$value = $formats[$nb];
1057
+			$format = $globalSources[$nb]['format'];
1058
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1059 1059
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1060
-		    } elseif ($format == 'vrstcp') {
1060
+			} elseif ($format == 'vrstcp') {
1061 1061
 			$buffer = @socket_read($r, 6000);
1062
-		    } else {
1062
+			} else {
1063 1063
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1064
-		    }
1065
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1066
-		    //echo $buffer."\n";
1067
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1068
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1069
-		    $error = false;
1070
-		    //$SI::del();
1071
-		    if ($format == 'vrstcp') {
1064
+			}
1065
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1066
+			//echo $buffer."\n";
1067
+			// lets play nice and handle signals such as ctrl-c/kill properly
1068
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1069
+			$error = false;
1070
+			//$SI::del();
1071
+			if ($format == 'vrstcp') {
1072 1072
 			$buffer = explode('},{',$buffer);
1073
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1074
-		    // SBS format is CSV format
1075
-		    if ($buffer !== FALSE && $buffer != '') {
1073
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1074
+			// SBS format is CSV format
1075
+			if ($buffer !== FALSE && $buffer != '') {
1076 1076
 			$tt[$format] = 0;
1077 1077
 			if ($format == 'acarssbs3') {
1078
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1079
-			    $ACARS->add(trim($buffer));
1080
-			    $ACARS->deleteLiveAcarsData();
1078
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1079
+				$ACARS->add(trim($buffer));
1080
+				$ACARS->deleteLiveAcarsData();
1081 1081
 			} elseif ($format == 'raw') {
1082
-			    // AVR format
1083
-			    $data = $SBS->parse($buffer);
1084
-			    if (is_array($data)) {
1082
+				// AVR format
1083
+				$data = $SBS->parse($buffer);
1084
+				if (is_array($data)) {
1085 1085
 				$data['datetime'] = date('Y-m-d H:i:s');
1086 1086
 				$data['format_source'] = 'raw';
1087 1087
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1088 1088
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1089 1089
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1090 1090
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1091
-			    }
1091
+				}
1092 1092
 			} elseif ($format == 'ais') {
1093
-			    $ais_data = $AIS->parse_line(trim($buffer));
1094
-			    $data = array();
1095
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1096
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1097
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1098
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1099
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1100
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1101
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1102
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1103
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1104
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1105
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1106
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1107
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1108
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1109
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1110
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1093
+				$ais_data = $AIS->parse_line(trim($buffer));
1094
+				$data = array();
1095
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1096
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1097
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1098
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1099
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1100
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1101
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1102
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1103
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1104
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1105
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1106
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1107
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1108
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1109
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1110
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1111 1111
 
1112
-			    if (isset($ais_data['timestamp'])) {
1112
+				if (isset($ais_data['timestamp'])) {
1113 1113
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1114
-			    } else {
1114
+				} else {
1115 1115
 				$data['datetime'] = date('Y-m-d H:i:s');
1116
-			    }
1117
-			    $data['format_source'] = 'aisnmea';
1118
-    			    $data['id_source'] = $id_source;
1119
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1120
-			    unset($data);
1121
-                        } elseif ($format == 'flightgearsp') {
1122
-                    	    //echo $buffer."\n";
1123
-                    	    if (strlen($buffer) > 5) {
1116
+				}
1117
+				$data['format_source'] = 'aisnmea';
1118
+					$data['id_source'] = $id_source;
1119
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1120
+				unset($data);
1121
+						} elseif ($format == 'flightgearsp') {
1122
+							//echo $buffer."\n";
1123
+							if (strlen($buffer) > 5) {
1124 1124
 				$line = explode(',',$buffer);
1125 1125
 				$data = array();
1126 1126
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1137,38 +1137,38 @@  discard block
 block discarded – undo
1137 1137
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1138 1138
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1139 1139
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1140
-			    }
1141
-                        } elseif ($format == 'acars') {
1142
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1143
-			    $ACARS->add(trim($buffer));
1144
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1145
-			    $ACARS->deleteLiveAcarsData();
1140
+				}
1141
+						} elseif ($format == 'acars') {
1142
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1143
+				$ACARS->add(trim($buffer));
1144
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1145
+				$ACARS->deleteLiveAcarsData();
1146 1146
 			} elseif ($format == 'flightgearmp') {
1147
-			    if (substr($buffer,0,1) != '#') {
1147
+				if (substr($buffer,0,1) != '#') {
1148 1148
 				$data = array();
1149 1149
 				//echo $buffer."\n";
1150 1150
 				$line = explode(' ',$buffer);
1151 1151
 				if (count($line) == 11) {
1152
-				    $userserver = explode('@',$line[0]);
1153
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1154
-				    $data['ident'] = $userserver[0];
1155
-				    $data['registration'] = $userserver[0];
1156
-				    $data['latitude'] = $line[4];
1157
-				    $data['longitude'] = $line[5];
1158
-				    $data['altitude'] = $line[6];
1159
-				    $data['datetime'] = date('Y-m-d H:i:s');
1160
-				    $aircraft_type = $line[10];
1161
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1162
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1163
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1164
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1152
+					$userserver = explode('@',$line[0]);
1153
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1154
+					$data['ident'] = $userserver[0];
1155
+					$data['registration'] = $userserver[0];
1156
+					$data['latitude'] = $line[4];
1157
+					$data['longitude'] = $line[5];
1158
+					$data['altitude'] = $line[6];
1159
+					$data['datetime'] = date('Y-m-d H:i:s');
1160
+					$aircraft_type = $line[10];
1161
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1162
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1163
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1164
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1165
+				}
1165 1166
 				}
1166
-			    }
1167 1167
 			} elseif ($format == 'beast') {
1168
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1169
-			    die;
1168
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1169
+				die;
1170 1170
 			} elseif ($format == 'vrstcp') {
1171
-			    foreach($buffer as $all_data) {
1171
+				foreach($buffer as $all_data) {
1172 1172
 				$line = json_decode('{'.$all_data.'}',true);
1173 1173
 				$data = array();
1174 1174
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1188,113 +1188,113 @@  discard block
 block discarded – undo
1188 1188
 				*/
1189 1189
 				$data['datetime'] = date('Y-m-d H:i:s');
1190 1190
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1191
-		    		$data['format_source'] = 'vrstcp';
1191
+					$data['format_source'] = 'vrstcp';
1192 1192
 				$data['id_source'] = $id_source;
1193 1193
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194 1194
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1195 1195
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1196 1196
 				unset($data);
1197
-			    }
1197
+				}
1198 1198
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1199
-			    $line = explode("\t", $buffer);
1200
-			    for($k = 0; $k < count($line); $k=$k+2) {
1199
+				$line = explode("\t", $buffer);
1200
+				for($k = 0; $k < count($line); $k=$k+2) {
1201 1201
 				$key = $line[$k];
1202
-			        $lined[$key] = $line[$k+1];
1203
-			    }
1204
-    			    if (count($lined) > 3) {
1205
-    				$data['hex'] = $lined['hexid'];
1206
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1207
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1208
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1209
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1210
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1211
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1212
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1213
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1214
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1215
-    				$data['id_source'] = $id_source;
1216
-    				$data['format_source'] = 'tsv';
1217
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1218
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1202
+					$lined[$key] = $line[$k+1];
1203
+				}
1204
+					if (count($lined) > 3) {
1205
+					$data['hex'] = $lined['hexid'];
1206
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1207
+					$data['datetime'] = date('Y-m-d H:i:s');;
1208
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1209
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1210
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1211
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1212
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1213
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1214
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1215
+					$data['id_source'] = $id_source;
1216
+					$data['format_source'] = 'tsv';
1217
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1218
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1219 1219
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1220
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1221
-    				unset($lined);
1222
-    				unset($data);
1223
-    			    } else $error = true;
1220
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1221
+					unset($lined);
1222
+					unset($data);
1223
+					} else $error = true;
1224 1224
 			} elseif ($format == 'aprs' && $use_aprs) {
1225
-			    if ($aprs_connect == 0) {
1225
+				if ($aprs_connect == 0) {
1226 1226
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1227 1227
 				$aprs_connect = 1;
1228
-			    }
1228
+				}
1229 1229
 			    
1230
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1230
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1231 1231
 				$aprs_last_tx = time();
1232 1232
 				$data_aprs = "# Keep alive";
1233 1233
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1234
-			    }
1234
+				}
1235 1235
 			    
1236
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1237
-			    //echo 'APRS data : '.$buffer."\n";
1238
-			    $buffer = str_replace('APRS <- ','',$buffer);
1239
-			    $buffer = str_replace('APRS -> ','',$buffer);
1240
-			    //echo $buffer."\n";
1241
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1236
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1237
+				//echo 'APRS data : '.$buffer."\n";
1238
+				$buffer = str_replace('APRS <- ','',$buffer);
1239
+				$buffer = str_replace('APRS -> ','',$buffer);
1240
+				//echo $buffer."\n";
1241
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1242 1242
 				$line = $APRS->parse($buffer);
1243 1243
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1244 1244
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1245
-				    $aprs_last_tx = time();
1246
-				    $data = array();
1247
-				    //print_r($line);
1248
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1249
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1250
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1251
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1252
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1253
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1254
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1255
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1256
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1257
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1258
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1259
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1260
-				    $data['latitude'] = $line['latitude'];
1261
-				    $data['longitude'] = $line['longitude'];
1262
-				    //$data['verticalrate'] = $line[16];
1263
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1264
-				    else $data['speed'] = 0;
1265
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1266
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1267
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1268
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1269
-				    //else $data['heading'] = 0;
1270
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1271
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1272
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1273
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1274
-    				    $data['id_source'] = $id_source;
1275
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1276
-				    else $data['format_source'] = 'aprs';
1277
-				    $data['source_name'] = $line['source'];
1278
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1279
-				    else $data['source_type'] = 'flarm';
1280
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1281
-				    $currentdate = date('Y-m-d H:i:s');
1282
-				    $aprsdate = strtotime($data['datetime']);
1283
-				    // Accept data if time <= system time + 20s
1284
-				    //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'])))) {
1285
-				    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'])))) {
1245
+					$aprs_last_tx = time();
1246
+					$data = array();
1247
+					//print_r($line);
1248
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1249
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1250
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1251
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1252
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1253
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1254
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1255
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1256
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1257
+					else $data['datetime'] = date('Y-m-d H:i:s');
1258
+					//$data['datetime'] = date('Y-m-d H:i:s');
1259
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1260
+					$data['latitude'] = $line['latitude'];
1261
+					$data['longitude'] = $line['longitude'];
1262
+					//$data['verticalrate'] = $line[16];
1263
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1264
+					else $data['speed'] = 0;
1265
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1266
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1267
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1268
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1269
+					//else $data['heading'] = 0;
1270
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1271
+					if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1272
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1273
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1274
+						$data['id_source'] = $id_source;
1275
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1276
+					else $data['format_source'] = 'aprs';
1277
+					$data['source_name'] = $line['source'];
1278
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1279
+					else $data['source_type'] = 'flarm';
1280
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1281
+					$currentdate = date('Y-m-d H:i:s');
1282
+					$aprsdate = strtotime($data['datetime']);
1283
+					// Accept data if time <= system time + 20s
1284
+					//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'])))) {
1285
+					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'])))) {
1286 1286
 					$send = $SI->add($data);
1287
-				    } elseif ($data['source_type'] == 'ais') {
1287
+					} elseif ($data['source_type'] == 'ais') {
1288 1288
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1289
-				    } elseif (isset($line['stealth'])) {
1289
+					} elseif (isset($line['stealth'])) {
1290 1290
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1291 1291
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1292
-				    //} 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')) {
1293
-				    } 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') {
1292
+					//} 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')) {
1293
+					} 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') {
1294 1294
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1295 1295
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1296
-				    }
1297
-				    unset($data);
1296
+					}
1297
+					unset($data);
1298 1298
 				} 
1299 1299
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1300 1300
 					echo '!! Weather Station not yet supported'."\n";
@@ -1304,12 +1304,12 @@  discard block
 block discarded – undo
1304 1304
 				}
1305 1305
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1306 1306
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1307
-			    }
1307
+				}
1308 1308
 			} else {
1309
-			    $line = explode(',', $buffer);
1310
-    			    if (count($line) > 20) {
1311
-    			    	$data['hex'] = $line[4];
1312
-    				/*
1309
+				$line = explode(',', $buffer);
1310
+					if (count($line) > 20) {
1311
+						$data['hex'] = $line[4];
1312
+					/*
1313 1313
     				$data['datetime'] = $line[6].' '.$line[7];
1314 1314
     					date_default_timezone_set($globalTimezone);
1315 1315
     					$datetime = new DateTime($data['datetime']);
@@ -1317,30 +1317,30 @@  discard block
 block discarded – undo
1317 1317
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1318 1318
     					date_default_timezone_set('UTC');
1319 1319
     				*/
1320
-    				// Force datetime to current UTC datetime
1321
-    				date_default_timezone_set('UTC');
1322
-    				$data['datetime'] = date('Y-m-d H:i:s');
1323
-    				$data['ident'] = trim($line[10]);
1324
-    				$data['latitude'] = $line[14];
1325
-    				$data['longitude'] = $line[15];
1326
-    				$data['verticalrate'] = $line[16];
1327
-    				$data['emergency'] = $line[20];
1328
-    				$data['speed'] = $line[12];
1329
-    				$data['squawk'] = $line[17];
1330
-    				$data['altitude'] = $line[11];
1331
-    				$data['heading'] = $line[13];
1332
-    				$data['ground'] = $line[21];
1333
-    				$data['emergency'] = $line[19];
1334
-    				$data['format_source'] = 'sbs';
1320
+					// Force datetime to current UTC datetime
1321
+					date_default_timezone_set('UTC');
1322
+					$data['datetime'] = date('Y-m-d H:i:s');
1323
+					$data['ident'] = trim($line[10]);
1324
+					$data['latitude'] = $line[14];
1325
+					$data['longitude'] = $line[15];
1326
+					$data['verticalrate'] = $line[16];
1327
+					$data['emergency'] = $line[20];
1328
+					$data['speed'] = $line[12];
1329
+					$data['squawk'] = $line[17];
1330
+					$data['altitude'] = $line[11];
1331
+					$data['heading'] = $line[13];
1332
+					$data['ground'] = $line[21];
1333
+					$data['emergency'] = $line[19];
1334
+					$data['format_source'] = 'sbs';
1335 1335
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1336
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1336
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1337 1337
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1338
-    				$data['id_source'] = $id_source;
1339
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1340
-    				else $error = true;
1341
-    				unset($data);
1342
-    			    } else $error = true;
1343
-			    if ($error) {
1338
+					$data['id_source'] = $id_source;
1339
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1340
+					else $error = true;
1341
+					unset($data);
1342
+					} else $error = true;
1343
+				if ($error) {
1344 1344
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1345 1345
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1346 1346
 				} else {
@@ -1356,13 +1356,13 @@  discard block
 block discarded – undo
1356 1356
 					connect_all($sourceer);
1357 1357
 					$sourceer = array();
1358 1358
 				}
1359
-			    }
1359
+				}
1360 1360
 			}
1361 1361
 			// Sleep for xxx microseconds
1362 1362
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1363
-		    } else {
1363
+			} else {
1364 1364
 			if ($format == 'flightgearmp') {
1365
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1365
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1366 1366
 				//@socket_close($r);
1367 1367
 				sleep($globalMinFetch);
1368 1368
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1371,9 +1371,9 @@  discard block
 block discarded – undo
1371 1371
 				break;
1372 1372
 				
1373 1373
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1374
-			    if (isset($tt[$format])) $tt[$format]++;
1375
-			    else $tt[$format] = 0;
1376
-			    if ($tt[$format] > 30) {
1374
+				if (isset($tt[$format])) $tt[$format]++;
1375
+				else $tt[$format] = 0;
1376
+				if ($tt[$format] > 30) {
1377 1377
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1378 1378
 				//@socket_close($r);
1379 1379
 				sleep(2);
@@ -1384,23 +1384,23 @@  discard block
 block discarded – undo
1384 1384
 				//connect_all($globalSources);
1385 1385
 				$tt[$format]=0;
1386 1386
 				break;
1387
-			    }
1387
+				}
1388
+			}
1388 1389
 			}
1389
-		    }
1390 1390
 		}
1391
-	    } else {
1391
+		} else {
1392 1392
 		$error = socket_strerror(socket_last_error());
1393 1393
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1394 1394
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1395 1395
 			if (isset($globalDebug)) echo "Restarting...\n";
1396 1396
 			// Restart the script if possible
1397 1397
 			if (is_array($sockets)) {
1398
-			    if ($globalDebug) echo "Shutdown all sockets...";
1398
+				if ($globalDebug) echo "Shutdown all sockets...";
1399 1399
 			    
1400
-			    foreach ($sockets as $sock) {
1400
+				foreach ($sockets as $sock) {
1401 1401
 				@socket_shutdown($sock,2);
1402 1402
 				@socket_close($sock);
1403
-			    }
1403
+				}
1404 1404
 			    
1405 1405
 			}
1406 1406
 			if ($globalDebug) echo "Waiting...";
@@ -1415,13 +1415,13 @@  discard block
 block discarded – undo
1415 1415
 			if ($globalDebug) echo "Restart all connections...";
1416 1416
 			connect_all($globalSources);
1417 1417
 		}
1418
-	    }
1418
+		}
1419 1419
 	}
1420 1420
 	if ($globalDaemon === false) {
1421
-	    if ($globalDebug) echo 'Check all...'."\n";
1422
-	    $SI->checkAll();
1421
+		if ($globalDebug) echo 'Check all...'."\n";
1422
+		$SI->checkAll();
1423
+	}
1423 1424
 	}
1424
-    }
1425 1425
 }
1426 1426
 
1427 1427
 ?>
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         	    exit(0);
152 152
         	}
153 153
     	    */
154
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
155 155
         	//$formats[$id] = 'planeupdatefaa';
156 156
         	$globalSources[$id]['format'] = 'planeupdatefaa';
157 157
         	//$last_exec['planeupdatefaa'] = 0;
@@ -160,26 +160,26 @@  discard block
 block discarded – undo
160 160
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 161
         	    exit(0);
162 162
         	}
163
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
164 164
         	//$formats[$id] = 'phpvmacars';
165 165
         	$globalSources[$id]['format'] = 'phpvmacars';
166 166
         	//$last_exec['phpvmacars'] = 0;
167 167
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
169 169
         	//$formats[$id] = 'phpvmacars';
170 170
         	$globalSources[$id]['format'] = 'vam';
171 171
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
-            } else if (preg_match('/whazzup/i',$host)) {
172
+            } else if (preg_match('/whazzup/i', $host)) {
173 173
         	//$formats[$id] = 'whazzup';
174 174
         	$globalSources[$id]['format'] = 'whazzup';
175 175
         	//$last_exec['whazzup'] = 0;
176 176
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
-            } else if (preg_match('/recentpireps/i',$host)) {
177
+            } else if (preg_match('/recentpireps/i', $host)) {
178 178
         	//$formats[$id] = 'pirepsjson';
179 179
         	$globalSources[$id]['format'] = 'pirepsjson';
180 180
         	//$last_exec['pirepsjson'] = 0;
181 181
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
183 183
         	//$formats[$id] = 'fr24json';
184 184
         	$globalSources[$id]['format'] = 'fr24json';
185 185
         	//$last_exec['fr24json'] = 0;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 189
         	    exit(0);
190 190
         	}
191
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
191
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
192 192
         	//$formats[$id] = 'fr24json';
193 193
         	$globalSources[$id]['format'] = 'myshiptracking';
194 194
         	//$last_exec['fr24json'] = 0;
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
         	    exit(0);
199 199
         	}
200 200
             //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
201
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 202
         	//$formats[$id] = 'tsv';
203 203
         	$globalSources[$id]['format'] = 'tsv';
204 204
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205 205
             }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
206
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
207 207
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
208
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
209 209
     		    if ($idf !== false) {
210 210
     			$httpfeeds[$id] = $idf;
211 211
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212 212
     		    }
213 213
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214 214
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
215
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
216
+	    $hostport = explode(':', $host);
217 217
 	    if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
@@ -223,19 +223,19 @@  discard block
 block discarded – undo
223 223
 	    }
224 224
 	    $Common = new Common();
225 225
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
226
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
227 227
     	    } else {
228
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
228
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
229 229
 	    }
230 230
 	    if ($s) {
231 231
     	        $sockets[$id] = $s;
232 232
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
233
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
234 234
 			//$formats[$id] = 'aprs';
235 235
 			$globalSources[$id]['format'] = 'aprs';
236 236
 			//$aprs_connect = 0;
237 237
 			//$use_aprs = true;
238
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
238
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
239 239
 			$globalSources[$id]['format'] = 'vrstcp';
240 240
     		    } elseif ($port == '10001') {
241 241
         		//$formats[$id] = 'tsv';
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
275 275
 else $timeout = 20;
276 276
 $errno = '';
277
-$errstr='';
277
+$errstr = '';
278 278
 
279 279
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
280 280
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 //connect_all($globalSources);
283 283
 
284 284
 if (isset($globalProxy) && $globalProxy) {
285
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
285
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
286 286
 } else {
287 287
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
288 288
 }
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 
310 310
 if ($use_aprs) {
311 311
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
312
-	$APRS=new APRS();
312
+	$APRS = new APRS();
313 313
 	$aprs_connect = 0;
314 314
 	$aprs_keep = 120;
315 315
 	$aprs_last_tx = time();
316 316
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
317
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
317
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
318 318
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
319
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
319
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
320 320
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
321
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
321
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
322 322
 	if ($aprs_full) $aprs_filter = '';
323 323
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
324 324
 	else $aprs_pass = '-1';
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 sleep(1);
333 333
 if ($globalDebug) echo "SCAN MODE \n\n";
334 334
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
335
-$endtime = time()+$globalCronEnd;
335
+$endtime = time() + $globalCronEnd;
336 336
 $i = 1;
337 337
 $tt = array();
338 338
 // Delete all ATC
339 339
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
340
-	$ATC=new ATC($Connection->db);
340
+	$ATC = new ATC($Connection->db);
341 341
 }
342 342
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
343 343
 	$ATC->deleteAll();
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 347
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
348
+    if (!$globalDaemon) $i = $endtime - time();
349 349
     // Delete old ATC
350 350
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	}
361 361
 	if ($max != $globalMinFetch) {
362 362
 	    if ($globalDebug) echo 'Sleeping...'."\n";
363
-	    sleep($globalMinFetch-$max+2);
363
+	    sleep($globalMinFetch - $max + 2);
364 364
 	}
365 365
     }
366 366
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	    //$buffer = $Common->getData($hosts[$id]);
374 374
 	    $buffer = $Common->getData($value['host']);
375 375
 	    if ($buffer != '') $reset = 0;
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    foreach ($buffer as $line) {
379 379
     		if ($line != '' && count($line) > 7) {
380 380
     		    $line = explode(',', $line);
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
     	    $last_exec[$id]['last'] = time();
403 403
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
404 404
 	    date_default_timezone_set('CET');
405
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
405
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
406 406
 	    date_default_timezone_set('UTC');
407 407
 	    if ($buffer != '') $reset = 0;
408
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
-	    $buffer = explode('\n',$buffer);
408
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
409
+	    $buffer = explode('\n', $buffer);
410 410
 	    foreach ($buffer as $line) {
411 411
 		if ($line != '') {
412 412
 		    echo "'".$line."'\n";
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425 425
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426 426
 		    if (isset($ais_data['timestamp'])) {
427
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
427
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
428 428
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
429 429
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430 430
 			    $add = true;
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 	    $w = $e = null;
448 448
 	    
449 449
 	    if (isset($arr[$id])) {
450
-		$nn = stream_select($arr,$w,$e,$timeout);
450
+		$nn = stream_select($arr, $w, $e, $timeout);
451 451
 		if ($nn > 0) {
452 452
 		    foreach ($httpfeeds as $feed) {
453
-			$buffer = stream_get_line($feed,2000,"\n");
454
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455
-			$buffer = explode('\n',$buffer);
453
+			$buffer = stream_get_line($feed, 2000, "\n");
454
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
455
+			$buffer = explode('\n', $buffer);
456 456
 			foreach ($buffer as $line) {
457 457
 			    if ($line != '') {
458 458
 				$ais_data = $AIS->parse_line(trim($line));
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
471 471
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
472 472
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
473
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
474 474
 				if (isset($ais_data['timestamp'])) {
475
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
475
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
476 476
 				} else {
477 477
 				    $data['datetime'] = date('Y-m-d H:i:s');
478 478
 				}
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 	    }
500 500
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
501
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
501
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
502 502
 	    if ($buffer != '') {
503 503
 		//echo $buffer;
504
-		$all_data = json_decode($buffer,true);
504
+		$all_data = json_decode($buffer, true);
505 505
 		//print_r($all_data);
506 506
 		if (isset($all_data[0]['DATA'])) {
507 507
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
517 517
 			$data['imo'] = $line['IMO'];
518 518
 			//$data['arrival_code'] = $ais_data['destination'];
519
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
519
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
520 520
 			$data['format_source'] = 'myshiptracking';
521 521
 			$data['id_source'] = $id_source;
522 522
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
 	    }
530 530
     	    $last_exec[$id]['last'] = time();
531 531
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
532
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
532
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
533 533
 	    if ($buffer != '') {
534
-		$all_data = json_decode($buffer,true);
534
+		$all_data = json_decode($buffer, true);
535 535
 		if (isset($all_data[0]['mmsi'])) {
536 536
 		    foreach ($all_data as $line) {
537 537
 			if ($line != '') {
@@ -559,27 +559,27 @@  discard block
 block discarded – undo
559 559
     	    $last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
561 561
 	    echo 'download...';
562
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
562
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
563 563
 	    echo 'done !'."\n";
564 564
 	    if ($buffer != '') $reset = 0;
565
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
566
-	    $buffer = explode('\n',$buffer);
565
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
566
+	    $buffer = explode('\n', $buffer);
567 567
 	    foreach ($buffer as $line) {
568 568
 		if ($line != '') {
569 569
 		    $data = array();
570
-		    $data['mmsi'] = (int)substr($line,0,9);
571
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
570
+		    $data['mmsi'] = (int) substr($line, 0, 9);
571
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
572 572
 		    //$data['status'] = substr($line,21,2);
573 573
 		    //$data['type'] = substr($line,24,3);
574
-		    $data['latitude'] = substr($line,29,9);
575
-		    $data['longitude'] = substr($line,41,9);
576
-		    $data['speed'] = round(substr($line,51,5));
574
+		    $data['latitude'] = substr($line, 29, 9);
575
+		    $data['longitude'] = substr($line, 41, 9);
576
+		    $data['speed'] = round(substr($line, 51, 5));
577 577
 		    //$data['course'] = substr($line,57,5);
578
-		    $data['heading'] = round(substr($line,63,3));
578
+		    $data['heading'] = round(substr($line, 63, 3));
579 579
 		    //$data['draft'] = substr($line,67,4);
580 580
 		    //$data['length'] = substr($line,72,3);
581 581
 		    //$data['beam'] = substr($line,76,2);
582
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
582
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
583 583
 		    //$data['callsign'] = trim(substr($line,100,7);
584 584
 		    //$data['dest'] = substr($line,108,20);
585 585
 		    //$data['etaDate'] = substr($line,129,5);
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
599 599
 	    //$buffer = $Common->getData($hosts[$id]);
600 600
 	    $buffer = $Common->getData($value['host']);
601
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
602
-	    $buffer = explode('\n',$buffer);
601
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
602
+	    $buffer = explode('\n', $buffer);
603 603
 	    $reset = 0;
604 604
 	    foreach ($buffer as $line) {
605 605
     		if ($line != '') {
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
611 611
 			$data['pilot_id'] = $line[1];
612 612
 			$data['pilot_name'] = $line[2];
613
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
613
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
614 614
 			$data['ident'] = $line[0]; // ident
615 615
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
616 616
 			$data['speed'] = $line[8]; // speed
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
627 627
 			//if (isset($line[37])) $data['last_update'] = $line[37];
628 628
 		        $data['departure_airport_icao'] = $line[11];
629
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
629
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
630 630
 		        $data['arrival_airport_icao'] = $line[13];
631 631
 			$data['frequency'] = $line[4];
632 632
 			$data['type'] = $line[18];
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
     			$data['id_source'] = $id_source;
636 636
 	    		//$data['arrival_airport_time'] = ;
637 637
 	    		if ($line[9] != '') {
638
-	    		    $aircraft_data = explode('/',$line[9]);
638
+	    		    $aircraft_data = explode('/', $line[9]);
639 639
 	    		    if (isset($aircraft_data[1])) {
640 640
 	    			$data['aircraft_icao'] = $aircraft_data[1];
641 641
 	    		    }
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
     			if ($line[3] == 'PILOT') $SI->add($data);
651 651
 			elseif ($line[3] == 'ATC') {
652 652
 				//print_r($data);
653
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
654
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
655
-				$typec = substr($data['ident'],-3);
653
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
654
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
655
+				$typec = substr($data['ident'], -3);
656 656
 				if ($typec == 'APP') $data['type'] = 'Approach';
657 657
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
658 658
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
664 664
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
665 665
 				if (!isset($data['source_name'])) $data['source_name'] = '';
666
-				if (isset($ATC)) 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']);
666
+				if (isset($ATC)) 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']);
667 667
 			}
668 668
     			unset($data);
669 669
     		    }
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
     	    $last_exec[$id]['last'] = time();
675 675
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
676 676
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
677
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
677
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
678 678
 	    if ($buffer != '') {
679
-	    $all_data = json_decode($buffer,true);
679
+	    $all_data = json_decode($buffer, true);
680 680
 	    if (isset($all_data['acList'])) {
681 681
 		$reset = 0;
682 682
 		foreach ($all_data['acList'] as $line) {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 		    $data['emergency'] = ''; // emergency
694 694
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
695 695
 		    
696
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
696
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
697 697
 		    else $data['datetime'] = date('Y-m-d H:i:s');
698 698
 		    
699 699
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
720 720
 		    $data['squawk'] = $line['squawk']; // squawk
721 721
 		    $data['emergency'] = ''; // emergency
722
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
722
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
723 723
 		    else $data['datetime'] = date('Y-m-d H:i:s');
724 724
 	    	    $data['format_source'] = 'aircraftlistjson';
725 725
     		    $data['id_source'] = $id_source;
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
736 736
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
737 737
 	    $buffer = $Common->getData($value['host']);
738
-	    $all_data = json_decode($buffer,true);
738
+	    $all_data = json_decode($buffer, true);
739 739
 	    if (isset($all_data['planes'])) {
740 740
 		$reset = 0;
741 741
 		foreach ($all_data['planes'] as $key => $line) {
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 		    $data['emergency'] = ''; // emergency
753 753
 		    $data['registration'] = $line[2];
754 754
 		    $data['aircraft_icao'] = $line[0];
755
-		    $deparr = explode('-',$line[1]);
755
+		    $deparr = explode('-', $line[1]);
756 756
 		    if (count($deparr) == 2) {
757 757
 			$data['departure_airport_icao'] = $deparr[0];
758 758
 			$data['arrival_airport_icao'] = $deparr[1];
759 759
 		    }
760
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
760
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
761 761
 	    	    $data['format_source'] = 'planeupdatefaa';
762 762
     		    $data['id_source'] = $id_source;
763 763
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
     	    $last_exec[$id]['last'] = time();
771 771
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
772 772
 	    $buffer = $Common->getData($value['host']);
773
-	    $all_data = json_decode($buffer,true);
773
+	    $all_data = json_decode($buffer, true);
774 774
 	    if (isset($all_data['states'])) {
775 775
 		$reset = 0;
776 776
 		foreach ($all_data['states'] as $key => $line) {
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		    //$data['emergency'] = ''; // emergency
788 788
 		    //$data['registration'] = $line[2];
789 789
 		    //$data['aircraft_icao'] = $line[0];
790
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
790
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
791 791
 	    	    $data['format_source'] = 'opensky';
792 792
     		    $data['id_source'] = $id_source;
793 793
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
802 802
 	    //$buffer = $Common->getData($hosts[$id]);
803 803
 	    $buffer = $Common->getData($value['host']);
804
-	    $all_data = json_decode($buffer,true);
804
+	    $all_data = json_decode($buffer, true);
805 805
 	    if (!empty($all_data)) $reset = 0;
806 806
 	    foreach ($all_data as $key => $line) {
807 807
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -834,11 +834,11 @@  discard block
 block discarded – undo
834 834
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
835 835
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
836 836
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
837
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
837
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
838 838
 	    //echo $buffer;
839
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
840
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
841
-	    $all_data = json_decode($buffer,true);
839
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
840
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
841
+	    $all_data = json_decode($buffer, true);
842 842
 	    if (json_last_error() != JSON_ERROR_NONE) {
843 843
 		die(json_last_error_msg());
844 844
 	    }
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 			//$data['departure_airport_iata'] = $line[11];
862 862
 			//$data['arrival_airport_iata'] = $line[12];
863 863
 	    		//$data['emergency'] = ''; // emergency
864
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
864
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
865 865
 	    		$data['format_source'] = 'radarvirtueljson';
866 866
     			$data['id_source'] = $id_source;
867 867
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -877,14 +877,14 @@  discard block
 block discarded – undo
877 877
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
878 878
 	    //$buffer = $Common->getData($hosts[$id]);
879 879
 	    $buffer = $Common->getData($value['host'].'?'.time());
880
-	    $all_data = json_decode(utf8_encode($buffer),true);
880
+	    $all_data = json_decode(utf8_encode($buffer), true);
881 881
 	    
882 882
 	    if (isset($all_data['pireps'])) {
883 883
 		$reset = 0;
884 884
 	        foreach ($all_data['pireps'] as $line) {
885 885
 		    $data = array();
886 886
 		    $data['id'] = $line['id'];
887
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
887
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
888 888
 		    $data['ident'] = $line['callsign']; // ident
889 889
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
890 890
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -914,9 +914,9 @@  discard block
 block discarded – undo
914 914
 			$SI->add($data);
915 915
 		    //    print_r($data);
916 916
     		    } elseif ($line['icon'] == 'ct') {
917
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
918
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
919
-			$typec = substr($data['ident'],-3);
917
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
918
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
919
+			$typec = substr($data['ident'], -3);
920 920
 			$data['type'] = '';
921 921
 			if ($typec == 'APP') $data['type'] = 'Approach';
922 922
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
928 928
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
929 929
 			else $data['type'] = 'Observer';
930
-			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']);
930
+			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']);
931 931
 		    }
932 932
 		    unset($data);
933 933
 		}
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 	    //$buffer = $Common->getData($hosts[$id]);
940 940
 	    if ($globalDebug) echo 'Get Data...'."\n";
941 941
 	    $buffer = $Common->getData($value['host']);
942
-	    $all_data = json_decode($buffer,true);
942
+	    $all_data = json_decode($buffer, true);
943 943
 	    if ($buffer != '' && is_array($all_data)) {
944 944
 		$reset = 0;
945 945
 		foreach ($all_data as $line) {
946 946
 	    	    $data = array();
947 947
 	    	    //$data['id'] = $line['id']; // id not usable
948 948
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
949
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
949
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
950 950
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
951 951
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
952 952
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -970,14 +970,14 @@  discard block
 block discarded – undo
970 970
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
971 971
 		    if (isset($line['aircraftname'])) {
972 972
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
973
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
974
-	    		$aircraft_data = explode('-',$line['aircraftname']);
973
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
974
+	    		$aircraft_data = explode('-', $line['aircraftname']);
975 975
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
976 976
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
977 977
 	    		else {
978
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
979
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
980
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
978
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
979
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
980
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
981 981
 	    		}
982 982
 	    	    }
983 983
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -997,14 +997,14 @@  discard block
 block discarded – undo
997 997
 	    //$buffer = $Common->getData($hosts[$id]);
998 998
 	    if ($globalDebug) echo 'Get Data...'."\n";
999 999
 	    $buffer = $Common->getData($value['host']);
1000
-	    $all_data = json_decode($buffer,true);
1000
+	    $all_data = json_decode($buffer, true);
1001 1001
 	    if ($buffer != '' && is_array($all_data)) {
1002 1002
 		$reset = 0;
1003 1003
 		foreach ($all_data as $line) {
1004 1004
 	    	    $data = array();
1005 1005
 	    	    //$data['id'] = $line['id']; // id not usable
1006 1006
 	    	    $data['id'] = trim($line['flight_id']);
1007
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1007
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1008 1008
 	    	    $data['pilot_name'] = $line['pilot_name'];
1009 1009
 	    	    $data['pilot_id'] = $line['pilot_id'];
1010 1010
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
 		    //$value = $formats[$nb];
1057 1057
 		    $format = $globalSources[$nb]['format'];
1058 1058
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1059
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1059
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1060 1060
 		    } elseif ($format == 'vrstcp') {
1061 1061
 			$buffer = @socket_read($r, 6000);
1062 1062
 		    } else {
1063
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1063
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1064 1064
 		    }
1065 1065
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1066 1066
 		    //echo $buffer."\n";
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 		    $error = false;
1070 1070
 		    //$SI::del();
1071 1071
 		    if ($format == 'vrstcp') {
1072
-			$buffer = explode('},{',$buffer);
1073
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1072
+			$buffer = explode('},{', $buffer);
1073
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1074 1074
 		    // SBS format is CSV format
1075 1075
 		    if ($buffer !== FALSE && $buffer != '') {
1076 1076
 			$tt[$format] = 0;
@@ -1104,13 +1104,13 @@  discard block
 block discarded – undo
1104 1104
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1105 1105
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1106 1106
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1107
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1107
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1108 1108
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1109 1109
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1110 1110
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1111 1111
 
1112 1112
 			    if (isset($ais_data['timestamp'])) {
1113
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1113
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1114 1114
 			    } else {
1115 1115
 				$data['datetime'] = date('Y-m-d H:i:s');
1116 1116
 			    }
@@ -1121,10 +1121,10 @@  discard block
 block discarded – undo
1121 1121
                         } elseif ($format == 'flightgearsp') {
1122 1122
                     	    //echo $buffer."\n";
1123 1123
                     	    if (strlen($buffer) > 5) {
1124
-				$line = explode(',',$buffer);
1124
+				$line = explode(',', $buffer);
1125 1125
 				$data = array();
1126 1126
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1127
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1127
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1128 1128
 				$data['ident'] = $line[6];
1129 1129
 				$data['aircraft_name'] = $line[7];
1130 1130
 				$data['longitude'] = $line[1];
@@ -1136,21 +1136,21 @@  discard block
 block discarded – undo
1136 1136
 				$data['format_source'] = 'flightgearsp';
1137 1137
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1138 1138
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1139
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1139
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1140 1140
 			    }
1141 1141
                         } elseif ($format == 'acars') {
1142 1142
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1143 1143
 			    $ACARS->add(trim($buffer));
1144
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1144
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1145 1145
 			    $ACARS->deleteLiveAcarsData();
1146 1146
 			} elseif ($format == 'flightgearmp') {
1147
-			    if (substr($buffer,0,1) != '#') {
1147
+			    if (substr($buffer, 0, 1) != '#') {
1148 1148
 				$data = array();
1149 1149
 				//echo $buffer."\n";
1150
-				$line = explode(' ',$buffer);
1150
+				$line = explode(' ', $buffer);
1151 1151
 				if (count($line) == 11) {
1152
-				    $userserver = explode('@',$line[0]);
1153
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1152
+				    $userserver = explode('@', $line[0]);
1153
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1154 1154
 				    $data['ident'] = $userserver[0];
1155 1155
 				    $data['registration'] = $userserver[0];
1156 1156
 				    $data['latitude'] = $line[4];
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
 				    $data['altitude'] = $line[6];
1159 1159
 				    $data['datetime'] = date('Y-m-d H:i:s');
1160 1160
 				    $aircraft_type = $line[10];
1161
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1162
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1161
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1162
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1163 1163
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1164 1164
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1165 1165
 				}
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1169 1169
 			    die;
1170 1170
 			} elseif ($format == 'vrstcp') {
1171
-			    foreach($buffer as $all_data) {
1172
-				$line = json_decode('{'.$all_data.'}',true);
1171
+			    foreach ($buffer as $all_data) {
1172
+				$line = json_decode('{'.$all_data.'}', true);
1173 1173
 				$data = array();
1174 1174
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1175 1175
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1196 1196
 				unset($data);
1197 1197
 			    }
1198
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1198
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1199 1199
 			    $line = explode("\t", $buffer);
1200
-			    for($k = 0; $k < count($line); $k=$k+2) {
1200
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1201 1201
 				$key = $line[$k];
1202
-			        $lined[$key] = $line[$k+1];
1202
+			        $lined[$key] = $line[$k + 1];
1203 1203
 			    }
1204 1204
     			    if (count($lined) > 3) {
1205 1205
     				$data['hex'] = $lined['hexid'];
1206 1206
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1207
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1207
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1208 1208
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1209 1209
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1210 1210
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1223,22 +1223,22 @@  discard block
 block discarded – undo
1223 1223
     			    } else $error = true;
1224 1224
 			} elseif ($format == 'aprs' && $use_aprs) {
1225 1225
 			    if ($aprs_connect == 0) {
1226
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1226
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1227 1227
 				$aprs_connect = 1;
1228 1228
 			    }
1229 1229
 			    
1230
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1230
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1231 1231
 				$aprs_last_tx = time();
1232 1232
 				$data_aprs = "# Keep alive";
1233
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1233
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1234 1234
 			    }
1235 1235
 			    
1236 1236
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1237 1237
 			    //echo 'APRS data : '.$buffer."\n";
1238
-			    $buffer = str_replace('APRS <- ','',$buffer);
1239
-			    $buffer = str_replace('APRS -> ','',$buffer);
1238
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1239
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1240 1240
 			    //echo $buffer."\n";
1241
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1241
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1242 1242
 				$line = $APRS->parse($buffer);
1243 1243
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1244 1244
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1254 1254
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1255 1255
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1256
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1256
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1257 1257
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1258 1258
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1259 1259
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 				connect_all($sourceee);
1383 1383
 				$sourceee = array();
1384 1384
 				//connect_all($globalSources);
1385
-				$tt[$format]=0;
1385
+				$tt[$format] = 0;
1386 1386
 				break;
1387 1387
 			    }
1388 1388
 			}
@@ -1391,14 +1391,14 @@  discard block
 block discarded – undo
1391 1391
 	    } else {
1392 1392
 		$error = socket_strerror(socket_last_error());
1393 1393
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1394
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1394
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1395 1395
 			if (isset($globalDebug)) echo "Restarting...\n";
1396 1396
 			// Restart the script if possible
1397 1397
 			if (is_array($sockets)) {
1398 1398
 			    if ($globalDebug) echo "Shutdown all sockets...";
1399 1399
 			    
1400 1400
 			    foreach ($sockets as $sock) {
1401
-				@socket_shutdown($sock,2);
1401
+				@socket_shutdown($sock, 2);
1402 1402
 				@socket_close($sock);
1403 1403
 			    }
1404 1404
 			    
Please login to merge, or discard this patch.
Braces   +934 added lines, -321 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,22 +158,30 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    /*
143 186
     	    // Disabled for now, site change source format
144 187
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -155,7 +198,9 @@  discard block
 block discarded – undo
155 198
         	//$formats[$id] = 'planeupdatefaa';
156 199
         	$globalSources[$id]['format'] = 'planeupdatefaa';
157 200
         	//$last_exec['planeupdatefaa'] = 0;
158
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	}
159 204
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160 205
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 206
         	    exit(0);
@@ -164,26 +209,36 @@  discard block
 block discarded – undo
164 209
         	//$formats[$id] = 'phpvmacars';
165 210
         	$globalSources[$id]['format'] = 'phpvmacars';
166 211
         	//$last_exec['phpvmacars'] = 0;
167
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
+        	if ($globalDebug) {
213
+        		echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	}
168 215
             } else if (preg_match('/VAM-json.php$/i',$host)) {
169 216
         	//$formats[$id] = 'phpvmacars';
170 217
         	$globalSources[$id]['format'] = 'vam';
171
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
218
+        	if ($globalDebug) {
219
+        		echo "Connect to Vam source (".$host.")...\n";
220
+        	}
172 221
             } else if (preg_match('/whazzup/i',$host)) {
173 222
         	//$formats[$id] = 'whazzup';
174 223
         	$globalSources[$id]['format'] = 'whazzup';
175 224
         	//$last_exec['whazzup'] = 0;
176
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
225
+        	if ($globalDebug) {
226
+        		echo "Connect to whazzup source (".$host.")...\n";
227
+        	}
177 228
             } else if (preg_match('/recentpireps/i',$host)) {
178 229
         	//$formats[$id] = 'pirepsjson';
179 230
         	$globalSources[$id]['format'] = 'pirepsjson';
180 231
         	//$last_exec['pirepsjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to pirepsjson source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183 236
         	//$formats[$id] = 'fr24json';
184 237
         	$globalSources[$id]['format'] = 'fr24json';
185 238
         	//$last_exec['fr24json'] = 0;
186
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to fr24 source (".$host.")...\n";
241
+        	}
187 242
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188 243
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 244
         	    exit(0);
@@ -192,7 +247,9 @@  discard block
 block discarded – undo
192 247
         	//$formats[$id] = 'fr24json';
193 248
         	$globalSources[$id]['format'] = 'myshiptracking';
194 249
         	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to myshiptracking source (".$host.")...\n";
252
+        	}
196 253
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197 254
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198 255
         	    exit(0);
@@ -201,17 +258,24 @@  discard block
 block discarded – undo
201 258
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 259
         	//$formats[$id] = 'tsv';
203 260
         	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
261
+        	if ($globalDebug) {
262
+        		echo "Connect to tsv source (".$host.")...\n";
263
+        	}
205 264
             }
206 265
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207 266
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208 267
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209 268
     		    if ($idf !== false) {
210 269
     			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
270
+        		if ($globalDebug) {
271
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+        		}
273
+    		    } elseif ($globalDebug) {
274
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
212 275
     		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
276
+    		} elseif ($globalDebug) {
277
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
278
+    		}
215 279
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216 280
 	    $hostport = explode(':',$host);
217 281
 	    if (isset($hostport[1])) {
@@ -251,17 +315,25 @@  discard block
 block discarded – undo
251 315
         		//$formats[$id] = 'beast';
252 316
         		$globalSources[$id]['format'] = 'beast';
253 317
 		    //} else $formats[$id] = 'sbs';
254
-		    } else $globalSources[$id]['format'] = 'sbs';
318
+		    } else {
319
+		    	$globalSources[$id]['format'] = 'sbs';
320
+		    }
255 321
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256 322
 		}
257
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
323
+		if ($globalDebug) {
324
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
325
+		}
258 326
             } else {
259
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
327
+		if ($globalDebug) {
328
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
329
+		}
260 330
     	    }
261 331
         }
262 332
     }
263 333
 }
264
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
334
+if (!isset($globalMinFetch)) {
335
+	$globalMinFetch = 15;
336
+}
265 337
 
266 338
 // Initialize all
267 339
 $status = array();
@@ -270,13 +342,19 @@  discard block
 block discarded – undo
270 342
 $formats = array();
271 343
 $last_exec = array();
272 344
 $time = time();
273
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
274
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
275
-else $timeout = 20;
345
+if (isset($globalSourcesTimeout)) {
346
+	$timeout = $globalSourcesTimeOut;
347
+} else if (isset($globalSBS1TimeOut)) {
348
+	$timeout = $globalSBS1TimeOut;
349
+} else {
350
+	$timeout = 20;
351
+}
276 352
 $errno = '';
277 353
 $errstr='';
278 354
 
279
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
355
+if (!isset($globalDaemon)) {
356
+	$globalDaemon = TRUE;
357
+}
280 358
 /* Initiate connections to all the hosts simultaneously */
281 359
 //connect_all($hosts);
282 360
 //connect_all($globalSources);
@@ -302,7 +380,9 @@  discard block
 block discarded – undo
302 380
     if (isset($source['format']) && $source['format'] == 'aprs') {
303 381
 	$aprs_connect = 0;
304 382
 	$use_aprs = true;
305
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
383
+	if (isset($source['port']) && $source['port'] == '10152') {
384
+		$aprs_full = true;
385
+	}
306 386
 	break;
307 387
     }
308 388
 }
@@ -313,25 +393,48 @@  discard block
 block discarded – undo
313 393
 	$aprs_connect = 0;
314 394
 	$aprs_keep = 120;
315 395
 	$aprs_last_tx = time();
316
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
317
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
318
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
319
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
320
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
321
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
322
-	if ($aprs_full) $aprs_filter = '';
323
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
324
-	else $aprs_pass = '-1';
396
+	if (isset($globalAPRSversion)) {
397
+		$aprs_version = $globalAPRSversion;
398
+	} else {
399
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
400
+	}
401
+	if (isset($globalAPRSssid)) {
402
+		$aprs_ssid = $globalAPRSssid;
403
+	} else {
404
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
405
+	}
406
+	if (isset($globalAPRSfilter)) {
407
+		$aprs_filter = $globalAPRSfilter;
408
+	} else {
409
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
410
+	}
411
+	if ($aprs_full) {
412
+		$aprs_filter = '';
413
+	}
414
+	if (isset($globalAPRSpass)) {
415
+		$aprs_pass = $globalAPRSpass;
416
+	} else {
417
+		$aprs_pass = '-1';
418
+	}
325 419
 
326
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
327
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
328
-}
420
+	if ($aprs_filter != '') {
421
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
422
+	} else {
423
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
424
+	}
425
+	}
329 426
 
330 427
 // connected - lets do some work
331
-if ($globalDebug) echo "Connected!\n";
428
+if ($globalDebug) {
429
+	echo "Connected!\n";
430
+}
332 431
 sleep(1);
333
-if ($globalDebug) echo "SCAN MODE \n\n";
334
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
432
+if ($globalDebug) {
433
+	echo "SCAN MODE \n\n";
434
+}
435
+if (!isset($globalCronEnd)) {
436
+	$globalCronEnd = 60;
437
+}
335 438
 $endtime = time()+$globalCronEnd;
336 439
 $i = 1;
337 440
 $tt = array();
@@ -345,10 +448,14 @@  discard block
 block discarded – undo
345 448
 
346 449
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 450
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
451
+    if (!$globalDaemon) {
452
+    	$i = $endtime-time();
453
+    }
349 454
     // Delete old ATC
350 455
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
456
+	if ($globalDebug) {
457
+		echo 'Delete old ATC...'."\n";
458
+	}
352 459
         $ATC->deleteOldATC();
353 460
     }
354 461
     
@@ -356,10 +463,14 @@  discard block
 block discarded – undo
356 463
     if (count($last_exec) == count($globalSources)) {
357 464
 	$max = $globalMinFetch;
358 465
 	foreach ($last_exec as $last) {
359
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
466
+	    if ((time() - $last['last']) < $max) {
467
+	    	$max = time() - $last['last'];
468
+	    }
360 469
 	}
361 470
 	if ($max != $globalMinFetch) {
362
-	    if ($globalDebug) echo 'Sleeping...'."\n";
471
+	    if ($globalDebug) {
472
+	    	echo 'Sleeping...'."\n";
473
+	    }
363 474
 	    sleep($globalMinFetch-$max+2);
364 475
 	}
365 476
     }
@@ -368,11 +479,15 @@  discard block
 block discarded – undo
368 479
     //foreach ($formats as $id => $value) {
369 480
     foreach ($globalSources as $id => $value) {
370 481
 	date_default_timezone_set('UTC');
371
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
482
+	if (!isset($last_exec[$id]['last'])) {
483
+		$last_exec[$id]['last'] = 0;
484
+	}
372 485
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
373 486
 	    //$buffer = $Common->getData($hosts[$id]);
374 487
 	    $buffer = $Common->getData($value['host']);
375
-	    if ($buffer != '') $reset = 0;
488
+	    if ($buffer != '') {
489
+	    	$reset = 0;
490
+	    }
376 491
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377 492
 	    $buffer = explode('\n',$buffer);
378 493
 	    foreach ($buffer as $line) {
@@ -381,20 +496,41 @@  discard block
 block discarded – undo
381 496
 	            $data = array();
382 497
 	            $data['hex'] = $line[1]; // hex
383 498
 	            $data['ident'] = $line[2]; // ident
384
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
499
+	            if (isset($line[3])) {
500
+	            	$data['altitude'] = $line[3];
501
+	            }
502
+	            // altitude
503
+	            if (isset($line[4])) {
504
+	            	$data['speed'] = $line[4];
505
+	            }
506
+	            // speed
507
+	            if (isset($line[5])) {
508
+	            	$data['heading'] = $line[5];
509
+	            }
510
+	            // heading
511
+	            if (isset($line[6])) {
512
+	            	$data['latitude'] = $line[6];
513
+	            }
514
+	            // lat
515
+	            if (isset($line[7])) {
516
+	            	$data['longitude'] = $line[7];
517
+	            }
518
+	            // long
389 519
 	            $data['verticalrate'] = ''; // vertical rate
390 520
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391 521
 	            $data['emergency'] = ''; // emergency
392 522
 		    $data['datetime'] = date('Y-m-d H:i:s');
393 523
 		    $data['format_source'] = 'deltadbtxt';
394 524
     		    $data['id_source'] = $id_source;
395
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
525
+		    if (isset($value['name']) && $value['name'] != '') {
526
+		    	$data['source_name'] = $value['name'];
527
+		    }
528
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
529
+		    	$data['noarchive'] = true;
530
+		    }
531
+		    if (isset($value['sourcestats'])) {
532
+		    	$data['sourcestats'] = $value['sourcestats'];
533
+		    }
398 534
     		    $SI->add($data);
399 535
 		    unset($data);
400 536
     		}
@@ -404,7 +540,9 @@  discard block
 block discarded – undo
404 540
 	    date_default_timezone_set('CET');
405 541
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406 542
 	    date_default_timezone_set('UTC');
407
-	    if ($buffer != '') $reset = 0;
543
+	    if ($buffer != '') {
544
+	    	$reset = 0;
545
+	    }
408 546
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409 547
 	    $buffer = explode('\n',$buffer);
410 548
 	    foreach ($buffer as $line) {
@@ -413,16 +551,36 @@  discard block
 block discarded – undo
413 551
 		    $add = false;
414 552
 		    $ais_data = $AIS->parse_line(trim($line));
415 553
 		    $data = array();
416
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
+		    if (isset($ais_data['ident'])) {
555
+		    	$data['ident'] = $ais_data['ident'];
556
+		    }
557
+		    if (isset($ais_data['mmsi'])) {
558
+		    	$data['mmsi'] = $ais_data['mmsi'];
559
+		    }
560
+		    if (isset($ais_data['speed'])) {
561
+		    	$data['speed'] = $ais_data['speed'];
562
+		    }
563
+		    if (isset($ais_data['heading'])) {
564
+		    	$data['heading'] = $ais_data['heading'];
565
+		    }
566
+		    if (isset($ais_data['latitude'])) {
567
+		    	$data['latitude'] = $ais_data['latitude'];
568
+		    }
569
+		    if (isset($ais_data['longitude'])) {
570
+		    	$data['longitude'] = $ais_data['longitude'];
571
+		    }
572
+		    if (isset($ais_data['status'])) {
573
+		    	$data['status'] = $ais_data['status'];
574
+		    }
575
+		    if (isset($ais_data['type'])) {
576
+		    	$data['type'] = $ais_data['type'];
577
+		    }
578
+		    if (isset($ais_data['imo'])) {
579
+		    	$data['imo'] = $ais_data['imo'];
580
+		    }
581
+		    if (isset($ais_data['callsign'])) {
582
+		    	$data['callsign'] = $ais_data['callsign'];
583
+		    }
426 584
 		    if (isset($ais_data['timestamp'])) {
427 585
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
428 586
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -436,8 +594,12 @@  discard block
 block discarded – undo
436 594
 		    $data['format_source'] = 'aisnmeatxt';
437 595
     		    $data['id_source'] = $id_source;
438 596
 		    //print_r($data);
439
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
601
+		    	$MI->add($data);
602
+		    }
441 603
 		    unset($data);
442 604
 		}
443 605
     	    }
@@ -457,20 +619,48 @@  discard block
 block discarded – undo
457 619
 			    if ($line != '') {
458 620
 				$ais_data = $AIS->parse_line(trim($line));
459 621
 				$data = array();
460
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
461
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
462
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
463
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
464
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
465
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
466
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
467
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
468
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
469
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
470
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
471
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
472
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
622
+				if (isset($ais_data['ident'])) {
623
+					$data['ident'] = $ais_data['ident'];
624
+				}
625
+				if (isset($ais_data['mmsi'])) {
626
+					$data['mmsi'] = $ais_data['mmsi'];
627
+				}
628
+				if (isset($ais_data['speed'])) {
629
+					$data['speed'] = $ais_data['speed'];
630
+				}
631
+				if (isset($ais_data['heading'])) {
632
+					$data['heading'] = $ais_data['heading'];
633
+				}
634
+				if (isset($ais_data['latitude'])) {
635
+					$data['latitude'] = $ais_data['latitude'];
636
+				}
637
+				if (isset($ais_data['longitude'])) {
638
+					$data['longitude'] = $ais_data['longitude'];
639
+				}
640
+				if (isset($ais_data['status'])) {
641
+					$data['status'] = $ais_data['status'];
642
+				}
643
+				if (isset($ais_data['statusid'])) {
644
+					$data['status_id'] = $ais_data['statusid'];
645
+				}
646
+				if (isset($ais_data['type'])) {
647
+					$data['type'] = $ais_data['type'];
648
+				}
649
+				if (isset($ais_data['typeid'])) {
650
+					$data['type_id'] = $ais_data['typeid'];
651
+				}
652
+				if (isset($ais_data['imo'])) {
653
+					$data['imo'] = $ais_data['imo'];
654
+				}
655
+				if (isset($ais_data['callsign'])) {
656
+					$data['callsign'] = $ais_data['callsign'];
657
+				}
658
+				if (isset($ais_data['destination'])) {
659
+					$data['arrival_code'] = $ais_data['destination'];
660
+				}
661
+				if (isset($ais_data['eta_ts'])) {
662
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
663
+				}
474 664
 				if (isset($ais_data['timestamp'])) {
475 665
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
476 666
 				} else {
@@ -478,18 +668,27 @@  discard block
 block discarded – undo
478 668
 				}
479 669
 				$data['format_source'] = 'aisnmeahttp';
480 670
 				$data['id_source'] = $id_source;
481
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
671
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
672
+					$data['noarchive'] = true;
673
+				}
674
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
675
+					$MI->add($data);
676
+				}
483 677
 				unset($data);
484 678
 			    }
485 679
 			}
486 680
 		    }
487 681
 		} else {
488 682
 		    $format = $value['format'];
489
-		    if (isset($tt[$format])) $tt[$format]++;
490
-		    else $tt[$format] = 0;
683
+		    if (isset($tt[$format])) {
684
+		    	$tt[$format]++;
685
+		    } else {
686
+		    	$tt[$format] = 0;
687
+		    }
491 688
 		    if ($tt[$format] > 30) {
492
-			if ($globalDebug) echo 'Reconnect...'."\n";
689
+			if ($globalDebug) {
690
+				echo 'Reconnect...'."\n";
691
+			}
493 692
 			sleep(2);
494 693
 			$sourceeen[] = $value;
495 694
 			connect_all($sourceeen);
@@ -519,7 +718,9 @@  discard block
 block discarded – undo
519 718
 			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
520 719
 			$data['format_source'] = 'myshiptracking';
521 720
 			$data['id_source'] = $id_source;
522
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
721
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
722
+				$data['noarchive'] = true;
723
+			}
523 724
 			$MI->add($data);
524 725
 			unset($data);
525 726
 		    }
@@ -540,7 +741,9 @@  discard block
 block discarded – undo
540 741
 			    $data['callsign'] = $line['callsign'];
541 742
 			    $data['mmsi'] = $line['mmsi'];
542 743
 			    $data['speed'] = $line['sog'];
543
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
744
+			    if ($line['heading'] != '511') {
745
+			    	$data['heading'] = $line['heading'];
746
+			    }
544 747
 			    $data['latitude'] = $line['latitude'];
545 748
 			    $data['longitude'] = $line['longitude'];
546 749
 			    $data['type_id'] = $line['shiptype'];
@@ -548,7 +751,9 @@  discard block
 block discarded – undo
548 751
 			    $data['datetime'] = $line['time'];
549 752
 			    $data['format_source'] = 'boatbeaconapp';
550 753
 			    $data['id_source'] = $id_source;
551
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
754
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
755
+			    	$data['noarchive'] = true;
756
+			    }
552 757
 			    $MI->add($data);
553 758
 			    unset($data);
554 759
 			}
@@ -561,7 +766,9 @@  discard block
 block discarded – undo
561 766
 	    echo 'download...';
562 767
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
563 768
 	    echo 'done !'."\n";
564
-	    if ($buffer != '') $reset = 0;
769
+	    if ($buffer != '') {
770
+	    	$reset = 0;
771
+	    }
565 772
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
566 773
 	    $buffer = explode('\n',$buffer);
567 774
 	    foreach ($buffer as $line) {
@@ -586,7 +793,9 @@  discard block
 block discarded – undo
586 793
 		    //$data['etaTime'] = substr($line,135,5);
587 794
 		    $data['format_source'] = 'shipplotter';
588 795
     		    $data['id_source'] = $id_source;
589
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
796
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
797
+		    	$data['noarchive'] = true;
798
+		    }
590 799
 		    //print_r($data);
591 800
 		    echo 'Add...'."\n";
592 801
 		    $MI->add($data);
@@ -606,16 +815,28 @@  discard block
 block discarded – undo
606 815
     		    $line = explode(':', $line);
607 816
     		    if (count($line) > 30 && $line[0] != 'callsign') {
608 817
 			$data = array();
609
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
610
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
818
+			if (isset($line[37]) && $line[37] != '') {
819
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
820
+			} else {
821
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
822
+			}
611 823
 			$data['pilot_id'] = $line[1];
612 824
 			$data['pilot_name'] = $line[2];
613 825
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
614 826
 			$data['ident'] = $line[0]; // ident
615
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
827
+			if ($line[7] != '' && $line[7] != 0) {
828
+				$data['altitude'] = $line[7];
829
+			}
830
+			// altitude
616 831
 			$data['speed'] = $line[8]; // speed
617
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
618
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
832
+			if (isset($line[45])) {
833
+				$data['heading'] = $line[45];
834
+			}
835
+			// heading
836
+			elseif (isset($line[38])) {
837
+				$data['heading'] = $line[38];
838
+			}
839
+			// heading
619 840
 			$data['latitude'] = $line[5]; // lat
620 841
 	        	$data['longitude'] = $line[6]; // long
621 842
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -631,7 +852,9 @@  discard block
 block discarded – undo
631 852
 			$data['frequency'] = $line[4];
632 853
 			$data['type'] = $line[18];
633 854
 			$data['range'] = $line[19];
634
-			if (isset($line[35])) $data['info'] = $line[35];
855
+			if (isset($line[35])) {
856
+				$data['info'] = $line[35];
857
+			}
635 858
     			$data['id_source'] = $id_source;
636 859
 	    		//$data['arrival_airport_time'] = ;
637 860
 	    		if ($line[9] != '') {
@@ -645,25 +868,44 @@  discard block
 block discarded – undo
645 868
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
646 869
 	    		*/
647 870
 	    		$data['format_source'] = $value['format'];
648
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
650
-    			if ($line[3] == 'PILOT') $SI->add($data);
651
-			elseif ($line[3] == 'ATC') {
871
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
872
+				$data['noarchive'] = true;
873
+			}
874
+			if (isset($value['name']) && $value['name'] != '') {
875
+				$data['source_name'] = $value['name'];
876
+			}
877
+    			if ($line[3] == 'PILOT') {
878
+    				$SI->add($data);
879
+    			} elseif ($line[3] == 'ATC') {
652 880
 				//print_r($data);
653 881
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
654 882
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
655 883
 				$typec = substr($data['ident'],-3);
656
-				if ($typec == 'APP') $data['type'] = 'Approach';
657
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
658
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
659
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
660
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
661
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
662
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
663
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
664
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
665
-				if (!isset($data['source_name'])) $data['source_name'] = '';
666
-				if (isset($ATC)) 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']);
884
+				if ($typec == 'APP') {
885
+					$data['type'] = 'Approach';
886
+				} elseif ($typec == 'TWR') {
887
+					$data['type'] = 'Tower';
888
+				} elseif ($typec == 'OBS') {
889
+					$data['type'] = 'Observer';
890
+				} elseif ($typec == 'GND') {
891
+					$data['type'] = 'Ground';
892
+				} elseif ($typec == 'DEL') {
893
+					$data['type'] = 'Delivery';
894
+				} elseif ($typec == 'DEP') {
895
+					$data['type'] = 'Departure';
896
+				} elseif ($typec == 'FSS') {
897
+					$data['type'] = 'Flight Service Station';
898
+				} elseif ($typec == 'CTR') {
899
+					$data['type'] = 'Control Radar or Centre';
900
+				} elseif ($data['type'] == '') {
901
+					$data['type'] = 'Observer';
902
+				}
903
+				if (!isset($data['source_name'])) {
904
+					$data['source_name'] = '';
905
+				}
906
+				if (isset($ATC)) {
907
+					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']);
908
+				}
667 909
 			}
668 910
     			unset($data);
669 911
     		    }
@@ -682,27 +924,61 @@  discard block
 block discarded – undo
682 924
 		foreach ($all_data['acList'] as $line) {
683 925
 		    $data = array();
684 926
 		    $data['hex'] = $line['Icao']; // hex
685
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
686
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
687
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
688
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
689
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
690
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
927
+		    if (isset($line['Call'])) {
928
+		    	$data['ident'] = $line['Call'];
929
+		    }
930
+		    // ident
931
+		    if (isset($line['Alt'])) {
932
+		    	$data['altitude'] = $line['Alt'];
933
+		    }
934
+		    // altitude
935
+		    if (isset($line['Spd'])) {
936
+		    	$data['speed'] = $line['Spd'];
937
+		    }
938
+		    // speed
939
+		    if (isset($line['Trak'])) {
940
+		    	$data['heading'] = $line['Trak'];
941
+		    }
942
+		    // heading
943
+		    if (isset($line['Lat'])) {
944
+		    	$data['latitude'] = $line['Lat'];
945
+		    }
946
+		    // lat
947
+		    if (isset($line['Long'])) {
948
+		    	$data['longitude'] = $line['Long'];
949
+		    }
950
+		    // long
691 951
 		    //$data['verticalrate'] = $line['']; // verticale rate
692
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
952
+		    if (isset($line['Sqk'])) {
953
+		    	$data['squawk'] = $line['Sqk'];
954
+		    }
955
+		    // squawk
693 956
 		    $data['emergency'] = ''; // emergency
694
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
957
+		    if (isset($line['Reg'])) {
958
+		    	$data['registration'] = $line['Reg'];
959
+		    }
695 960
 		    
696
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
697
-		    else $data['datetime'] = date('Y-m-d H:i:s');
961
+		    if (isset($line['PosTime'])) {
962
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
963
+		    } else {
964
+		    	$data['datetime'] = date('Y-m-d H:i:s');
965
+		    }
698 966
 		    
699 967
 		    //$data['datetime'] = date('Y-m-d H:i:s');
700
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
968
+		    if (isset($line['Type'])) {
969
+		    	$data['aircraft_icao'] = $line['Type'];
970
+		    }
701 971
 	    	    $data['format_source'] = 'aircraftlistjson';
702 972
 		    $data['id_source'] = $id_source;
703
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
704
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
705
-		    if (isset($data['latitude'])) $SI->add($data);
973
+		    if (isset($value['name']) && $value['name'] != '') {
974
+		    	$data['source_name'] = $value['name'];
975
+		    }
976
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
977
+		    	$data['noarchive'] = true;
978
+		    }
979
+		    if (isset($data['latitude'])) {
980
+		    	$SI->add($data);
981
+		    }
706 982
 		    unset($data);
707 983
 		}
708 984
 	    } elseif (is_array($all_data)) {
@@ -719,12 +995,19 @@  discard block
 block discarded – undo
719 995
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
720 996
 		    $data['squawk'] = $line['squawk']; // squawk
721 997
 		    $data['emergency'] = ''; // emergency
722
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
723
-		    else $data['datetime'] = date('Y-m-d H:i:s');
998
+		    if (isset($line['PosTime'])) {
999
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1000
+		    } else {
1001
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1002
+		    }
724 1003
 	    	    $data['format_source'] = 'aircraftlistjson';
725 1004
     		    $data['id_source'] = $id_source;
726
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1005
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1006
+		    	$data['noarchive'] = true;
1007
+		    }
1008
+		    if (isset($value['name']) && $value['name'] != '') {
1009
+		    	$data['source_name'] = $value['name'];
1010
+		    }
728 1011
 		    $SI->add($data);
729 1012
 		    unset($data);
730 1013
 		}
@@ -760,8 +1043,12 @@  discard block
 block discarded – undo
760 1043
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
761 1044
 	    	    $data['format_source'] = 'planeupdatefaa';
762 1045
     		    $data['id_source'] = $id_source;
763
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
764
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1046
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1047
+		    	$data['noarchive'] = true;
1048
+		    }
1049
+		    if (isset($value['name']) && $value['name'] != '') {
1050
+		    	$data['source_name'] = $value['name'];
1051
+		    }
765 1052
 		    $SI->add($data);
766 1053
 		    unset($data);
767 1054
 		}
@@ -790,7 +1077,9 @@  discard block
 block discarded – undo
790 1077
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
791 1078
 	    	    $data['format_source'] = 'opensky';
792 1079
     		    $data['id_source'] = $id_source;
793
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1080
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1081
+		    	$data['noarchive'] = true;
1082
+		    }
794 1083
 		    $SI->add($data);
795 1084
 		    unset($data);
796 1085
 		}
@@ -802,7 +1091,9 @@  discard block
 block discarded – undo
802 1091
 	    //$buffer = $Common->getData($hosts[$id]);
803 1092
 	    $buffer = $Common->getData($value['host']);
804 1093
 	    $all_data = json_decode($buffer,true);
805
-	    if (!empty($all_data)) $reset = 0;
1094
+	    if (!empty($all_data)) {
1095
+	    	$reset = 0;
1096
+	    }
806 1097
 	    foreach ($all_data as $key => $line) {
807 1098
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
808 1099
 		    $data = array();
@@ -823,8 +1114,12 @@  discard block
 block discarded – undo
823 1114
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
824 1115
 	    	    $data['format_source'] = 'fr24json';
825 1116
     		    $data['id_source'] = $id_source;
826
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
827
-		    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
+		    }
828 1123
 		    $SI->add($data);
829 1124
 		    unset($data);
830 1125
 		}
@@ -848,24 +1143,42 @@  discard block
 block discarded – undo
848 1143
 		    if (isset($line['inf'])) {
849 1144
 			$data = array();
850 1145
 			$data['hex'] = $line['inf']['ia'];
851
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1146
+			if (isset($line['inf']['cs'])) {
1147
+				$data['ident'] = $line['inf']['cs'];
1148
+			}
1149
+			//$line[13]
852 1150
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
853
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
854
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1151
+	    		if (isset($line['inf']['gs'])) {
1152
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1153
+	    		}
1154
+	    		// speed
1155
+	    		if (isset($line['inf']['tr'])) {
1156
+	    			$data['heading'] = $line['inf']['tr'];
1157
+	    		}
1158
+	    		// heading
855 1159
 	    		$data['latitude'] = $line['pt'][0]; // lat
856 1160
 	    		$data['longitude'] = $line['pt'][1]; // long
857 1161
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
858
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1162
+	    		if (isset($line['inf']['sq'])) {
1163
+	    			$data['squawk'] = $line['inf']['sq'];
1164
+	    		}
1165
+	    		// squawk
859 1166
 	    		//$data['aircraft_icao'] = $line[8];
860
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1167
+	    		if (isset($line['inf']['rc'])) {
1168
+	    			$data['registration'] = $line['inf']['rc'];
1169
+	    		}
861 1170
 			//$data['departure_airport_iata'] = $line[11];
862 1171
 			//$data['arrival_airport_iata'] = $line[12];
863 1172
 	    		//$data['emergency'] = ''; // emergency
864 1173
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
865 1174
 	    		$data['format_source'] = 'radarvirtueljson';
866 1175
     			$data['id_source'] = $id_source;
867
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
868
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1176
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1177
+				$data['noarchive'] = true;
1178
+			}
1179
+			if (isset($value['name']) && $value['name'] != '') {
1180
+				$data['source_name'] = $value['name'];
1181
+			}
869 1182
 			$SI->add($data);
870 1183
 			unset($data);
871 1184
 		    }
@@ -886,30 +1199,65 @@  discard block
 block discarded – undo
886 1199
 		    $data['id'] = $line['id'];
887 1200
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
888 1201
 		    $data['ident'] = $line['callsign']; // ident
889
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
890
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
891
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
892
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
893
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
894
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202
+		    if (isset($line['pilotid'])) {
1203
+		    	$data['pilot_id'] = $line['pilotid'];
1204
+		    }
1205
+		    // pilot id
1206
+		    if (isset($line['name'])) {
1207
+		    	$data['pilot_name'] = $line['name'];
1208
+		    }
1209
+		    // pilot name
1210
+		    if (isset($line['alt'])) {
1211
+		    	$data['altitude'] = $line['alt'];
1212
+		    }
1213
+		    // altitude
1214
+		    if (isset($line['gs'])) {
1215
+		    	$data['speed'] = $line['gs'];
1216
+		    }
1217
+		    // speed
1218
+		    if (isset($line['heading'])) {
1219
+		    	$data['heading'] = $line['heading'];
1220
+		    }
1221
+		    // heading
1222
+		    if (isset($line['route'])) {
1223
+		    	$data['waypoints'] = $line['route'];
1224
+		    }
1225
+		    // route
895 1226
 		    $data['latitude'] = $line['lat']; // lat
896 1227
 		    $data['longitude'] = $line['lon']; // long
897 1228
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
898 1229
 		    //$data['squawk'] = $line['squawk']; // squawk
899 1230
 		    //$data['emergency'] = ''; // emergency
900
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
901
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
902
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1231
+		    if (isset($line['depicao'])) {
1232
+		    	$data['departure_airport_icao'] = $line['depicao'];
1233
+		    }
1234
+		    if (isset($line['deptime'])) {
1235
+		    	$data['departure_airport_time'] = $line['deptime'];
1236
+		    }
1237
+		    if (isset($line['arricao'])) {
1238
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1239
+		    }
903 1240
 		    //$data['arrival_airport_time'] = $line['arrtime'];
904
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
905
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
906
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
907
-		    else $data['info'] = '';
1241
+		    if (isset($line['aircraft'])) {
1242
+		    	$data['aircraft_icao'] = $line['aircraft'];
1243
+		    }
1244
+		    if (isset($line['transponder'])) {
1245
+		    	$data['squawk'] = $line['transponder'];
1246
+		    }
1247
+		    if (isset($line['atis'])) {
1248
+		    	$data['info'] = $line['atis'];
1249
+		    } else {
1250
+		    	$data['info'] = '';
1251
+		    }
908 1252
 		    $data['format_source'] = 'pireps';
909 1253
     		    $data['id_source'] = $id_source;
910 1254
 		    $data['datetime'] = date('Y-m-d H:i:s');
911
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
912
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1255
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1256
+		    	$data['noarchive'] = true;
1257
+		    }
1258
+		    if (isset($value['name']) && $value['name'] != '') {
1259
+		    	$data['source_name'] = $value['name'];
1260
+		    }
913 1261
 		    if ($line['icon'] == 'plane') {
914 1262
 			$SI->add($data);
915 1263
 		    //    print_r($data);
@@ -918,16 +1266,28 @@  discard block
 block discarded – undo
918 1266
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
919 1267
 			$typec = substr($data['ident'],-3);
920 1268
 			$data['type'] = '';
921
-			if ($typec == 'APP') $data['type'] = 'Approach';
922
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
923
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
924
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
925
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
926
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
927
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
928
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
929
-			else $data['type'] = 'Observer';
930
-			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']);
1269
+			if ($typec == 'APP') {
1270
+				$data['type'] = 'Approach';
1271
+			} elseif ($typec == 'TWR') {
1272
+				$data['type'] = 'Tower';
1273
+			} elseif ($typec == 'OBS') {
1274
+				$data['type'] = 'Observer';
1275
+			} elseif ($typec == 'GND') {
1276
+				$data['type'] = 'Ground';
1277
+			} elseif ($typec == 'DEL') {
1278
+				$data['type'] = 'Delivery';
1279
+			} elseif ($typec == 'DEP') {
1280
+				$data['type'] = 'Departure';
1281
+			} elseif ($typec == 'FSS') {
1282
+				$data['type'] = 'Flight Service Station';
1283
+			} elseif ($typec == 'CTR') {
1284
+				$data['type'] = 'Control Radar or Centre';
1285
+			} else {
1286
+				$data['type'] = 'Observer';
1287
+			}
1288
+			if (isset($ATC)) {
1289
+				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']);
1290
+			}
931 1291
 		    }
932 1292
 		    unset($data);
933 1293
 		}
@@ -937,7 +1297,9 @@  discard block
 block discarded – undo
937 1297
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
938 1298
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
939 1299
 	    //$buffer = $Common->getData($hosts[$id]);
940
-	    if ($globalDebug) echo 'Get Data...'."\n";
1300
+	    if ($globalDebug) {
1301
+	    	echo 'Get Data...'."\n";
1302
+	    }
941 1303
 	    $buffer = $Common->getData($value['host']);
942 1304
 	    $all_data = json_decode($buffer,true);
943 1305
 	    if ($buffer != '' && is_array($all_data)) {
@@ -945,10 +1307,16 @@  discard block
 block discarded – undo
945 1307
 		foreach ($all_data as $line) {
946 1308
 	    	    $data = array();
947 1309
 	    	    //$data['id'] = $line['id']; // id not usable
948
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1310
+	    	    if (isset($line['pilotid'])) {
1311
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1312
+	    	    }
949 1313
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
950
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
951
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1314
+	    	    if (isset($line['pilotname'])) {
1315
+	    	    	$data['pilot_name'] = $line['pilotname'];
1316
+	    	    }
1317
+	    	    if (isset($line['pilotid'])) {
1318
+	    	    	$data['pilot_id'] = $line['pilotid'];
1319
+	    	    }
952 1320
 	    	    $data['ident'] = $line['flightnum']; // ident
953 1321
 	    	    $data['altitude'] = $line['alt']; // altitude
954 1322
 	    	    $data['speed'] = $line['gs']; // speed
@@ -966,28 +1334,44 @@  discard block
 block discarded – undo
966 1334
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
967 1335
     		    $data['arrival_airport_time'] = $line['arrtime'];
968 1336
     		    $data['registration'] = $line['aircraft'];
969
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
970
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1337
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1338
+		    	$data['noarchive'] = true;
1339
+		    }
1340
+		    if (isset($line['route'])) {
1341
+		    	$data['waypoints'] = $line['route'];
1342
+		    }
1343
+		    // route
971 1344
 		    if (isset($line['aircraftname'])) {
972 1345
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
973 1346
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
974 1347
 	    		$aircraft_data = explode('-',$line['aircraftname']);
975
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
976
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
977
-	    		else {
1348
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1349
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1350
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1351
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1352
+	    		} else {
978 1353
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
979
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
980
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1354
+	    		    if (isset($aircraft_data[1])) {
1355
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1356
+	    		    } else {
1357
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1358
+	    		    }
981 1359
 	    		}
982 1360
 	    	    }
983
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1361
+    		    if (isset($line['route'])) {
1362
+    		    	$data['waypoints'] = $line['route'];
1363
+    		    }
984 1364
     		    $data['id_source'] = $id_source;
985 1365
 	    	    $data['format_source'] = 'phpvmacars';
986
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1366
+		    if (isset($value['name']) && $value['name'] != '') {
1367
+		    	$data['source_name'] = $value['name'];
1368
+		    }
987 1369
 		    $SI->add($data);
988 1370
 		    unset($data);
989 1371
 		}
990
-		if ($globalDebug) echo 'No more data...'."\n";
1372
+		if ($globalDebug) {
1373
+			echo 'No more data...'."\n";
1374
+		}
991 1375
 		unset($buffer);
992 1376
 		unset($all_data);
993 1377
 	    }
@@ -995,7 +1379,9 @@  discard block
 block discarded – undo
995 1379
     	    $last_exec[$id]['last'] = time();
996 1380
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
997 1381
 	    //$buffer = $Common->getData($hosts[$id]);
998
-	    if ($globalDebug) echo 'Get Data...'."\n";
1382
+	    if ($globalDebug) {
1383
+	    	echo 'Get Data...'."\n";
1384
+	    }
999 1385
 	    $buffer = $Common->getData($value['host']);
1000 1386
 	    $all_data = json_decode($buffer,true);
1001 1387
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1024,16 +1410,25 @@  discard block
 block discarded – undo
1024 1410
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1025 1411
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1026 1412
     		    //$data['registration'] = $line['aircraft'];
1027
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1413
+		    if (isset($line['route'])) {
1414
+		    	$data['waypoints'] = $line['route'];
1415
+		    }
1416
+		    // route
1028 1417
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1029 1418
     		    $data['id_source'] = $id_source;
1030 1419
 	    	    $data['format_source'] = 'vam';
1031
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1032
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1420
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1421
+		    	$data['noarchive'] = true;
1422
+		    }
1423
+		    if (isset($value['name']) && $value['name'] != '') {
1424
+		    	$data['source_name'] = $value['name'];
1425
+		    }
1033 1426
 		    $SI->add($data);
1034 1427
 		    unset($data);
1035 1428
 		}
1036
-		if ($globalDebug) echo 'No more data...'."\n";
1429
+		if ($globalDebug) {
1430
+			echo 'No more data...'."\n";
1431
+		}
1037 1432
 		unset($buffer);
1038 1433
 		unset($all_data);
1039 1434
 	    }
@@ -1041,7 +1436,9 @@  discard block
 block discarded – undo
1041 1436
     	    $last_exec[$id]['last'] = time();
1042 1437
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1043 1438
 	} 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') {
1044
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1439
+	    if (function_exists('pcntl_fork')) {
1440
+	    	pcntl_signal_dispatch();
1441
+	    }
1045 1442
     	    //$last_exec[$id]['last'] = time();
1046 1443
 
1047 1444
 	    //$read = array( $sockets[$id] );
@@ -1049,7 +1446,9 @@  discard block
 block discarded – undo
1049 1446
 	    $write = NULL;
1050 1447
 	    $e = NULL;
1051 1448
 	    $n = socket_select($read, $write, $e, $timeout);
1052
-	    if ($e != NULL) var_dump($e);
1449
+	    if ($e != NULL) {
1450
+	    	var_dump($e);
1451
+	    }
1053 1452
 	    if ($n > 0) {
1054 1453
 		$reset = 0;
1055 1454
 		foreach ($read as $nb => $r) {
@@ -1070,12 +1469,16 @@  discard block
 block discarded – undo
1070 1469
 		    //$SI::del();
1071 1470
 		    if ($format == 'vrstcp') {
1072 1471
 			$buffer = explode('},{',$buffer);
1073
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1472
+		    } else {
1473
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1474
+		    }
1074 1475
 		    // SBS format is CSV format
1075 1476
 		    if ($buffer !== FALSE && $buffer != '') {
1076 1477
 			$tt[$format] = 0;
1077 1478
 			if ($format == 'acarssbs3') {
1078
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1479
+			    if ($globalDebug) {
1480
+			    	echo 'ACARS : '.$buffer."\n";
1481
+			    }
1079 1482
 			    $ACARS->add(trim($buffer));
1080 1483
 			    $ACARS->deleteLiveAcarsData();
1081 1484
 			} elseif ($format == 'raw') {
@@ -1084,30 +1487,70 @@  discard block
 block discarded – undo
1084 1487
 			    if (is_array($data)) {
1085 1488
 				$data['datetime'] = date('Y-m-d H:i:s');
1086 1489
 				$data['format_source'] = 'raw';
1087
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1088
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1089
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1090
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1490
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1491
+					$data['source_name'] = $globalSources[$nb]['name'];
1492
+				}
1493
+				if (isset($globalSources[$nb]['sourcestats'])) {
1494
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1495
+				}
1496
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1497
+					$data['noarchive'] = true;
1498
+				}
1499
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1500
+					$SI->add($data);
1501
+				}
1091 1502
 			    }
1092 1503
 			} elseif ($format == 'ais') {
1093 1504
 			    $ais_data = $AIS->parse_line(trim($buffer));
1094 1505
 			    $data = array();
1095
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1096
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1097
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1098
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1099
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1100
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1101
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1102
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1103
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1104
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1105
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1106
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1107
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1108
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1109
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1110
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
+			    if (isset($ais_data['ident'])) {
1507
+			    	$data['ident'] = $ais_data['ident'];
1508
+			    }
1509
+			    if (isset($ais_data['mmsi'])) {
1510
+			    	$data['mmsi'] = $ais_data['mmsi'];
1511
+			    }
1512
+			    if (isset($ais_data['speed'])) {
1513
+			    	$data['speed'] = $ais_data['speed'];
1514
+			    }
1515
+			    if (isset($ais_data['heading'])) {
1516
+			    	$data['heading'] = $ais_data['heading'];
1517
+			    }
1518
+			    if (isset($ais_data['latitude'])) {
1519
+			    	$data['latitude'] = $ais_data['latitude'];
1520
+			    }
1521
+			    if (isset($ais_data['longitude'])) {
1522
+			    	$data['longitude'] = $ais_data['longitude'];
1523
+			    }
1524
+			    if (isset($ais_data['status'])) {
1525
+			    	$data['status'] = $ais_data['status'];
1526
+			    }
1527
+			    if (isset($ais_data['statusid'])) {
1528
+			    	$data['status_id'] = $ais_data['statusid'];
1529
+			    }
1530
+			    if (isset($ais_data['type'])) {
1531
+			    	$data['type'] = $ais_data['type'];
1532
+			    }
1533
+			    if (isset($ais_data['imo'])) {
1534
+			    	$data['imo'] = $ais_data['imo'];
1535
+			    }
1536
+			    if (isset($ais_data['callsign'])) {
1537
+			    	$data['callsign'] = $ais_data['callsign'];
1538
+			    }
1539
+			    if (isset($ais_data['destination'])) {
1540
+			    	$data['arrival_code'] = $ais_data['destination'];
1541
+			    }
1542
+			    if (isset($ais_data['eta_ts'])) {
1543
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1544
+			    }
1545
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1546
+			    	$data['noarchive'] = true;
1547
+			    }
1548
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1549
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1550
+			    }
1551
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1552
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1553
+			    }
1111 1554
 
1112 1555
 			    if (isset($ais_data['timestamp'])) {
1113 1556
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1116,7 +1559,9 @@  discard block
 block discarded – undo
1116 1559
 			    }
1117 1560
 			    $data['format_source'] = 'aisnmea';
1118 1561
     			    $data['id_source'] = $id_source;
1119
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1562
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1563
+			    	$MI->add($data);
1564
+			    }
1120 1565
 			    unset($data);
1121 1566
                         } elseif ($format == 'flightgearsp') {
1122 1567
                     	    //echo $buffer."\n";
@@ -1134,12 +1579,18 @@  discard block
 block discarded – undo
1134 1579
 				$data['speed'] = round($line[5]*1.94384);
1135 1580
 				$data['datetime'] = date('Y-m-d H:i:s');
1136 1581
 				$data['format_source'] = 'flightgearsp';
1137
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1138
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1582
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1583
+					$data['noarchive'] = true;
1584
+				}
1585
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1586
+					$SI->add($data);
1587
+				}
1139 1588
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1140 1589
 			    }
1141 1590
                         } elseif ($format == 'acars') {
1142
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1591
+                    	    if ($globalDebug) {
1592
+                    	    	echo 'ACARS : '.$buffer."\n";
1593
+                    	    }
1143 1594
 			    $ACARS->add(trim($buffer));
1144 1595
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1145 1596
 			    $ACARS->deleteLiveAcarsData();
@@ -1160,8 +1611,12 @@  discard block
 block discarded – undo
1160 1611
 				    $aircraft_type = $line[10];
1161 1612
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1162 1613
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1163
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1164
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
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
+				    }
1165 1620
 				}
1166 1621
 			    }
1167 1622
 			} elseif ($format == 'beast') {
@@ -1171,28 +1626,62 @@  discard block
 block discarded – undo
1171 1626
 			    foreach($buffer as $all_data) {
1172 1627
 				$line = json_decode('{'.$all_data.'}',true);
1173 1628
 				$data = array();
1174
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1175
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1176
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1177
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1178
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1179
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1180
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1629
+				if (isset($line['Icao'])) {
1630
+					$data['hex'] = $line['Icao'];
1631
+				}
1632
+				// hex
1633
+				if (isset($line['Call'])) {
1634
+					$data['ident'] = $line['Call'];
1635
+				}
1636
+				// ident
1637
+				if (isset($line['Alt'])) {
1638
+					$data['altitude'] = $line['Alt'];
1639
+				}
1640
+				// altitude
1641
+				if (isset($line['Spd'])) {
1642
+					$data['speed'] = $line['Spd'];
1643
+				}
1644
+				// speed
1645
+				if (isset($line['Trak'])) {
1646
+					$data['heading'] = $line['Trak'];
1647
+				}
1648
+				// heading
1649
+				if (isset($line['Lat'])) {
1650
+					$data['latitude'] = $line['Lat'];
1651
+				}
1652
+				// lat
1653
+				if (isset($line['Long'])) {
1654
+					$data['longitude'] = $line['Long'];
1655
+				}
1656
+				// long
1181 1657
 				//$data['verticalrate'] = $line['']; // verticale rate
1182
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1658
+				if (isset($line['Sqk'])) {
1659
+					$data['squawk'] = $line['Sqk'];
1660
+				}
1661
+				// squawk
1183 1662
 				$data['emergency'] = ''; // emergency
1184
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1663
+				if (isset($line['Reg'])) {
1664
+					$data['registration'] = $line['Reg'];
1665
+				}
1185 1666
 				/*
1186 1667
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1187 1668
 				else $data['datetime'] = date('Y-m-d H:i:s');
1188 1669
 				*/
1189 1670
 				$data['datetime'] = date('Y-m-d H:i:s');
1190
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1671
+				if (isset($line['Type'])) {
1672
+					$data['aircraft_icao'] = $line['Type'];
1673
+				}
1191 1674
 		    		$data['format_source'] = 'vrstcp';
1192 1675
 				$data['id_source'] = $id_source;
1193
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1195
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1676
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1677
+					$data['noarchive'] = true;
1678
+				}
1679
+				if (isset($value['name']) && $value['name'] != '') {
1680
+					$data['source_name'] = $value['name'];
1681
+				}
1682
+				if (isset($data['latitude']) && isset($data['hex'])) {
1683
+					$SI->add($data);
1684
+				}
1196 1685
 				unset($data);
1197 1686
 			    }
1198 1687
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1205,22 +1694,46 @@  discard block
 block discarded – undo
1205 1694
     				$data['hex'] = $lined['hexid'];
1206 1695
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1207 1696
     				$data['datetime'] = date('Y-m-d H:i:s');;
1208
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1209
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1210
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1211
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1212
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1213
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1214
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1697
+    				if (isset($lined['ident'])) {
1698
+    					$data['ident'] = $lined['ident'];
1699
+    				}
1700
+    				if (isset($lined['lat'])) {
1701
+    					$data['latitude'] = $lined['lat'];
1702
+    				}
1703
+    				if (isset($lined['lon'])) {
1704
+    					$data['longitude'] = $lined['lon'];
1705
+    				}
1706
+    				if (isset($lined['speed'])) {
1707
+    					$data['speed'] = $lined['speed'];
1708
+    				}
1709
+    				if (isset($lined['squawk'])) {
1710
+    					$data['squawk'] = $lined['squawk'];
1711
+    				}
1712
+    				if (isset($lined['alt'])) {
1713
+    					$data['altitude'] = $lined['alt'];
1714
+    				}
1715
+    				if (isset($lined['heading'])) {
1716
+    					$data['heading'] = $lined['heading'];
1717
+    				}
1215 1718
     				$data['id_source'] = $id_source;
1216 1719
     				$data['format_source'] = 'tsv';
1217
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1218
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1219
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1220
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1720
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1721
+    					$data['source_name'] = $globalSources[$nb]['name'];
1722
+    				}
1723
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1724
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1725
+    				}
1726
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1727
+					$data['noarchive'] = true;
1728
+				}
1729
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1730
+    					$SI->add($data);
1731
+    				}
1221 1732
     				unset($lined);
1222 1733
     				unset($data);
1223
-    			    } else $error = true;
1734
+    			    } else {
1735
+    			    	$error = true;
1736
+    			    }
1224 1737
 			} elseif ($format == 'aprs' && $use_aprs) {
1225 1738
 			    if ($aprs_connect == 0) {
1226 1739
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1245,39 +1758,86 @@  discard block
 block discarded – undo
1245 1758
 				    $aprs_last_tx = time();
1246 1759
 				    $data = array();
1247 1760
 				    //print_r($line);
1248
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1249
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1250
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1251
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1252
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1253
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1254
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1255
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1256
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1257
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1761
+				    if (isset($line['address'])) {
1762
+				    	$data['hex'] = $line['address'];
1763
+				    }
1764
+				    if (isset($line['mmsi'])) {
1765
+				    	$data['mmsi'] = $line['mmsi'];
1766
+				    }
1767
+				    if (isset($line['imo'])) {
1768
+				    	$data['imo'] = $line['imo'];
1769
+				    }
1770
+				    if (isset($line['squawk'])) {
1771
+				    	$data['squawk'] = $line['squawk'];
1772
+				    }
1773
+				    if (isset($line['arrival_code'])) {
1774
+				    	$data['arrical_code'] = $line['arrival_code'];
1775
+				    }
1776
+				    if (isset($line['arrival_date'])) {
1777
+				    	$data['arrical_date'] = $line['arrival_date'];
1778
+				    }
1779
+				    if (isset($line['type_id'])) {
1780
+				    	$data['type_id'] = $line['typeid'];
1781
+				    }
1782
+				    if (isset($line['status_id'])) {
1783
+				    	$data['status_id'] = $line['statusid'];
1784
+				    }
1785
+				    if (isset($line['timestamp'])) {
1786
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1787
+				    } else {
1788
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1789
+				    }
1258 1790
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1259
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1791
+				    if (isset($line['ident'])) {
1792
+				    	$data['ident'] = $line['ident'];
1793
+				    }
1260 1794
 				    $data['latitude'] = $line['latitude'];
1261 1795
 				    $data['longitude'] = $line['longitude'];
1262 1796
 				    //$data['verticalrate'] = $line[16];
1263
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1264
-				    else $data['speed'] = 0;
1265
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1266
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1267
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1268
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1797
+				    if (isset($line['speed'])) {
1798
+				    	$data['speed'] = $line['speed'];
1799
+				    } else {
1800
+				    	$data['speed'] = 0;
1801
+				    }
1802
+				    if (isset($line['altitude'])) {
1803
+				    	$data['altitude'] = $line['altitude'];
1804
+				    }
1805
+				    if (isset($line['comment'])) {
1806
+				    	$data['comment'] = $line['comment'];
1807
+				    }
1808
+				    if (isset($line['symbol'])) {
1809
+				    	$data['type'] = $line['symbol'];
1810
+				    }
1811
+				    if (isset($line['heading'])) {
1812
+				    	$data['heading'] = $line['heading'];
1813
+				    }
1269 1814
 				    //else $data['heading'] = 0;
1270
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1271
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1272
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1273
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1815
+				    if (isset($line['stealth'])) {
1816
+				    	$data['aircraft_type'] = $line['stealth'];
1817
+				    }
1818
+				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) {
1819
+				    	$data['noarchive'] = true;
1820
+				    }
1821
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1822
+				    	$data['noarchive'] = true;
1823
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1824
+				    	$data['noarchive'] = false;
1825
+				    }
1274 1826
     				    $data['id_source'] = $id_source;
1275
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1276
-				    else $data['format_source'] = 'aprs';
1827
+    				    if (isset($line['format_source'])) {
1828
+    				    	$data['format_source'] = $line['format_source'];
1829
+    				    } else {
1830
+				    	$data['format_source'] = 'aprs';
1831
+				    }
1277 1832
 				    $data['source_name'] = $line['source'];
1278
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1279
-				    else $data['source_type'] = 'flarm';
1280
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1833
+				    if (isset($line['source_type'])) {
1834
+				    	$data['source_type'] = $line['source_type'];
1835
+				    } else {
1836
+				    	$data['source_type'] = 'flarm';
1837
+				    }
1838
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1839
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1840
+    				    }
1281 1841
 				    $currentdate = date('Y-m-d H:i:s');
1282 1842
 				    $aprsdate = strtotime($data['datetime']);
1283 1843
 				    // Accept data if time <= system time + 20s
@@ -1285,21 +1845,26 @@  discard block
 block discarded – undo
1285 1845
 				    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'])))) {
1286 1846
 					$send = $SI->add($data);
1287 1847
 				    } elseif ($data['source_type'] == 'ais') {
1288
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1848
+					if (isset($globalMarine) && $globalMarine) {
1849
+						$send = $MI->add($data);
1850
+					}
1289 1851
 				    } elseif (isset($line['stealth'])) {
1290
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1291
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1852
+					if ($line['stealth'] != 0) {
1853
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1854
+					} else {
1855
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1856
+					}
1292 1857
 				    //} 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')) {
1293 1858
 				    } 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') {
1294 1859
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1295
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1860
+					if (isset($globalTracker) && $globalTracker) {
1861
+						$send = $TI->add($data);
1862
+					}
1296 1863
 				    }
1297 1864
 				    unset($data);
1298
-				} 
1299
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1865
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1300 1866
 					echo '!! Weather Station not yet supported'."\n";
1301
-				}
1302
-				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')) {
1867
+				} 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')) {
1303 1868
 					echo '!! Car & Trucks not yet supported'."\n";
1304 1869
 				}
1305 1870
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1332,26 +1897,45 @@  discard block
 block discarded – undo
1332 1897
     				$data['ground'] = $line[21];
1333 1898
     				$data['emergency'] = $line[19];
1334 1899
     				$data['format_source'] = 'sbs';
1335
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1336
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1337
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1900
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1901
+					$data['source_name'] = $globalSources[$nb]['name'];
1902
+				}
1903
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1904
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1905
+    				}
1906
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1907
+					$data['noarchive'] = true;
1908
+				}
1338 1909
     				$data['id_source'] = $id_source;
1339
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1340
-    				else $error = true;
1910
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1911
+    					$send = $SI->add($data);
1912
+    				} else {
1913
+    					$error = true;
1914
+    				}
1341 1915
     				unset($data);
1342
-    			    } else $error = true;
1916
+    			    } else {
1917
+    			    	$error = true;
1918
+    			    }
1343 1919
 			    if ($error) {
1344 1920
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1345
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1921
+					if ($globalDebug) {
1922
+						echo "Not a message. Ignoring... \n";
1923
+					}
1346 1924
 				} else {
1347
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1925
+					if ($globalDebug) {
1926
+						echo "Wrong line format. Ignoring... \n";
1927
+					}
1348 1928
 					if ($globalDebug) {
1349 1929
 						echo $buffer;
1350 1930
 						//print_r($line);
1351 1931
 					}
1352 1932
 					//socket_close($r);
1353
-					if ($globalDebug) echo "Reconnect after an error...\n";
1354
-					if ($format == 'aprs') $aprs_connect = 0;
1933
+					if ($globalDebug) {
1934
+						echo "Reconnect after an error...\n";
1935
+					}
1936
+					if ($format == 'aprs') {
1937
+						$aprs_connect = 0;
1938
+					}
1355 1939
 					$sourceer[$nb] = $globalSources[$nb];
1356 1940
 					connect_all($sourceer);
1357 1941
 					$sourceer = array();
@@ -1359,10 +1943,14 @@  discard block
 block discarded – undo
1359 1943
 			    }
1360 1944
 			}
1361 1945
 			// Sleep for xxx microseconds
1362
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1946
+			if (isset($globalSBSSleep)) {
1947
+				usleep($globalSBSSleep);
1948
+			}
1363 1949
 		    } else {
1364 1950
 			if ($format == 'flightgearmp') {
1365
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1951
+			    	if ($globalDebug) {
1952
+			    		echo "Reconnect FlightGear MP...";
1953
+			    	}
1366 1954
 				//@socket_close($r);
1367 1955
 				sleep($globalMinFetch);
1368 1956
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1371,10 +1959,15 @@  discard block
 block discarded – undo
1371 1959
 				break;
1372 1960
 				
1373 1961
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1374
-			    if (isset($tt[$format])) $tt[$format]++;
1375
-			    else $tt[$format] = 0;
1962
+			    if (isset($tt[$format])) {
1963
+			    	$tt[$format]++;
1964
+			    } else {
1965
+			    	$tt[$format] = 0;
1966
+			    }
1376 1967
 			    if ($tt[$format] > 30) {
1377
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1968
+				if ($globalDebug) {
1969
+					echo "ERROR : Reconnect ".$format."...";
1970
+				}
1378 1971
 				//@socket_close($r);
1379 1972
 				sleep(2);
1380 1973
 				$aprs_connect = 0;
@@ -1391,11 +1984,17 @@  discard block
 block discarded – undo
1391 1984
 	    } else {
1392 1985
 		$error = socket_strerror(socket_last_error());
1393 1986
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1394
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1395
-			if (isset($globalDebug)) echo "Restarting...\n";
1987
+			if ($globalDebug) {
1988
+				echo "ERROR : socket_select give this error ".$error . "\n";
1989
+			}
1990
+			if (isset($globalDebug)) {
1991
+				echo "Restarting...\n";
1992
+			}
1396 1993
 			// Restart the script if possible
1397 1994
 			if (is_array($sockets)) {
1398
-			    if ($globalDebug) echo "Shutdown all sockets...";
1995
+			    if ($globalDebug) {
1996
+			    	echo "Shutdown all sockets...";
1997
+			    }
1399 1998
 			    
1400 1999
 			    foreach ($sockets as $sock) {
1401 2000
 				@socket_shutdown($sock,2);
@@ -1403,22 +2002,36 @@  discard block
 block discarded – undo
1403 2002
 			    }
1404 2003
 			    
1405 2004
 			}
1406
-			if ($globalDebug) echo "Waiting...";
2005
+			if ($globalDebug) {
2006
+				echo "Waiting...";
2007
+			}
1407 2008
 			sleep(2);
1408 2009
 			$time = time();
1409 2010
 			//connect_all($hosts);
1410 2011
 			$aprs_connect = 0;
1411
-			if ($reset%5 == 0) sleep(20);
1412
-			if ($reset%10 == 0) sleep(100);
1413
-			if ($reset%20 == 0) sleep(200);
1414
-			if ($reset > 100) exit('Too many attempts...');
1415
-			if ($globalDebug) echo "Restart all connections...";
2012
+			if ($reset%5 == 0) {
2013
+				sleep(20);
2014
+			}
2015
+			if ($reset%10 == 0) {
2016
+				sleep(100);
2017
+			}
2018
+			if ($reset%20 == 0) {
2019
+				sleep(200);
2020
+			}
2021
+			if ($reset > 100) {
2022
+				exit('Too many attempts...');
2023
+			}
2024
+			if ($globalDebug) {
2025
+				echo "Restart all connections...";
2026
+			}
1416 2027
 			connect_all($globalSources);
1417 2028
 		}
1418 2029
 	    }
1419 2030
 	}
1420 2031
 	if ($globalDaemon === false) {
1421
-	    if ($globalDebug) echo 'Check all...'."\n";
2032
+	    if ($globalDebug) {
2033
+	    	echo 'Check all...'."\n";
2034
+	    }
1422 2035
 	    $SI->checkAll();
1423 2036
 	}
1424 2037
     }
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@  discard block
 block discarded – undo
5 5
 $marine = false;
6 6
 $usecoord = false;
7 7
 if (isset($_GET['tracker'])) {
8
-    $tracker = true;
8
+	$tracker = true;
9 9
 }
10 10
 if (isset($_GET['marine'])) {
11
-    $marine = true;
11
+	$marine = true;
12 12
 }
13 13
 if ($tracker) {
14
-    require_once('require/class.Tracker.php');
15
-    require_once('require/class.TrackerLive.php');
16
-    require_once('require/class.TrackerArchive.php');
14
+	require_once('require/class.Tracker.php');
15
+	require_once('require/class.TrackerLive.php');
16
+	require_once('require/class.TrackerArchive.php');
17 17
 } elseif ($marine) {
18
-    require_once('require/class.Marine.php');
19
-    require_once('require/class.MarineLive.php');
20
-    require_once('require/class.MarineArchive.php');
18
+	require_once('require/class.Marine.php');
19
+	require_once('require/class.MarineLive.php');
20
+	require_once('require/class.MarineArchive.php');
21 21
 } else {
22
-    require_once('require/class.Spotter.php');
23
-    require_once('require/class.SpotterLive.php');
24
-    require_once('require/class.SpotterArchive.php');
22
+	require_once('require/class.Spotter.php');
23
+	require_once('require/class.SpotterLive.php');
24
+	require_once('require/class.SpotterArchive.php');
25 25
 }
26 26
 
27 27
 $begintime = microtime(true);
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 $Common = new Common();
42 42
 
43 43
 if (isset($_GET['download'])) {
44
-    if ($_GET['download'] == "true")
45
-    {
44
+	if ($_GET['download'] == "true")
45
+	{
46 46
 	header('Content-disposition: attachment; filename="flightairmap.json"');
47
-    }
47
+	}
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
@@ -497,17 +497,17 @@  discard block
 block discarded – undo
497 497
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
498 498
 				
499 499
 				if (
500
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
501
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
500
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
501
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
502 502
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
503 503
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
504
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
505
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
506
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
507
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
508
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
509
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
510
-				    ) {
504
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
505
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
506
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
507
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
508
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
509
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
510
+					) {
511 511
 					if ($tracker) {
512 512
 						if ($from_archive || $globalArchive) {
513 513
 							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']);
@@ -596,66 +596,66 @@  discard block
 block discarded – undo
596 596
 				}
597 597
 				
598 598
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
599
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
600
-				     && (isset($spotter_item['departure_airport']) 
601
-				        && $spotter_item['departure_airport'] != 'NA' 
602
-				        && isset($spotter_item['arrival_airport']) 
603
-				        && $spotter_item['arrival_airport'] != 'NA' 
604
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
605
-				    	    || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
606
-				    	    || (isset($globalMapRoute) && $globalMapRoute)))))) {
607
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
608
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
609
-				    if (isset($spotter_item['departure_airport_latitude'])) {
599
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
600
+					 && (isset($spotter_item['departure_airport']) 
601
+						&& $spotter_item['departure_airport'] != 'NA' 
602
+						&& isset($spotter_item['arrival_airport']) 
603
+						&& $spotter_item['arrival_airport'] != 'NA' 
604
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
605
+							|| (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
606
+							|| (isset($globalMapRoute) && $globalMapRoute)))))) {
607
+					if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
608
+					else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
609
+					if (isset($spotter_item['departure_airport_latitude'])) {
610 610
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
611
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
611
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
612 612
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
613 613
 					if (isset($dairport[0]['latitude'])) {
614
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
614
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
615 615
 					}
616
-				    }
617
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
616
+					}
617
+					if (isset($spotter_item['arrival_airport_latitude'])) {
618 618
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],';
619
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
619
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
620 620
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
621 621
 					if (isset($aairport[0]['latitude'])) {
622
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
622
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
623 623
 					}
624
-				    }
625
-				    $output_air  = substr($output_air, 0, -1);
626
-				    $output_air .= ']}},';
627
-				    $output .= $output_air;
628
-				    unset($output_air);
624
+					}
625
+					$output_air  = substr($output_air, 0, -1);
626
+					$output_air .= ']}},';
627
+					$output .= $output_air;
628
+					unset($output_air);
629 629
 				}
630 630
 
631 631
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
632 632
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
633 633
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
634
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
635
-				     && (isset($spotter_item['arrival_airport']) 
636
-				        && $spotter_item['arrival_airport'] != 'NA' 
637
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
638
-				    	    || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
639
-				    	    || (isset($globalMapRoute) && $globalMapRoute)))))) {
640
-				    $havedata = false;
641
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
642
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
643
-				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
634
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
635
+					 && (isset($spotter_item['arrival_airport']) 
636
+						&& $spotter_item['arrival_airport'] != 'NA' 
637
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
638
+							|| (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
639
+							|| (isset($globalMapRoute) && $globalMapRoute)))))) {
640
+					$havedata = false;
641
+					if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
642
+					else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
643
+					$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
644 644
 
645
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
645
+					if (isset($spotter_item['arrival_airport_latitude'])) {
646 646
 					$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
647 647
 					$havedata = true;
648
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
648
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
649 649
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
650 650
 					if (isset($aairport[0]['latitude'])) {
651
-					    $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
652
-					    $havedata = true;
651
+						$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
652
+						$havedata = true;
653 653
 					}
654
-				    }
655
-				    //$output_dest  = substr($output_dest, 0, -1);
656
-				    $output_dest .= ']}},';
657
-				    if ($havedata) $output .= $output_dest;
658
-				    unset($output_dest);
654
+					}
655
+					//$output_dest  = substr($output_dest, 0, -1);
656
+					$output_dest .= ']}},';
657
+					if ($havedata) $output .= $output_dest;
658
+					unset($output_dest);
659 659
 				}
660 660
 			}
661 661
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
 $min = true;
56 56
 $allhistory = false;
57 57
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
58
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
60
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
61
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
63
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
64
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
65
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
66
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
67
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
68 68
 
69 69
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 70
 	$min = true;
71 71
 } else $min = false;
72 72
 
73 73
 if (isset($_GET['ident'])) {
74
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
74
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
75 75
 	if ($tracker) {
76 76
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
77 77
 	} elseif ($marine) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 	$allhistory = true;
87 87
 } elseif (isset($_GET['flightaware_id'])) {
88
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
88
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
89 89
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
90 90
 	if (empty($spotter_array)) {
91 91
 		$from_archive = true;
@@ -93,44 +93,44 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 	$allhistory = true;
95 95
 } elseif (isset($_GET['famtrack_id'])) {
96
-	$famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING);
96
+	$famtrack_id = filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING);
97 97
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['fammarine_id'])) {
100
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
100
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
101 101
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
102 102
 	$allhistory = true;
103 103
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
104 104
 //} elseif (isset($_GET['coord'])) {
105 105
 	$usecoord = true;
106
-	$coord = explode(',',$_GET['coord']);
106
+	$coord = explode(',', $_GET['coord']);
107 107
 	if ($tracker) {
108
-		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter);
108
+		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter);
109 109
 	} elseif ($marine) {
110
-		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter);
110
+		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter);
111 111
 	} else {
112
-		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
112
+		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
113 113
 	}
114 114
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
115 115
 	$usecoord = true;
116
-	$coord = explode(',',$_GET['coord']);
116
+	$coord = explode(',', $_GET['coord']);
117 117
 	if ($tracker) {
118
-		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
118
+		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
119 119
 	} elseif ($marine) {
120
-		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
120
+		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
121 121
 	} else {
122
-		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
122
+		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
123 123
 	}
124 124
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
125 125
 	$from_archive = true;
126 126
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127 127
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
128
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
129
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
130
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
131
-	$begindate = date('Y-m-d H:i:s',$begindate);
132
-	$enddate = date('Y-m-d H:i:s',$enddate);
133
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
128
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
129
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
130
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
131
+	$begindate = date('Y-m-d H:i:s', $begindate);
132
+	$enddate = date('Y-m-d H:i:s', $enddate);
133
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
134 134
 } elseif ($min) {
135 135
 	if ($tracker) {
136 136
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 #	$min = true;
143 143
 } else {
144 144
 	if ($tracker) {
145
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
145
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
146 146
 	} elseif ($marine) {
147
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
147
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
148 148
 	} else {
149
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
149
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
150 150
 	}
151 151
 }
152 152
 
153 153
 if (!empty($spotter_array) || $usecoord) {
154 154
 	if ($usecoord) {
155 155
 		if (isset($_GET['archive'])) {
156
-			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
156
+			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
157 157
 		} else {
158 158
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 159
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if ($flightcnt == '') $flightcnt = 0;
162 162
 } else $flightcnt = 0;
163 163
 
164
-$sqltime = round(microtime(true)-$begintime,2);
164
+$sqltime = round(microtime(true) - $begintime, 2);
165 165
 
166 166
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167 167
 else $usenextlatlon = true;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if (!empty($spotter_array) && is_array($spotter_array))
179 179
 		{
180 180
 			$output .= '"features": [';
181
-			foreach($spotter_array as $spotter_item)
181
+			foreach ($spotter_array as $spotter_item)
182 182
 			{
183 183
 				$j++;
184 184
 				date_default_timezone_set('UTC');
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 */
235 235
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 236
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
238
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
237
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
238
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
239 239
 							//"
240 240
 						} else {
241 241
 							if ($compress) $output .= '"c": "NA",';
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
245 245
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
246 246
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
247
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
247
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
248 248
 						} elseif (isset($spotter_item['aircraft_type'])) {
249 249
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
250 250
 						} elseif (!$min) {
@@ -384,16 +384,16 @@  discard block
 block discarded – undo
384 384
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
385 385
 						
386 386
 						if (isset($archivespeed)) {
387
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
387
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
388 388
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
389 389
 						} elseif ($usenextlatlon) {
390
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
390
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
391 391
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
392 392
 						}
393 393
 
394 394
 						if (!$min) $output .= '"image": "'.$image.'",';
395 395
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
396
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
396
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
397 397
 						}
398 398
 						if (isset($spotter_item['image_source_website'])) {
399 399
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
416 416
 						}
417 417
 						if (isset($spotter_item['acars'])) {
418
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
418
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
419 419
 						}
420 420
 						// type when not aircraft ?
421 421
 						if (isset($spotter_item['type'])) {
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
                 
494 494
 			}
495 495
 */
496
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
496
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
497 497
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
498 498
 				
499 499
 				if (
@@ -501,11 +501,11 @@  discard block
 block discarded – undo
501 501
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
502 502
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
503 503
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
504
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
504
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
505 505
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
506
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
506
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
507 507
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
508
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
508
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
509 509
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
510 510
 				    ) {
511 511
 					if ($tracker) {
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
543 543
 							}
544 544
 							$output_history .= '[';
545
-							$output_history .=  $spotter_history['longitude'].', ';
546
-							$output_history .=  $spotter_history['latitude'].', ';
547
-							$output_history .=  $spotter_history['altitude']*30.48;
545
+							$output_history .= $spotter_history['longitude'].', ';
546
+							$output_history .= $spotter_history['latitude'].', ';
547
+							$output_history .= $spotter_history['altitude']*30.48;
548 548
 							$output_history .= '],';
549 549
 							/*
550 550
 							if ($from_archive === false) {
@@ -562,8 +562,8 @@  discard block
 block discarded – undo
562 562
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
563 563
 							} else $d = true;
564 564
 							$output_history .= '[';
565
-							$output_history .=  $spotter_history['longitude'].', ';
566
-							$output_history .=  $spotter_history['latitude'];
565
+							$output_history .= $spotter_history['longitude'].', ';
566
+							$output_history .= $spotter_history['latitude'];
567 567
 							$output_history .= '],';
568 568
 							/*
569 569
 							if ($from_archive === false) {
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 					
580 580
 						if ($from_archive === false) {
581 581
 							$output_historyd = '[';
582
-							$output_historyd .=  $spotter_item['longitude'].', ';
583
-							$output_historyd .=  $spotter_item['latitude'];
584
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
582
+							$output_historyd .= $spotter_item['longitude'].', ';
583
+							$output_historyd .= $spotter_item['latitude'];
584
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
585 585
 							$output_historyd .= '],';
586 586
 							//$output_history = $output_historyd.$output_history;
587 587
 							$output_history = $output_history.$output_historyd;
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 					}
596 596
 				}
597 597
 				
598
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
598
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
599 599
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
600 600
 				     && (isset($spotter_item['departure_airport']) 
601 601
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
632 632
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
633
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
633
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
634 634
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
635 635
 				     && (isset($spotter_item['arrival_airport']) 
636 636
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			$output  = substr($output, 0, -1);
662 662
 			$output .= ']';
663 663
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
664
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
664
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
665 665
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
666 666
 			$output .= '"fc": "'.$j.'"';
667 667
 		} else {
Please login to merge, or discard this patch.
Braces   +289 added lines, -113 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		//$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,14 +282,22 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
238
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
287
+							} else {
288
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
289
+							}
239 290
 							//"
240 291
 						} else {
241
-							if ($compress) $output .= '"c": "NA",';
242
-							else $output .= '"callsign": "NA",';
292
+							if ($compress) {
293
+								$output .= '"c": "NA",';
294
+							} else {
295
+								$output .= '"callsign": "NA",';
296
+							}
297
+						}
298
+						if (isset($spotter_item['registration'])) {
299
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
243 300
 						}
244
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
245 301
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
246 302
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
247 303
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -254,15 +310,21 @@  discard block
 block discarded – undo
254 310
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
255 311
 						}
256 312
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
257
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
258
-							else {
313
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
314
+								$spotter_item['aircraft_shadow'] = '';
315
+							} else {
259 316
 								$aircraft_icao = $spotter_item['aircraft_icao'];
260
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
261
-								else {
317
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
318
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
319
+								} else {
262 320
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
263
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
264
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
265
-									else $spotter_item['aircraft_shadow'] = '';
321
+									if (count($aircraft_info) > 0) {
322
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
323
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
324
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
325
+									} else {
326
+										$spotter_item['aircraft_shadow'] = '';
327
+									}
266 328
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
267 329
 								}
268 330
 							}
@@ -270,73 +332,139 @@  discard block
 block discarded – undo
270 332
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
271 333
 							if ($tracker) {
272 334
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
273
-									if ($compress) $output .= '"as": "ambulance.png",';
274
-									else $output .= '"aircraft_shadow": "ambulance.png",';
335
+									if ($compress) {
336
+										$output .= '"as": "ambulance.png",';
337
+									} else {
338
+										$output .= '"aircraft_shadow": "ambulance.png",';
339
+									}
275 340
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
276
-									if ($compress) $output .= '"as": "police.png",';
277
-									else $output .= '"aircraft_shadow": "police.png",';
341
+									if ($compress) {
342
+										$output .= '"as": "police.png",';
343
+									} else {
344
+										$output .= '"aircraft_shadow": "police.png",';
345
+									}
278 346
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
279
-									if ($compress) $output .= '"as": "ship.png",';
280
-									else $output .= '"aircraft_shadow": "ship.png",';
347
+									if ($compress) {
348
+										$output .= '"as": "ship.png",';
349
+									} else {
350
+										$output .= '"aircraft_shadow": "ship.png",';
351
+									}
281 352
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
282
-									if ($compress) $output .= '"as": "ship.png",';
283
-									else $output .= '"aircraft_shadow": "ship.png",';
353
+									if ($compress) {
354
+										$output .= '"as": "ship.png",';
355
+									} else {
356
+										$output .= '"aircraft_shadow": "ship.png",';
357
+									}
284 358
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
285
-									if ($compress) $output .= '"as": "ship.png",';
286
-									else $output .= '"aircraft_shadow": "ship.png",';
359
+									if ($compress) {
360
+										$output .= '"as": "ship.png",';
361
+									} else {
362
+										$output .= '"aircraft_shadow": "ship.png",';
363
+									}
287 364
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
288
-									if ($compress) $output .= '"as": "truck.png",';
289
-									else $output .= '"aircraft_shadow": "truck.png",';
365
+									if ($compress) {
366
+										$output .= '"as": "truck.png",';
367
+									} else {
368
+										$output .= '"aircraft_shadow": "truck.png",';
369
+									}
290 370
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
291
-									if ($compress) $output .= '"as": "truck.png",';
292
-									else $output .= '"aircraft_shadow": "truck.png",';
371
+									if ($compress) {
372
+										$output .= '"as": "truck.png",';
373
+									} else {
374
+										$output .= '"aircraft_shadow": "truck.png",';
375
+									}
293 376
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
294
-									if ($compress) $output .= '"as": "aircraft.png",';
295
-									else $output .= '"aircraft_shadow": "aircraft.png",';
377
+									if ($compress) {
378
+										$output .= '"as": "aircraft.png",';
379
+									} else {
380
+										$output .= '"aircraft_shadow": "aircraft.png",';
381
+									}
296 382
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
297
-									if ($compress) $output .= '"as": "aircraft.png",';
298
-									else $output .= '"aircraft_shadow": "aircraft.png",';
383
+									if ($compress) {
384
+										$output .= '"as": "aircraft.png",';
385
+									} else {
386
+										$output .= '"aircraft_shadow": "aircraft.png",';
387
+									}
299 388
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
300
-									if ($compress) $output .= '"as": "helico.png",';
301
-									else $output .= '"aircraft_shadow": "helico.png",';
389
+									if ($compress) {
390
+										$output .= '"as": "helico.png",';
391
+									} else {
392
+										$output .= '"aircraft_shadow": "helico.png",';
393
+									}
302 394
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
303
-									if ($compress) $output .= '"as": "rail.png",';
304
-									else $output .= '"aircraft_shadow": "rail.png",';
395
+									if ($compress) {
396
+										$output .= '"as": "rail.png",';
397
+									} else {
398
+										$output .= '"aircraft_shadow": "rail.png",';
399
+									}
305 400
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
306
-									if ($compress) $output .= '"as": "firetruck.png",';
307
-									else $output .= '"aircraft_shadow": "firetruck.png",';
401
+									if ($compress) {
402
+										$output .= '"as": "firetruck.png",';
403
+									} else {
404
+										$output .= '"aircraft_shadow": "firetruck.png",';
405
+									}
308 406
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
309
-									if ($compress) $output .= '"as": "bus.png",';
310
-									else $output .= '"aircraft_shadow": "bus.png",';
407
+									if ($compress) {
408
+										$output .= '"as": "bus.png",';
409
+									} else {
410
+										$output .= '"aircraft_shadow": "bus.png",';
411
+									}
311 412
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
312
-									if ($compress) $output .= '"as": "phone.png",';
313
-									else $output .= '"aircraft_shadow": "phone.png",';
413
+									if ($compress) {
414
+										$output .= '"as": "phone.png",';
415
+									} else {
416
+										$output .= '"aircraft_shadow": "phone.png",';
417
+									}
314 418
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
315
-									if ($compress) $output .= '"as": "jogger.png",';
316
-									else $output .= '"aircraft_shadow": "jogger.png",';
419
+									if ($compress) {
420
+										$output .= '"as": "jogger.png",';
421
+									} else {
422
+										$output .= '"aircraft_shadow": "jogger.png",';
423
+									}
317 424
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
318
-									if ($compress) $output .= '"as": "bike.png",';
319
-									else $output .= '"aircraft_shadow": "bike.png",';
425
+									if ($compress) {
426
+										$output .= '"as": "bike.png",';
427
+									} else {
428
+										$output .= '"aircraft_shadow": "bike.png",';
429
+									}
320 430
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
321
-									if ($compress) $output .= '"as": "motorcycle.png",';
322
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
431
+									if ($compress) {
432
+										$output .= '"as": "motorcycle.png",';
433
+									} else {
434
+										$output .= '"aircraft_shadow": "motorcycle.png",';
435
+									}
323 436
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
324
-									if ($compress) $output .= '"as": "balloon.png",';
325
-									else $output .= '"aircraft_shadow": "balloon.png",';
437
+									if ($compress) {
438
+										$output .= '"as": "balloon.png",';
439
+									} else {
440
+										$output .= '"aircraft_shadow": "balloon.png",';
441
+									}
326 442
 								} else {
327
-									if ($compress) $output .= '"as": "car.png",';
328
-									else $output .= '"aircraft_shadow": "car.png",';
443
+									if ($compress) {
444
+										$output .= '"as": "car.png",';
445
+									} else {
446
+										$output .= '"aircraft_shadow": "car.png",';
447
+									}
329 448
 								}
330 449
 							} elseif ($marine) {
331
-								if ($compress) $output .= '"as": "ship.png",';
332
-								else $output .= '"aircraft_shadow": "ship.png",';
450
+								if ($compress) {
451
+									$output .= '"as": "ship.png",';
452
+								} else {
453
+									$output .= '"aircraft_shadow": "ship.png",';
454
+								}
333 455
 							} else {
334
-								if ($compress) $output .= '"as": "default.png",';
335
-								else $output .= '"aircraft_shadow": "default.png",';
456
+								if ($compress) {
457
+									$output .= '"as": "default.png",';
458
+								} else {
459
+									$output .= '"aircraft_shadow": "default.png",';
460
+								}
336 461
 							}
337 462
 						} else {
338
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
339
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
463
+							if ($compress) {
464
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
465
+							} else {
466
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
467
+							}
340 468
 						}
341 469
 						if (isset($spotter_item['airline_name'])) {
342 470
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -344,8 +472,11 @@  discard block
 block discarded – undo
344 472
 							$output .= '"airline_name": "NA",';
345 473
 						}
346 474
 						if (isset($spotter_item['departure_airport'])) {
347
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
348
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
475
+							if ($compress) {
476
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
477
+							} else {
478
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
479
+							}
349 480
 						}
350 481
 						if (isset($spotter_item['departure_airport_city'])) {
351 482
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -357,8 +488,11 @@  discard block
 block discarded – undo
357 488
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
358 489
 						}
359 490
 						if (isset($spotter_item['arrival_airport'])) {
360
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
361
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
491
+							if ($compress) {
492
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
493
+							} else {
494
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
495
+							}
362 496
 						}
363 497
 						if (isset($spotter_item['arrival_airport_city'])) {
364 498
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -377,11 +511,17 @@  discard block
 block discarded – undo
377 511
 						}
378 512
 						
379 513
 						if (isset($spotter_item['altitude'])) {
380
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
381
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
514
+							if ($compress) {
515
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
516
+							} else {
517
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
518
+							}
519
+						}
520
+						if ($compress) {
521
+							$output .= '"h": "'.$spotter_item['heading'].'",';
522
+						} else {
523
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
382 524
 						}
383
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
384
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
385 525
 						
386 526
 						if (isset($archivespeed)) {
387 527
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -391,7 +531,9 @@  discard block
 block discarded – undo
391 531
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
392 532
 						}
393 533
 
394
-						if (!$min) $output .= '"image": "'.$image.'",';
534
+						if (!$min) {
535
+							$output .= '"image": "'.$image.'",';
536
+						}
395 537
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
396 538
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
397 539
 						}
@@ -399,8 +541,11 @@  discard block
 block discarded – undo
399 541
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
400 542
 						}
401 543
 						if (isset($spotter_item['squawk'])) {
402
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
403
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
544
+							if ($compress) {
545
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
546
+							} else {
547
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
548
+							}
404 549
 						}
405 550
 						if (isset($spotter_item['squawk_usage'])) {
406 551
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -419,14 +564,23 @@  discard block
 block discarded – undo
419 564
 						}
420 565
 						// type when not aircraft ?
421 566
 						if (isset($spotter_item['type'])) {
422
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
423
-							else $output .= '"type": "'.$spotter_item['type'].'"';
567
+							if ($compress) {
568
+								$output .= '"t": "'.$spotter_item['type'].'"';
569
+							} else {
570
+								$output .= '"type": "'.$spotter_item['type'].'"';
571
+							}
424 572
 						} elseif ($marine) {
425
-							if ($compress) $output .= '"t": "ship"';
426
-							else $output .= '"type": "ship"';
573
+							if ($compress) {
574
+								$output .= '"t": "ship"';
575
+							} else {
576
+								$output .= '"type": "ship"';
577
+							}
427 578
 						} else {
428
-							if ($compress) $output .= '"t": "aircraft"';
429
-							else $output .= '"type": "aircraft"';
579
+							if ($compress) {
580
+								$output .= '"t": "aircraft"';
581
+							} else {
582
+								$output .= '"type": "aircraft"';
583
+							}
430 584
 						}
431 585
 						$output .= '},';
432 586
 						$output .= '"geometry": {';
@@ -494,7 +648,9 @@  discard block
 block discarded – undo
494 648
 			}
495 649
 */
496 650
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
497
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
651
+				if ($history == '' && isset($_COOKIE['history'])) {
652
+					$history = $_COOKIE['history'];
653
+				}
498 654
 				
499 655
 				if (
500 656
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -538,8 +694,11 @@  discard block
 block discarded – undo
538 694
 									$output_history .= ']}},';
539 695
 									$output .= $output_history;
540 696
 								}
541
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
542
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
697
+								if ($compress) {
698
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
699
+								} else {
700
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
+								}
543 702
 							}
544 703
 							$output_history .= '[';
545 704
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -558,9 +717,14 @@  discard block
 block discarded – undo
558 717
 							$prev_alt = $alt;
559 718
 						} else {
560 719
 							if ($d == false) {
561
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
562
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
563
-							} else $d = true;
720
+								if ($compress) {
721
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
722
+								} else {
723
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
724
+								}
725
+							} else {
726
+								$d = true;
727
+							}
564 728
 							$output_history .= '[';
565 729
 							$output_history .=  $spotter_history['longitude'].', ';
566 730
 							$output_history .=  $spotter_history['latitude'];
@@ -581,7 +745,9 @@  discard block
 block discarded – undo
581 745
 							$output_historyd = '[';
582 746
 							$output_historyd .=  $spotter_item['longitude'].', ';
583 747
 							$output_historyd .=  $spotter_item['latitude'];
584
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
748
+							if (isset($spotter_history['altitude'])) {
749
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
750
+							}
585 751
 							$output_historyd .= '],';
586 752
 							//$output_history = $output_historyd.$output_history;
587 753
 							$output_history = $output_history.$output_historyd;
@@ -604,8 +770,11 @@  discard block
 block discarded – undo
604 770
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
605 771
 				    	    || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
606 772
 				    	    || (isset($globalMapRoute) && $globalMapRoute)))))) {
607
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
608
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
773
+				    if ($compress) {
774
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
775
+				    } else {
776
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
777
+				    }
609 778
 				    if (isset($spotter_item['departure_airport_latitude'])) {
610 779
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
611 780
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -638,8 +807,11 @@  discard block
 block discarded – undo
638 807
 				    	    || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) 
639 808
 				    	    || (isset($globalMapRoute) && $globalMapRoute)))))) {
640 809
 				    $havedata = false;
641
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
642
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
810
+				    if ($compress) {
811
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
812
+				    } else {
813
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
814
+				    }
643 815
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
644 816
 
645 817
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -654,7 +826,9 @@  discard block
 block discarded – undo
654 826
 				    }
655 827
 				    //$output_dest  = substr($output_dest, 0, -1);
656 828
 				    $output_dest .= ']}},';
657
-				    if ($havedata) $output .= $output_dest;
829
+				    if ($havedata) {
830
+				    	$output .= $output_dest;
831
+				    }
658 832
 				    unset($output_dest);
659 833
 				}
660 834
 			}
@@ -662,7 +836,9 @@  discard block
 block discarded – undo
662 836
 			$output .= ']';
663 837
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
664 838
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
665
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
839
+			if (isset($begindate)) {
840
+				$output .= '"archive_date": "'.$begindate.'",';
841
+			}
666 842
 			$output .= '"fc": "'.$j.'"';
667 843
 		} else {
668 844
 			$output .= '"features": ';
Please login to merge, or discard this patch.