Completed
Push — master ( 8d4415...1bf6ad )
by Yannick
72:06 queued 32:47
created
require/class.TrackerImport.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source($this->db);
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
header.php 3 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@  discard block
 block discarded – undo
14 14
 if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
15 15
 
16 16
 if (isset($_GET['3d'])) {
17
-	setcookie('MapFormat','3d');
17
+	setcookie('MapFormat', '3d');
18 18
 } else if (isset($_GET['2d'])) {
19
-	setcookie('MapFormat','2d');
19
+	setcookie('MapFormat', '2d');
20 20
 }
21 21
 
22 22
 if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
23
-	$tsk = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
23
+	$tsk = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
24 24
 }
25 25
 
26 26
 if (isset($_POST['archive'])) {
27
-	setcookie('archive','true');
28
-	setcookie('archive_begin',strtotime($_POST['start_date']));
29
-	setcookie('archive_end',strtotime($_POST['end_date']));
30
-	setcookie('archive_speed',$_POST['archivespeed']);
27
+	setcookie('archive', 'true');
28
+	setcookie('archive_begin', strtotime($_POST['start_date']));
29
+	setcookie('archive_end', strtotime($_POST['end_date']));
30
+	setcookie('archive_speed', $_POST['archivespeed']);
31 31
 }
32 32
 if (isset($_POST['noarchive'])) {
33
-	setcookie('archive','false',-1);
34
-	setcookie('archive_begin','',-1);
35
-	setcookie('archive_end','',-1);
36
-	setcookie('archive_speed','',-1);
33
+	setcookie('archive', 'false', -1);
34
+	setcookie('archive_begin', '', -1);
35
+	setcookie('archive_end', '', -1);
36
+	setcookie('archive_speed', '', -1);
37 37
 }
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
40
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
41
+	    return strpos($key, 'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
45
-		setcookie($filt,null,-1);
45
+		setcookie($filt, null, -1);
46 46
 	}
47 47
 }
48 48
 ?>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 265
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 266
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
267
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
268 268
 <?php
269 269
 		if (!isset($type) || $type == 'aircraft') {
270 270
 ?>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 338
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 339
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
340
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
341 341
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 342
 <?php
343 343
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 ?>
743 743
       <div class="search">
744 744
 	<form action="<?php print $globalURL; ?>/search" method="get">
745
-		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
-		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != ""){ print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
745
+		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
+		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != "") { print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
747 747
 	</form>
748 748
 	</div>
749 749
   	<div class="social">
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	print '</div>';
762 762
 }
763 763
 
764
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
764
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     </div>
775 775
 <?php
776 776
 }
777
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
777
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
778 778
 {
779 779
     ?>
780 780
     <div class="top-header clear" role="main">
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
804 804
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40 40
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
41
+		return strpos($key,'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
@@ -404,34 +404,34 @@  discard block
 block discarded – undo
404 404
 
405 405
       <ul class="nav navbar-nav">
406 406
 <?php
407
-    if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
407
+	if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
408 408
 ?>
409 409
     <li><a href="<?php print $globalURL; ?>/news"><?php echo _("News"); ?></a></li>
410 410
 <?php
411
-    }
411
+	}
412 412
 ?>
413 413
 
414 414
 <?php 
415
-    $sub = false;
416
-    if (
415
+	$sub = false;
416
+	if (
417 417
 	(
418
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
418
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
419 419
 	) || 
420 420
 	(
421
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
421
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
422 422
 	) || 
423 423
 	(
424
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
424
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
425 425
 	) || 
426 426
 	(
427
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
427
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
428 428
 	)
429
-    ) {
429
+	) {
430 430
 	$sub = true;
431
-    }
431
+	}
432 432
 ?>
433 433
 <?php
434
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
434
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
435 435
 ?>
436 436
     <li class="dropdown">
437 437
 <?php
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	<ul class="dropdown-menu multi-level">
443 443
       	<li class="dropdown-submenu">
444 444
 <?php
445
-        }
445
+		}
446 446
 ?>
447 447
 <?php
448 448
 	if (isset($globalNewsFeeds['aircraft']) && !empty($globalNewsFeeds['aircraft'])) {
@@ -457,25 +457,25 @@  discard block
 block discarded – undo
457 457
           <ul class="dropdown-menu">
458 458
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
459 459
 <?php
460
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
460
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
461 461
 ?>
462 462
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
463 463
 <?php
464
-    }
464
+	}
465 465
 ?>
466 466
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
467 467
 <?php
468
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
468
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
469 469
 ?>
470 470
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
471 471
 <?php
472
-    } 
473
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
472
+	} 
473
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
474 474
 
475 475
 ?>
476 476
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
477 477
 <?php
478
-    }
478
+	}
479 479
 ?>
480 480
 			<li><hr /></li>
481 481
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -483,43 +483,43 @@  discard block
 block discarded – undo
483 483
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
484 484
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
485 485
             <?php
486
-        	if ($globalACARS) {
487
-        	    if (isset($globalDemo) && $globalDemo) {
488
-    	    ?>
486
+			if ($globalACARS) {
487
+				if (isset($globalDemo) && $globalDemo) {
488
+			?>
489 489
             <li><hr /></li>
490 490
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
491 491
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
492 492
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
493 493
             <?php
494
-        	    } else {
495
-    	    ?>
494
+				} else {
495
+			?>
496 496
             <li><hr /></li>
497 497
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
498 498
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
499 499
             <?php
500
-        	    }
501
-        	}
502
-    	    ?>
500
+				}
501
+			}
502
+			?>
503 503
     	    <?php
504
-    	        if (isset($globalAccidents) && $globalAccidents) {
505
-    	    ?>
504
+				if (isset($globalAccidents) && $globalAccidents) {
505
+			?>
506 506
             <li><hr /></li>
507 507
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
508 508
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
509 509
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
510 510
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
511 511
             <?php
512
-        	}
513
-    	    ?>
512
+			}
513
+			?>
514 514
             <li><hr /></li>
515 515
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
516 516
             <?php
517 517
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
518
-	    ?>
518
+		?>
519 519
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
520 520
 	    <?php
521 521
 		}
522
-	    ?>
522
+		?>
523 523
           </ul>
524 524
         </li>
525 525
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
     </ul>
547 547
 <?php
548 548
 	}
549
-    }
549
+	}
550 550
 ?>
551 551
 <?php
552
-    if (isset($globalMarine) && $globalMarine) {
552
+	if (isset($globalMarine) && $globalMarine) {
553 553
 ?>
554 554
     <li class="dropdown">
555 555
 <?php
556
-        if ($sub) {
556
+		if ($sub) {
557 557
 ?>
558 558
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Marines"); ?> <b class="caret"></b></a>
559 559
 	<ul class="dropdown-menu multi-level">
@@ -587,14 +587,14 @@  discard block
 block discarded – undo
587 587
 	}
588 588
 ?>
589 589
 <?php
590
-    }
590
+	}
591 591
 ?>
592 592
 <?php
593
-    if (isset($globalTracker) && $globalTracker) {
593
+	if (isset($globalTracker) && $globalTracker) {
594 594
 ?>
595 595
     <li class="dropdown">
596 596
 <?php
597
-        if ($sub) {
597
+		if ($sub) {
598 598
 ?>
599 599
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
600 600
 	<ul class="dropdown-menu multi-level">
@@ -628,14 +628,14 @@  discard block
 block discarded – undo
628 628
 	}
629 629
 ?>
630 630
 <?php
631
-    }
631
+	}
632 632
 ?>
633 633
 <?php
634
-    if (isset($globalSatellite) && $globalSatellite) {
634
+	if (isset($globalSatellite) && $globalSatellite) {
635 635
 ?>
636 636
     <li class="dropdown">
637 637
 <?php
638
-        if ($sub) {
638
+		if ($sub) {
639 639
 ?>
640 640
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellites"); ?> <b class="caret"></b></a>
641 641
 	<ul class="dropdown-menu multi-level">
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 ?>
673 673
 <?php
674
-    }
674
+	}
675 675
 ?>
676 676
 
677 677
         <li class="dropdown">
@@ -680,12 +680,12 @@  discard block
 block discarded – undo
680 680
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
681 681
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
682 682
 <?php
683
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
683
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
684 684
 ?>
685 685
 		<li><hr /></li>
686 686
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
687 687
 <?php
688
-    }
688
+	}
689 689
 ?>
690 690
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
691 691
                 <li><hr /></li>
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
   	    <form>
710 710
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
711 711
   		    <?php
712
-  		        foreach ($alllang as $key => $lang) {
713
-  		            print '<option value="'.$key.'"';
714
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
715
-  		            if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
716
-  		            else print '>'.$lang[0].'</option>';
717
-  		        }
718
-  		    ?>
712
+  				foreach ($alllang as $key => $lang) {
713
+  					print '<option value="'.$key.'"';
714
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
715
+  					if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
716
+  					else print '>'.$lang[0].'</option>';
717
+  				}
718
+  			?>
719 719
   		</select>
720 720
   	    </form>
721 721
   	</div>
@@ -748,18 +748,18 @@  discard block
 block discarded – undo
748 748
 ?>
749 749
     <div class="top-header clear" role="main">
750 750
 <?php
751
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
751
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
752 752
 ?>
753 753
     <div id="archive-map"></div>
754 754
 <?php
755
-    }
755
+	}
756 756
 ?>
757 757
     </div>
758 758
 <?php
759 759
 }
760 760
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
761 761
 {
762
-    ?>
762
+	?>
763 763
     <div class="top-header clear" role="main">
764 764
         <div id="map"></div>
765 765
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
         var zoom = 13;
771 771
 //create the map
772 772
 <?php
773
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
773
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
774 774
 ?>
775 775
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
776 776
 <?php
777
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
777
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
778 778
 ?>
779 779
   map = L.map('map', { zoomControl:true });
780 780
 <?php
781
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
781
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
782 782
 ?>
783 783
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
784 784
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -786,22 +786,22 @@  discard block
 block discarded – undo
786 786
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
787 787
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
788 788
 <?php
789
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
789
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
790 790
 ?>
791 791
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
792 792
 <?php
793
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
793
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
794 794
 ?>
795 795
   map = L.map('map', { zoomControl:true });
796 796
 <?php
797
-    }
797
+	}
798 798
 ?>
799 799
   //initialize the layer group for the aircrft markers
800 800
   var layer_data = L.layerGroup();
801 801
 
802 802
   //a few title layers
803 803
 <?php
804
-    if ($globalMapProvider == 'Mapbox') {
804
+	if ($globalMapProvider == 'Mapbox') {
805 805
 ?>
806 806
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
807 807
     maxZoom: 18,
@@ -812,14 +812,14 @@  discard block
 block discarded – undo
812 812
     token : '<?php print $globalMapboxToken; ?>'
813 813
   }).addTo(map);
814 814
 <?php
815
-    } elseif ($globalMapProvider == 'Mapbox-GL') {
815
+	} elseif ($globalMapProvider == 'Mapbox-GL') {
816 816
 ?>
817 817
     L.mapboxGL({
818 818
 	accessToken: '<?php print $globalMapboxToken; ?>',
819 819
 	style: 'mapbox://styles/mapbox/bright-v8'
820 820
   }).addTo(map);
821 821
 <?php
822
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
822
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
823 823
 ?>
824 824
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
825 825
     maxZoom: 18,
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
829 829
   }).addTo(map);
830 830
 <?php
831
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
831
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
832 832
 ?>
833 833
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
834 834
     maxZoom: 18,
@@ -837,27 +837,27 @@  discard block
 block discarded – undo
837 837
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
838 838
   }).addTo(map);
839 839
 <?php
840
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
840
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
841 841
 ?>
842 842
     var googleLayer = new L.Google('ROADMAP');
843 843
     map.addLayer(googleLayer);
844 844
 <?php
845
-    } elseif ($globalMapProvider == 'Google-Satellite') {
845
+	} elseif ($globalMapProvider == 'Google-Satellite') {
846 846
 ?>
847 847
     var googleLayer = new L.Google('SATELLITE');
848 848
     map.addLayer(googleLayer);
849 849
 <?php
850
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
850
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
851 851
 ?>
852 852
     var googleLayer = new L.Google('HYBRID');
853 853
     map.addLayer(googleLayer);
854 854
 <?php
855
-    } elseif ($globalMapProvider == 'Google-Terrain') {
855
+	} elseif ($globalMapProvider == 'Google-Terrain') {
856 856
 ?>
857 857
     var googleLayer = new L.Google('Terrain');
858 858
     map.addLayer(googleLayer);
859 859
 <?php
860
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
860
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
861 861
 	$customid = $globalMapProvider;
862 862
 ?>
863 863
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
868 868
     }).addTo(map);
869 869
 <?php
870
-    } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
870
+	} elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
871 871
 ?>
872 872
     var center = map.getCenter();
873 873
     map.options.crs = L.CRS.EPSG4326;
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
         attribution: 'Natural Earth'
883 883
     }).addTo(map);
884 884
 <?php
885
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
886
-    } else {
885
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
886
+	} else {
887 887
 ?>
888 888
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
889 889
     maxZoom: 18,
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
   }).addTo(map);
893 893
 
894 894
 <?php
895
-    }
895
+	}
896 896
 ?>
897 897
         </script>
898 898
     </div>
Please login to merge, or discard this patch.
Braces   +95 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -204,7 +211,10 @@  discard block
 block discarded – undo
204 211
 <?php
205 212
 		} else {
206 213
 ?>
207
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
214
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
215
+	print '&tsk='.$tsk;
216
+}
217
+?>"></script>
208 218
 <?php
209 219
 		}
210 220
 		if (!isset($globalAircraft) || $globalAircraft) {
@@ -244,7 +254,13 @@  discard block
 block discarded – undo
244 254
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
245 255
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
246 256
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
247
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
257
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
258
+	print '&latitude='.$latitude;
259
+}
260
+?><?php if(isset($longitude)) {
261
+	print '&longitude='.$longitude;
262
+}
263
+?>&<?php print time(); ?>"></script>
248 264
 <?php
249 265
 		if (!isset($type) || $type == 'aircraft') {
250 266
 ?>
@@ -317,7 +333,13 @@  discard block
 block discarded – undo
317 333
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
318 334
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
319 335
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
320
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
336
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
337
+	print '&latitude='.$latitude;
338
+}
339
+?><?php if(isset($longitude)) {
340
+	print '&longitude='.$longitude;
341
+}
342
+?>&<?php print time(); ?>"></script>
321 343
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
322 344
 <?php
323 345
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -398,7 +420,12 @@  discard block
 block discarded – undo
398 420
         <span class="icon-bar"></span>
399 421
       </button>
400 422
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
401
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
423
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
424
+	print '/';
425
+} else {
426
+	print $globalURL;
427
+}
428
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
402 429
     </div>
403 430
     <div class="collapse navbar-collapse">
404 431
 
@@ -453,7 +480,10 @@  discard block
 block discarded – undo
453 480
 	}
454 481
 ?>
455 482
 
456
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
483
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
484
+	echo 'right-';
485
+}
486
+?>caret"></b></a>
457 487
           <ul class="dropdown-menu">
458 488
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
459 489
 <?php
@@ -524,8 +554,14 @@  discard block
 block discarded – undo
524 554
         </li>
525 555
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
526 556
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
527
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
528
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
557
+        <li class="dropdown<?php if ($sub) {
558
+	echo '-submenu';
559
+}
560
+?>">
561
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
562
+	echo 'right-';
563
+}
564
+?>caret"></b></a>
529 565
           <ul class="dropdown-menu">
530 566
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
531 567
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -569,7 +605,10 @@  discard block
 block discarded – undo
569 605
 <?php
570 606
 	}
571 607
 ?>
572
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
608
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
609
+	echo 'right-';
610
+}
611
+?>caret"></b></a>
573 612
 		<ul class="dropdown-menu">
574 613
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
575 614
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -610,7 +649,10 @@  discard block
 block discarded – undo
610 649
 <?php
611 650
 	}
612 651
 ?>
613
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
652
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
653
+	echo 'right-';
654
+}
655
+?>caret"></b></a>
614 656
 		<ul class="dropdown-menu">
615 657
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
616 658
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -653,7 +695,10 @@  discard block
 block discarded – undo
653 695
 ?>
654 696
 
655 697
 <!--
656
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
698
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
699
+	echo 'right-';
700
+}
701
+?>caret"></b></a>
657 702
 		<ul class="dropdown-menu">
658 703
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
659 704
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -711,9 +756,14 @@  discard block
 block discarded – undo
711 756
   		    <?php
712 757
   		        foreach ($alllang as $key => $lang) {
713 758
   		            print '<option value="'.$key.'"';
714
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
715
-  		            if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
716
-  		            else print '>'.$lang[0].'</option>';
759
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
760
+  		            	print ' selected ';
761
+  		            }
762
+  		            if ($lang[0] == 'Deutsch') {
763
+  		            	print '>'.$lang[0].' (&beta;eta)</option>';
764
+  		            } else {
765
+  		            	print '>'.$lang[0].'</option>';
766
+  		            }
717 767
   		        }
718 768
   		    ?>
719 769
   		</select>
@@ -861,9 +911,24 @@  discard block
 block discarded – undo
861 911
 	$customid = $globalMapProvider;
862 912
 ?>
863 913
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
864
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
865
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
866
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
914
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
915
+	print $globalMapCustomLayer[$customid]['maxZoom'];
916
+} else {
917
+	print '18';
918
+}
919
+?>,
920
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
921
+	print $globalMapCustomLayer[$customid]['minZoom'];
922
+} else {
923
+	print '0';
924
+}
925
+?>,
926
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
927
+	print 'false';
928
+} else {
929
+	print 'true';
930
+}
931
+?>,
867 932
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
868 933
     }).addTo(map);
869 934
 <?php
@@ -878,7 +943,12 @@  discard block
 block discarded – undo
878 943
         maxZoom: 5,
879 944
         tms : true,
880 945
         zindex : 3,
881
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
946
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
947
+	print 'false';
948
+} else {
949
+	print 'true';
950
+}
951
+?>,
882 952
         attribution: 'Natural Earth'
883 953
     }).addTo(map);
884 954
 <?php
@@ -901,4 +971,7 @@  discard block
 block discarded – undo
901 971
 
902 972
 ?>
903 973
 
904
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
974
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
975
+	print 'index ';
976
+}
977
+?>clear">
Please login to merge, or discard this patch.
require/class.MapMatching.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 		$gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&amp;apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">';
45 45
 		$gpx .= '<trk>';
46 46
 		$gpx .= '<trkseg>';
47
-		foreach($spotter_history_array as $spotter_data) {
48
-			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
50
-			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
47
+		foreach ($spotter_history_array as $spotter_data) {
48
+			$gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">';
49
+			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>';
50
+			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>';
51 51
 			$gpx .= '</trkpt>';
52 52
 		}
53 53
 		$gpx .= '</trkseg>';
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85 85
 		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86 86
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
88 88
 		$data = $this->create_gpx($spotter_history_array);
89 89
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 90
 		$Common = new Common();
91
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json'));
92
-		$matching = json_decode($matching,true);
91
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json'));
92
+		$matching = json_decode($matching, true);
93 93
 		if (isset($matching['diary']['entries'][0]['route']['links'])) {
94 94
 			$spotter_history_array = array();
95 95
 			foreach ($matching['diary']['entries'][0]['route']['links'] as $match) {
96 96
 				if (isset($match['wpts'])) {
97 97
 					foreach ($match['wpts'] as $coord) {
98
-						$spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']);
98
+						$spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']);
99 99
 					}
100 100
 				}
101 101
 			}
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 115
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
116 116
 		$spotter_history_initial_array = array();
117 117
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
119
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
118
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
119
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
120 120
 		}
121 121
 		$data = $this->create_gpx($spotter_history_array);
122 122
 		$url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&instructions=false&key='.$globalGraphHopperKey;
123 123
 		$Common = new Common();
124
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
125
-		$matching = json_decode($matching,true);
124
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
125
+		$matching = json_decode($matching, true);
126 126
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
127 127
 			$spotter_history_array = array();
128 128
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
129 129
 				$coord = $match;
130
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
130
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
131 131
 			}
132 132
 		}
133
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
133
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
134 134
 		$spotter_history_array[0]['mapmatching_engine'] = 'graphhopper';
135 135
 		return $spotter_history_array;
136 136
 	}
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
147 147
 		$spotter_history_initial_array = array();
148 148
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
150
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
149
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
150
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
151 151
 		}
152 152
 		$data = $this->create_gpx($spotter_history_array);
153 153
 		$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0&instructions=false';
154 154
 		//$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0';
155 155
 		$Common = new Common();
156
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
157
-		$matching = json_decode($matching,true);
156
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
157
+		$matching = json_decode($matching, true);
158 158
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
159 159
 			$spotter_history_array = array();
160 160
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
161 161
 				$coord = $match;
162
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
162
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
163 163
 			}
164 164
 		}
165
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
165
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
166 166
 		$spotter_history_array[0]['mapmatching_engine'] = 'fam';
167 167
 		return $spotter_history_array;
168 168
 	}
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
179 179
 		$spotter_history_initial_array = array();
180 180
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
182
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
181
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
182
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
183 183
 		}
184 184
 		$coord = '';
185 185
 		$ts = '';
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
196 196
 		$Common = new Common();
197 197
 		$matching = $Common->getData($url);
198
-		$matching  = json_decode($matching,true);
198
+		$matching = json_decode($matching, true);
199 199
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
200 200
 			$spotter_history_array = array();
201 201
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
202 202
 				$coord = $match;
203
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
203
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
204 204
 			}
205 205
 		}
206
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
206
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
207 207
 		$spotter_history_array[0]['mapmatching_engine'] = 'osmr';
208 208
 		return $spotter_history_array;
209 209
 	}
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
220 220
 		$spotter_history_initial_array = array();
221 221
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
223
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
222
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
223
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
224 224
 		}
225 225
 		$coord = '';
226 226
 		$ts = '';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
 		$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson';
238 238
 		$Common = new Common();
239 239
 		$matching = $Common->getData($url);
240
-		$matching  = json_decode($matching,true);
240
+		$matching = json_decode($matching, true);
241 241
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
242 242
 			$spotter_history_array = array();
243 243
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
244 244
 				$coord = $match;
245
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
245
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
246 246
 			}
247 247
 		}
248
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
248
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
249 249
 		$spotter_history_array[0]['mapmatching_engine'] = 'mapbox';
250 250
 		return $spotter_history_array;
251 251
 	}
Please login to merge, or discard this patch.
Braces   +54 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 		$gpx .= '<trkseg>';
47 47
 		foreach($spotter_history_array as $spotter_data) {
48 48
 			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
49
+			if (isset($spotter_data['altitude'])) {
50
+				$gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
51
+			}
50 52
 			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
51 53
 			$gpx .= '</trkpt>';
52 54
 		}
@@ -82,9 +84,15 @@  discard block
 block discarded – undo
82 84
 
83 85
 	public function TrackMatching($spotter_history_array) {
84 86
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (!isset($globalMapMatchingMaxPts)) {
88
+			$globalMapMatchingMaxPts = 100;
89
+		}
90
+		if (count($spotter_history_array) < 2) {
91
+			return $spotter_history_array;
92
+		}
93
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
94
+			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
95
+		}
88 96
 		$data = $this->create_gpx($spotter_history_array);
89 97
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 98
 		$Common = new Common();
@@ -111,8 +119,12 @@  discard block
 block discarded – undo
111 119
 	*/
112 120
 	public function GraphHopper($spotter_history_array) {
113 121
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
114
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
115
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
122
+		if (!isset($globalMapMatchingMaxPts)) {
123
+			$globalMapMatchingMaxPts = 100;
124
+		}
125
+		if (count($spotter_history_array) < 2) {
126
+			return $spotter_history_array;
127
+		}
116 128
 		$spotter_history_initial_array = array();
117 129
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118 130
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -142,8 +154,12 @@  discard block
 block discarded – undo
142 154
 	*/
143 155
 	public function FAMMapMatching($spotter_history_array) {
144 156
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
145
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
146
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
157
+		if (!isset($globalMapMatchingMaxPts)) {
158
+			$globalMapMatchingMaxPts = 100;
159
+		}
160
+		if (count($spotter_history_array) < 2) {
161
+			return $spotter_history_array;
162
+		}
147 163
 		$spotter_history_initial_array = array();
148 164
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149 165
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -174,8 +190,12 @@  discard block
 block discarded – undo
174 190
 	*/
175 191
 	public function osmr($spotter_history_array) {
176 192
 		global $globalMapMatchingMaxPts;
177
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50;
178
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
193
+		if (!isset($globalMapMatchingMaxPts)) {
194
+			$globalMapMatchingMaxPts = 50;
195
+		}
196
+		if (count($spotter_history_array) < 2) {
197
+			return $spotter_history_array;
198
+		}
179 199
 		$spotter_history_initial_array = array();
180 200
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181 201
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -185,11 +205,17 @@  discard block
 block discarded – undo
185 205
 		$ts = '';
186 206
 		$rd = '';
187 207
 		foreach ($spotter_history_array as $spotter_data) {
188
-			if ($coord != '') $coord .= ';';
208
+			if ($coord != '') {
209
+				$coord .= ';';
210
+			}
189 211
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
190
-			if ($ts != '') $ts .= ';';
212
+			if ($ts != '') {
213
+				$ts .= ';';
214
+			}
191 215
 			$ts .= strtotime($spotter_data['date']);
192
-			if ($rd != '') $rd .= ';';
216
+			if ($rd != '') {
217
+				$rd .= ';';
218
+			}
193 219
 			$rd .= '20';
194 220
 		}
195 221
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
@@ -215,8 +241,12 @@  discard block
 block discarded – undo
215 241
 	*/
216 242
 	public function mapbox($spotter_history_array) {
217 243
 		global $globalMapMatchingMaxPts, $globalMapboxToken;
218
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60;
219
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
244
+		if (!isset($globalMapMatchingMaxPts)) {
245
+			$globalMapMatchingMaxPts = 60;
246
+		}
247
+		if (count($spotter_history_array) < 2) {
248
+			return $spotter_history_array;
249
+		}
220 250
 		$spotter_history_initial_array = array();
221 251
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222 252
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -226,11 +256,17 @@  discard block
 block discarded – undo
226 256
 		$ts = '';
227 257
 		$rd = '';
228 258
 		foreach ($spotter_history_array as $spotter_data) {
229
-			if ($coord != '') $coord .= ';';
259
+			if ($coord != '') {
260
+				$coord .= ';';
261
+			}
230 262
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
231
-			if ($ts != '') $ts .= ';';
263
+			if ($ts != '') {
264
+				$ts .= ';';
265
+			}
232 266
 			$ts .= strtotime($spotter_data['date']);
233
-			if ($rd != '') $rd .= ';';
267
+			if ($rd != '') {
268
+				$rd .= ';';
269
+			}
234 270
 			$rd .= '20';
235 271
 		}
236 272
 		//$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd;
Please login to merge, or discard this patch.
highlights-display.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
 require_once('header.php');
8 8
 
9 9
 //calculuation for the pagination
10
-if(!isset($_GET['limit']))
10
+if (!isset($_GET['limit']))
11 11
 {
12 12
 	$limit_start = 0;
13 13
 	$limit_end = 28;
14 14
 	$absolute_difference = 28;
15 15
 } else {
16 16
 	$limit_explode = explode(",", $_GET['limit']);
17
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
18
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
17
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
18
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
19 19
 	if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
20 20
 		$limit_start = 0;
21 21
 		$limit_end = 25;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 print '<div class="column">';	
40 40
 print '<p>'._("The view below shows all aircraft that have been selected to have some sort of special characteristic about them, such as unique liveries, destinations etc.").'</p>';
41 41
 
42
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
42
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
43 43
 if ($sort != '') {
44 44
 	$spotter_array = $Spotter->getSpotterDataByHighlight($limit_start.",".$absolute_difference, $sort);
45 45
 } else {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 if (!empty($spotter_array))
49 49
 {
50 50
 	print '<div class="dispay-view">';
51
-	foreach($spotter_array as $spotter_item)
51
+	foreach ($spotter_array as $spotter_item)
52 52
 	{
53 53
 		if (isset($spotter_item['image']) && $spotter_item['image'] != "")
54 54
 		{
Please login to merge, or discard this patch.
pilot-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 require_once('require/class.Language.php');
6 6
 require_once('require/class.SpotterArchive.php');
7 7
 
8
-if (!isset($_GET['pilot'])){
8
+if (!isset($_GET['pilot'])) {
9 9
 	header('Location: '.$globalURL.'/');
10 10
 } else {
11 11
 	$Spotter = new Spotter();
12 12
 	$SpotterArchive = new SpotterArchive();
13 13
 	//calculuation for the pagination
14
-	if(!isset($_GET['limit']))
14
+	if (!isset($_GET['limit']))
15 15
 	{
16 16
 		$limit_start = 0;
17 17
 		$limit_end = 25;
@@ -32,29 +32,29 @@  discard block
 block discarded – undo
32 32
 	
33 33
 	$page_url = $globalURL.'/pilot/'.$_GET['pilot'];
34 34
 	
35
-	$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
36
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
37
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
35
+	$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
36
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
37
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
38
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
39 39
 	$filter = array();
40
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
41
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
40
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
41
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
42 42
 	if ($sort != '') 
43 43
 	{
44
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
44
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
45 45
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
46
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
46
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
47 47
 		}
48 48
 	} else {
49
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
49
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
50 50
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
51
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
51
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
52 52
 		}
53 53
 	}
54 54
 
55 55
 	if (!empty($spotter_array))
56 56
 	{
57
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
57
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['pilot_name']);
58 58
 		$ident = $spotter_array[0]['ident'];
59 59
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
60 60
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
 			$Stats = new Stats();
116 116
 			$flights = $Stats->getStatsPilot($pilot);
117 117
 		} else $flights = 0;
118
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
118
+		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot, $filter);
119 119
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
120
-		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
120
+		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot, $filter));
121 121
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
122
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot,$filter));
122
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot, $filter));
123 123
 		print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
124
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot,$filter));
124
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot, $filter));
125 125
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
126
-		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
126
+		$airlines = count($Spotter->countAllAirlinesByPilot($pilot, $filter));
127 127
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
128
-		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
128
+		$duration = $Spotter->getFlightDurationByPilot($pilot, $filter);
129 129
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
130 130
 		print '</div>';
131 131
 	
132 132
 		include('pilot-sub-menu.php');
133 133
 		print '<div class="table column">';
134
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
134
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
135 135
 
136 136
 		include('table-output.php'); 
137 137
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,8 +37,12 @@  discard block
 block discarded – undo
37 37
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38 38
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
39 39
 	$filter = array();
40
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
41
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
40
+	if ($year != '') {
41
+		$filter = array_merge($filter,array('year' => $year));
42
+	}
43
+	if ($month != '') {
44
+		$filter = array_merge($filter,array('month' => $month));
45
+	}
42 46
 	if ($sort != '') 
43 47
 	{
44 48
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -56,8 +60,12 @@  discard block
 block discarded – undo
56 60
 	{
57 61
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
58 62
 		$ident = $spotter_array[0]['ident'];
59
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
60
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
63
+		if (isset($spotter_array[0]['latitude'])) {
64
+			$latitude = $spotter_array[0]['latitude'];
65
+		}
66
+		if (isset($spotter_array[0]['longitude'])) {
67
+			$longitude = $spotter_array[0]['longitude'];
68
+		}
61 69
 		require_once('header.php');
62 70
 		/*
63 71
 		if (isset($globalArchive) && $globalArchive) {
@@ -110,12 +118,18 @@  discard block
 block discarded – undo
110 118
 		*/
111 119
 		print '<div class="info column">';
112 120
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
113
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
121
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
122
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
123
+		}
114 124
 		if ($year == '' && $month == '') {
115 125
 			$Stats = new Stats();
116 126
 			$flights = $Stats->getStatsPilot($pilot);
117
-		} else $flights = 0;
118
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
127
+		} else {
128
+			$flights = 0;
129
+		}
130
+		if ($flights == 0) {
131
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
132
+		}
119 133
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
120 134
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
121 135
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -126,7 +140,9 @@  discard block
 block discarded – undo
126 140
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
127 141
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
128 142
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
129
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
143
+		if ($duration != '0') {
144
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
145
+		}
130 146
 		print '</div>';
131 147
 	
132 148
 		include('pilot-sub-menu.php');
Please login to merge, or discard this patch.
route-statistics-aircraft.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
 require_once('require/class.Connection.php');
8 8
 require_once('require/class.Spotter.php');
9 9
 require_once('require/class.Language.php');
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
12
-$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING);
12
+$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING);
13 13
 $Spotter = new Spotter();
14 14
 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
15 15
   
16 16
 if (!empty($spotter_array))
17 17
 {
18
-	$title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
18
+	$title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']);
19 19
 	require_once('header.php');
20 20
 	print '<div class="info column">';
21 21
 	print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	include('route-sub-menu.php');
27 27
 	print '<div class="column">';
28 28
 	print '<h2>'._("Most Common Aircraft").'</h2>';
29
-	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>';
29
+	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>';
30 30
 
31 31
 	$aircraft_array = $Spotter->countAllAircraftTypesByRoute($departure_airport, $arrival_airport);
32 32
 	if (!empty($aircraft_array))
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		print '</thead>';
42 42
 		print '<tbody>';
43 43
 		$i = 1;
44
-		foreach($aircraft_array as $aircraft_item)
44
+		foreach ($aircraft_array as $aircraft_item)
45 45
 		{
46 46
 			print '<tr>';
47 47
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['owner'])){
10
+if (!isset($_GET['owner'])) {
11 11
 	header('Location: '.$globalURL.'');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	//$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	} else {
23 23
 		$limit_explode = explode(",", $_GET['limit']);
24 24
 		if (isset($limit_explode[1])) {
25
-			$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
26
-			$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
25
+			$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
26
+			$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
27 27
 		} else {
28 28
 			$limit_start = 0;
29 29
 			$limit_end = 25;
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
 	
41 41
 	$page_url = $globalURL.'/owner/'.$_GET['owner'];
42 42
 	
43
-	$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
44
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
45
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
43
+	$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
44
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
45
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
48
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
49
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
50 50
 	if ($sort != '') 
51 51
 	{
52
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
53 53
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
55 55
 		}
56 56
 	} else {
57
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
57
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
58 58
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
59
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
59
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
60 60
 		}
61 61
 	}
62 62
 
63 63
 	if (!empty($spotter_array))
64 64
 	{
65
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
65
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
66 66
 		//$ident = $spotter_array[0]['ident'];
67 67
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68 68
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 		$Stats = new Stats();
123 123
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124 124
 		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
125
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
126 126
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
127
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
128 128
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
129
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
129
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
130 130
 		print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
131
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
131
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
132 132
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
133
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
133
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
134 134
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
135
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
136 136
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
137 137
 		print '</div>';
138 138
 	
139 139
 		include('owner-sub-menu.php');
140 140
 		print '<div class="table column">';
141
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
141
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
142 142
 
143 143
 		include('table-output.php'); 
144 144
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,12 @@  discard block
 block discarded – undo
45 45
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46 46
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
48
+	if ($year != '') {
49
+		$filter = array_merge($filter,array('year' => $year));
50
+	}
51
+	if ($month != '') {
52
+		$filter = array_merge($filter,array('month' => $month));
53
+	}
50 54
 	if ($sort != '') 
51 55
 	{
52 56
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -64,8 +68,12 @@  discard block
 block discarded – undo
64 68
 	{
65 69
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
66 70
 		//$ident = $spotter_array[0]['ident'];
67
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
71
+		if (isset($spotter_array[0]['latitude'])) {
72
+			$latitude = $spotter_array[0]['latitude'];
73
+		}
74
+		if (isset($spotter_array[0]['longitude'])) {
75
+			$longitude = $spotter_array[0]['longitude'];
76
+		}
69 77
 		require_once('header.php');
70 78
 		/*
71 79
 		if (isset($globalArchive) && $globalArchive) {
@@ -120,9 +128,14 @@  discard block
 block discarded – undo
120 128
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
121 129
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
122 130
 		$Stats = new Stats();
123
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124
-		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
131
+		if ($year == '' && $month == '') {
132
+			$flights = $Stats->getStatsOwner($owner);
133
+		} else {
134
+			$flights = 0;
135
+		}
136
+		if ($flights == 0) {
137
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
138
+		}
126 139
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127 140
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
128 141
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -133,7 +146,9 @@  discard block
 block discarded – undo
133 146
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
134 147
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135 148
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
136
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
149
+		if ($duration != '0') {
150
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
151
+		}
137 152
 		print '</div>';
138 153
 	
139 154
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,40 +150,40 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
181
+    	    } else if (preg_match('/aircraft$/i', $host)) {
182 182
         	//$formats[$id] = 'planefinderclient';
183 183
         	$globalSources[$id]['format'] = 'planefinderclient';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
186
+    	    } else if (preg_match('/opensky/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftlistjson';
188 188
         	$globalSources[$id]['format'] = 'opensky';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
203
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
204 204
         	//$formats[$id] = 'planeupdatefaa';
205 205
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 206
         	//$last_exec['planeupdatefaa'] = 0;
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 210
         	    exit(0);
211 211
         	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'phpvmacars';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
217
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vaos';
220 220
         	//$last_exec['phpvmacars'] = 0;
221 221
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
222
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'vam';
225 225
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
226
+            } else if (preg_match('/whazzup/i', $host)) {
227 227
         	//$formats[$id] = 'whazzup';
228 228
         	$globalSources[$id]['format'] = 'whazzup';
229 229
         	//$last_exec['whazzup'] = 0;
230 230
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
231
+            } else if (preg_match('/blitzortung/i', $host)) {
232 232
         	$globalSources[$id]['format'] = 'blitzortung';
233 233
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
234
+            } else if (preg_match('/airwhere/i', $host)) {
235 235
         	$globalSources[$id]['format'] = 'airwhere';
236 236
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
237
+            } else if (preg_match('/recentpireps/i', $host)) {
238 238
         	//$formats[$id] = 'pirepsjson';
239 239
         	$globalSources[$id]['format'] = 'pirepsjson';
240 240
         	//$last_exec['pirepsjson'] = 0;
241 241
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
242
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
243 243
         	//$formats[$id] = 'fr24json';
244 244
         	$globalSources[$id]['format'] = 'fr24json';
245 245
         	//$last_exec['fr24json'] = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 249
         	    exit(0);
250 250
         	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
251
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'myshiptracking';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -258,21 +258,21 @@  discard block
 block discarded – undo
258 258
         	    exit(0);
259 259
         	}
260 260
             //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
261
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 262
         	//$formats[$id] = 'tsv';
263 263
         	$globalSources[$id]['format'] = 'tsv';
264 264
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265 265
             }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
266
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
267 267
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
268
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
269 269
     		    if ($idf !== false) {
270 270
     			$httpfeeds[$id] = $idf;
271 271
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272 272
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273 273
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
-	    $hostport = explode(':',$host);
274
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
275
+	    $hostport = explode(':', $host);
276 276
 	    if (isset($hostport[1])) {
277 277
 		$port = $hostport[1];
278 278
 		$hostn = $hostport[0];
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 	    }
283 283
 	    $Common = new Common();
284 284
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
285
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
286 286
     	    } else {
287
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
287
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
288 288
 	    }
289 289
 	    if ($s) {
290 290
     	        $sockets[$id] = $s;
291 291
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
292
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
293 293
 			//$formats[$id] = 'aprs';
294 294
 			$globalSources[$id]['format'] = 'aprs';
295 295
 			//$aprs_connect = 0;
296 296
 			//$use_aprs = true;
297
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
297
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298 298
 			$globalSources[$id]['format'] = 'vrstcp';
299 299
     		    } elseif ($port == '10001') {
300 300
         		//$formats[$id] = 'tsv';
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
336 336
 else $timeout = 20;
337 337
 $errno = '';
338
-$errstr='';
338
+$errstr = '';
339 339
 
340 340
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
341 341
 /* Initiate connections to all the hosts simultaneously */
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 //connect_all($globalSources);
344 344
 
345 345
 if (isset($globalProxy) && $globalProxy) {
346
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
346
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
347 347
 } else {
348 348
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
349 349
 }
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 
374 374
 if ($use_aprs) {
375 375
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
376
-	$APRS=new APRS();
376
+	$APRS = new APRS();
377 377
 	$aprs_connect = 0;
378 378
 	$aprs_keep = 120;
379 379
 	$aprs_last_tx = time();
380 380
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
381
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
381
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
382 382
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
383
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
383
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
384 384
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
385
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
385
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386 386
 	if ($aprs_full) $aprs_filter = '';
387 387
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
388 388
 	else $aprs_pass = '-1';
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 sleep(1);
397 397
 if ($globalDebug) echo "SCAN MODE \n\n";
398 398
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
399
-$endtime = time()+$globalCronEnd;
399
+$endtime = time() + $globalCronEnd;
400 400
 $i = 1;
401 401
 $tt = array();
402 402
 // Delete all ATC
403 403
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
404
-	$ATC=new ATC($Connection->db);
404
+	$ATC = new ATC($Connection->db);
405 405
 }
406 406
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
407 407
 	$ATC->deleteAll();
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 while ($i > 0) {
412 412
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413 413
 
414
-    if (!$globalDaemon) $i = $endtime-time();
414
+    if (!$globalDaemon) $i = $endtime - time();
415 415
     // Delete old ATC
416 416
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 	if ($max < $globalMinFetch) {
427 427
 	    if ($globalDebug) echo 'Sleeping...'."\n";
428
-	    sleep($globalMinFetch-$max+2);
428
+	    sleep($globalMinFetch - $max + 2);
429 429
 	}
430 430
     }
431 431
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	    //$buffer = $Common->getData($hosts[$id]);
445 445
 	    $buffer = $Common->getData($value['host']);
446 446
 	    if ($buffer != '') $reset = 0;
447
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
-	    $buffer = explode('\n',$buffer);
447
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
448
+	    $buffer = explode('\n', $buffer);
449 449
 	    foreach ($buffer as $line) {
450 450
     		if ($line != '' && count($line) > 7) {
451 451
     		    $line = explode(',', $line);
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
 	    )
479 479
 	) {
480 480
 	    date_default_timezone_set('CET');
481
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
481
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
482 482
 	    date_default_timezone_set('UTC');
483 483
 	    if ($buffer != '') $reset = 0;
484
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
-	    $buffer = explode('\n',$buffer);
484
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
485
+	    $buffer = explode('\n', $buffer);
486 486
 	    foreach ($buffer as $line) {
487 487
 		if ($line != '') {
488 488
 		    //echo "'".$line."'\n";
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 		    $ais_data = $AIS->parse_line(trim($line));
491 491
 		    $data = array();
492 492
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
493
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
494 494
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495 495
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496 496
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503 503
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504 504
 		    if (isset($ais_data['timestamp'])) {
505
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
505
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
506 506
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
507 507
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508 508
 			    $add = true;
@@ -525,21 +525,21 @@  discard block
 block discarded – undo
525 525
 	    $w = $e = null;
526 526
 	    
527 527
 	    if (isset($arr[$id])) {
528
-		$nn = stream_select($arr,$w,$e,$timeout);
528
+		$nn = stream_select($arr, $w, $e, $timeout);
529 529
 		if ($nn > 0) {
530 530
 		    foreach ($httpfeeds as $feed) {
531
-			$buffer = stream_get_line($feed,2000,"\n");
531
+			$buffer = stream_get_line($feed, 2000, "\n");
532 532
 			if ($buffer === FALSE) {
533 533
 			    connect_all($globalSources);
534 534
 			}
535
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
536
-			$buffer = explode('\n',$buffer);
535
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
536
+			$buffer = explode('\n', $buffer);
537 537
 			foreach ($buffer as $line) {
538 538
 			    if ($line != '') {
539 539
 				$ais_data = $AIS->parse_line(trim($line));
540 540
 				$data = array();
541 541
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
542
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
542
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
543 543
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
544 544
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
545 545
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
552 552
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553 553
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
554
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
555 555
 				if (isset($ais_data['timestamp'])) {
556
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
556
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
557 557
 				} else {
558 558
 				    $data['datetime'] = date('Y-m-d H:i:s');
559 559
 				}
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
586 586
 	    )
587 587
 	) {
588
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
588
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
589 589
 	    if ($buffer != '') {
590 590
 		//echo $buffer;
591
-		$all_data = json_decode($buffer,true);
591
+		$all_data = json_decode($buffer, true);
592 592
 		//print_r($all_data);
593 593
 		if (isset($all_data[0]['DATA'])) {
594 594
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 			    $data['ident'] = $line['NAME'];
598 598
 			    $data['mmsi'] = $line['MMSI'];
599 599
 			    if (strlen($data['mmsi']) > 9) {
600
-				$data['mmsi'] = substr($data['mmsi'],-9);
600
+				$data['mmsi'] = substr($data['mmsi'], -9);
601 601
 			    }
602 602
 			    $data['speed'] = $line['SOG'];
603 603
 			    $data['heading'] = $line['COG'];
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 			    //$data['type_id'] = $line['TYPE'];
608 608
 			    $data['imo'] = $line['IMO'];
609 609
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
610
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
611
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
612 612
 			    $data['format_source'] = 'myshiptracking';
613 613
 			    $data['id_source'] = $id_source;
614 614
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -625,16 +625,16 @@  discard block
 block discarded – undo
625 625
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
626 626
 	    )
627 627
 	) {
628
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
628
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
629 629
 	    if ($buffer != '') {
630
-		$all_data = json_decode($buffer,true);
630
+		$all_data = json_decode($buffer, true);
631 631
 		if (isset($all_data[0]['mmsi'])) {
632 632
 		    foreach ($all_data as $line) {
633 633
 			if ($line != '') {
634 634
 			    $data = array();
635 635
 			    $data['ident'] = $line['shipname'];
636 636
 			    $data['callsign'] = $line['callsign'];
637
-			    $data['mmsi'] = substr($line['mmsi'],-9);
637
+			    $data['mmsi'] = substr($line['mmsi'], -9);
638 638
 			    $data['speed'] = $line['sog'];
639 639
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640 640
 			    $data['latitude'] = $line['latitude'];
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 	) {
662 662
 	    $buffer = $Common->getData($value['host']);
663 663
 	    if ($buffer != '') {
664
-		$all_data = json_decode($buffer,true);
664
+		$all_data = json_decode($buffer, true);
665 665
 		if (isset($all_data['features'][0]['id'])) {
666 666
 		    foreach ($all_data['features'] as $line) {
667 667
 			print_r($line);
668 668
 			$data = array();
669 669
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
670 670
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
671
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
671
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
672 672
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
673 673
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
674 674
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -695,31 +695,31 @@  discard block
 block discarded – undo
695 695
 	    )
696 696
 	) {
697 697
 	    echo 'download...';
698
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
698
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
699 699
 	    echo 'done !'."\n";
700 700
 	    // FIXME: Need more work
701 701
 	    if ($buffer != '') $reset = 0;
702
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
-	    $buffer = explode('\n',$buffer);
702
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
703
+	    $buffer = explode('\n', $buffer);
704 704
 	    foreach ($buffer as $line) {
705 705
 		if ($line != '') {
706 706
 		    $data = array();
707 707
 		    echo $line."\n";
708
-		    $data['mmsi'] = (int)substr($line,0,9);
709
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
-		    $data['status_id'] = substr($line,21,2);
711
-		    $data['type_id'] = substr($line,24,3);
712
-		    $data['latitude'] = substr($line,29,9);
713
-		    $data['longitude'] = substr($line,41,9);
714
-		    $data['speed'] = round(substr($line,51,5));
708
+		    $data['mmsi'] = (int) substr($line, 0, 9);
709
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
710
+		    $data['status_id'] = substr($line, 21, 2);
711
+		    $data['type_id'] = substr($line, 24, 3);
712
+		    $data['latitude'] = substr($line, 29, 9);
713
+		    $data['longitude'] = substr($line, 41, 9);
714
+		    $data['speed'] = round(substr($line, 51, 5));
715 715
 		    //$data['course'] = substr($line,57,5);
716
-		    $data['heading'] = round(substr($line,63,3));
716
+		    $data['heading'] = round(substr($line, 63, 3));
717 717
 		    //$data['draft'] = substr($line,67,4);
718 718
 		    //$data['length'] = substr($line,72,3);
719 719
 		    //$data['beam'] = substr($line,76,2);
720
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
720
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
721 721
 		    //$data['callsign'] = trim(substr($line,100,7);
722
-		    $data['arrival_code'] = substr($line,108,20);
722
+		    $data['arrival_code'] = substr($line, 108, 20);
723 723
 		    //$data['etaDate'] = substr($line,129,5);
724 724
 		    //$data['etaTime'] = substr($line,135,5);
725 725
 		    $data['format_source'] = 'shipplotter';
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
 	) {
751 751
 	    //$buffer = $Common->getData($hosts[$id]);
752 752
 	    $buffer = $Common->getData($value['host']);
753
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
-	    $buffer = explode('\n',$buffer);
753
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
754
+	    $buffer = explode('\n', $buffer);
755 755
 	    $reset = 0;
756 756
 	    foreach ($buffer as $line) {
757 757
     		if ($line != '') {
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
763 763
 			$data['pilot_id'] = $line[1];
764 764
 			$data['pilot_name'] = $line[2];
765
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
765
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
766 766
 			$data['ident'] = $line[0]; // ident
767 767
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
768 768
 			$data['speed'] = $line[8]; // speed
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
779 779
 			//if (isset($line[37])) $data['last_update'] = $line[37];
780 780
 		        $data['departure_airport_icao'] = $line[11];
781
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
781
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
782 782
 		        $data['arrival_airport_icao'] = $line[13];
783 783
 			$data['frequency'] = $line[4];
784 784
 			$data['type'] = $line[18];
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
     			$data['id_source'] = $id_source;
788 788
 	    		//$data['arrival_airport_time'] = ;
789 789
 	    		if ($line[9] != '') {
790
-	    		    $aircraft_data = explode('/',$line[9]);
790
+	    		    $aircraft_data = explode('/', $line[9]);
791 791
 	    		    if (isset($aircraft_data[1])) {
792 792
 	    			$data['aircraft_icao'] = $aircraft_data[1];
793 793
 	    		    }
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
     			if ($line[3] === 'PILOT') $SI->add($data);
803 803
 			elseif ($line[3] === 'ATC') {
804 804
 				//print_r($data);
805
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
806
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
807
-				$typec = substr($data['ident'],-3);
805
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
806
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
807
+				$typec = substr($data['ident'], -3);
808 808
 				if ($typec === 'APP') $data['type'] = 'Approach';
809 809
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
810 810
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
817 817
 				if (!isset($data['source_name'])) $data['source_name'] = '';
818 818
 				if (isset($ATC)) {
819
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
820
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
819
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
820
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
821 821
 				}
822 822
 			}
823 823
     			unset($data);
@@ -833,24 +833,24 @@  discard block
 block discarded – undo
833 833
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834 834
     	    )
835 835
     	) {
836
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
836
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
837 837
 	    if ($buffer != '') {
838 838
 		$all_data = simplexml_load_string($buffer);
839
-		foreach($all_data->children() as $childdata) {
839
+		foreach ($all_data->children() as $childdata) {
840 840
 			$data = array();
841 841
 			$line = $childdata;
842 842
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
843
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
844
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
845
-			$data['latitude'] = (float)$line['pktLatitude'];
846
-			$data['longitude'] = (float)$line['pktLongitude'];
847
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
848
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
849
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
843
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
844
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
845
+			$data['latitude'] = (float) $line['pktLatitude'];
846
+			$data['longitude'] = (float) $line['pktLongitude'];
847
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
848
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
849
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
850 850
 			$data['altitude_relative'] = 'AMSL';
851
-			$data['pilot_id'] = (int)$line['pktPilotID'];
851
+			$data['pilot_id'] = (int) $line['pktPilotID'];
852 852
 			$data['aircraft_icao'] = 'PARAGLIDER';
853
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
853
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
854 854
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
855 855
 			$data['format_source'] = $value['format'];
856 856
 			$SI->add($data);
@@ -858,22 +858,22 @@  discard block
 block discarded – undo
858 858
 		}
859 859
 	    }
860 860
 	    $Source->deleteOldLocationByType('gs');
861
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
861
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
862 862
 	    if ($buffer != '') {
863 863
 		$all_data = simplexml_load_string($buffer);
864
-		foreach($all_data->children() as $childdata) {
864
+		foreach ($all_data->children() as $childdata) {
865 865
 			$data = array();
866 866
 			$line = $childdata;
867
-			$data['id'] = (int)$line['gsID'];
868
-			$data['latitude'] = (float)$line['gsLatitude'];
869
-			$data['longitude'] = (float)$line['gsLongitude'];
870
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
867
+			$data['id'] = (int) $line['gsID'];
868
+			$data['latitude'] = (float) $line['gsLatitude'];
869
+			$data['longitude'] = (float) $line['gsLongitude'];
870
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
871 871
 			$data['altitude_relative'] = 'AMSL';
872
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
872
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
873 873
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
874
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
874
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
875 875
 			} else {
876
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
876
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
877 877
 			}
878 878
 			unset($data);
879 879
 		}
@@ -891,9 +891,9 @@  discard block
 block discarded – undo
891 891
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
892 892
 	    )
893 893
 	) {
894
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
894
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
895 895
 	    if ($buffer != '') {
896
-	        $all_data = json_decode($buffer,true);
896
+	        $all_data = json_decode($buffer, true);
897 897
 		if (isset($all_data['acList'])) {
898 898
 		    $reset = 0;
899 899
 		    foreach ($all_data['acList'] as $line) {
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
910 910
 			$data['emergency'] = ''; // emergency
911 911
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
912
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
912
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
913 913
 			else $data['datetime'] = date('Y-m-d H:i:s');
914 914
 			//$data['datetime'] = date('Y-m-d H:i:s');
915 915
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 			$data['verticalrate'] = $line['vrt']; // verticale rate
935 935
 			$data['squawk'] = $line['squawk']; // squawk
936 936
 			$data['emergency'] = ''; // emergency
937
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
937
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
938 938
 			else $data['datetime'] = date('Y-m-d H:i:s');
939 939
 			$data['format_source'] = 'aircraftlistjson';
940 940
 			$data['id_source'] = $id_source;
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
     	    )
956 956
     	) {
957 957
 	    $buffer = $Common->getData($value['host']);
958
-	    $all_data = json_decode($buffer,true);
958
+	    $all_data = json_decode($buffer, true);
959 959
 	    if (isset($all_data['planes'])) {
960 960
 		$reset = 0;
961 961
 		foreach ($all_data['planes'] as $key => $line) {
@@ -972,12 +972,12 @@  discard block
 block discarded – undo
972 972
 		    $data['emergency'] = ''; // emergency
973 973
 		    $data['registration'] = $line[2];
974 974
 		    $data['aircraft_icao'] = $line[0];
975
-		    $deparr = explode('-',$line[1]);
975
+		    $deparr = explode('-', $line[1]);
976 976
 		    if (count($deparr) === 2) {
977 977
 			$data['departure_airport_icao'] = $deparr[0];
978 978
 			$data['arrival_airport_icao'] = $deparr[1];
979 979
 		    }
980
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
980
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
981 981
 	    	    $data['format_source'] = 'planeupdatefaa';
982 982
     		    $data['id_source'] = $id_source;
983 983
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 	    )
996 996
 	) {
997 997
 	    $buffer = $Common->getData($value['host']);
998
-	    $all_data = json_decode($buffer,true);
998
+	    $all_data = json_decode($buffer, true);
999 999
 	    if (isset($all_data['states'])) {
1000 1000
 		$reset = 0;
1001 1001
 		foreach ($all_data['states'] as $key => $line) {
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 		    //$data['emergency'] = ''; // emergency
1013 1013
 		    //$data['registration'] = $line[2];
1014 1014
 		    //$data['aircraft_icao'] = $line[0];
1015
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1015
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1016 1016
 		    $data['format_source'] = 'opensky';
1017 1017
 		    $data['id_source'] = $id_source;
1018 1018
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	    )
1030 1030
 	) {
1031 1031
 	    $buffer = $Common->getData($value['host']);
1032
-	    $all_data = json_decode($buffer,true);
1033
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1032
+	    $all_data = json_decode($buffer, true);
1033
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1034 1034
 		$reset = 0;
1035 1035
 		foreach ($all_data['aircraft'] as $key => $line) {
1036 1036
 		    $data = array();
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	    )
1069 1069
 	) {
1070 1070
 	    $buffer = $Common->getData($value['host']);
1071
-	    $all_data = json_decode($buffer,true);
1071
+	    $all_data = json_decode($buffer, true);
1072 1072
 	    if (isset($all_data['aircraft'])) {
1073 1073
 		$reset = 0;
1074 1074
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 		    //$data['emergency'] = ''; // emergency
1086 1086
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087 1087
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1088
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1089 1089
 		    $data['format_source'] = 'planefinderclient';
1090 1090
 		    $data['id_source'] = $id_source;
1091 1091
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	) {
1105 1105
 	    //$buffer = $Common->getData($hosts[$id]);
1106 1106
 	    $buffer = $Common->getData($value['host']);
1107
-	    $all_data = json_decode($buffer,true);
1107
+	    $all_data = json_decode($buffer, true);
1108 1108
 	    if (!empty($all_data)) $reset = 0;
1109 1109
 	    foreach ($all_data as $key => $line) {
1110 1110
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1142,11 +1142,11 @@  discard block
 block discarded – undo
1142 1142
 	    )
1143 1143
 	) {
1144 1144
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1145
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1146 1146
 	    //echo $buffer;
1147
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1148
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
-	    $all_data = json_decode($buffer,true);
1147
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1148
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1149
+	    $all_data = json_decode($buffer, true);
1150 1150
 	    if (json_last_error() != JSON_ERROR_NONE) {
1151 1151
 		die(json_last_error_msg());
1152 1152
 	    }
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			//$data['departure_airport_iata'] = $line[11];
1170 1170
 			//$data['arrival_airport_iata'] = $line[12];
1171 1171
 	    		//$data['emergency'] = ''; // emergency
1172
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1172
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1173 1173
 	    		$data['format_source'] = 'radarvirtueljson';
1174 1174
     			$data['id_source'] = $id_source;
1175 1175
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1190,14 +1190,14 @@  discard block
 block discarded – undo
1190 1190
 	) {
1191 1191
 	    //$buffer = $Common->getData($hosts[$id]);
1192 1192
 	    $buffer = $Common->getData($value['host'].'?'.time());
1193
-	    $all_data = json_decode(utf8_encode($buffer),true);
1193
+	    $all_data = json_decode(utf8_encode($buffer), true);
1194 1194
 	    
1195 1195
 	    if (isset($all_data['pireps'])) {
1196 1196
 		$reset = 0;
1197 1197
 	        foreach ($all_data['pireps'] as $line) {
1198 1198
 		    $data = array();
1199 1199
 		    $data['id'] = $line['id'];
1200
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1200
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1201 1201
 		    $data['ident'] = $line['callsign']; // ident
1202 1202
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203 1203
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1227,9 +1227,9 @@  discard block
 block discarded – undo
1227 1227
 			$SI->add($data);
1228 1228
 		    //    print_r($data);
1229 1229
     		    } elseif ($line['icon'] === 'ct') {
1230
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1231
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232
-			$typec = substr($data['ident'],-3);
1230
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1231
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1232
+			$typec = substr($data['ident'], -3);
1233 1233
 			$data['type'] = '';
1234 1234
 			if ($typec === 'APP') $data['type'] = 'Approach';
1235 1235
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1241 1241
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242 1242
 			else $data['type'] = 'Observer';
1243
-			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']);
1243
+			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']);
1244 1244
 		    }
1245 1245
 		    unset($data);
1246 1246
 		}
@@ -1257,14 +1257,14 @@  discard block
 block discarded – undo
1257 1257
 	    //$buffer = $Common->getData($hosts[$id]);
1258 1258
 	    if ($globalDebug) echo 'Get Data...'."\n";
1259 1259
 	    $buffer = $Common->getData($value['host']);
1260
-	    $all_data = json_decode($buffer,true);
1260
+	    $all_data = json_decode($buffer, true);
1261 1261
 	    if ($buffer != '' && is_array($all_data)) {
1262 1262
 		$reset = 0;
1263 1263
 		foreach ($all_data as $line) {
1264 1264
 	    	    $data = array();
1265 1265
 	    	    //$data['id'] = $line['id']; // id not usable
1266 1266
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1267
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1268 1268
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269 1269
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270 1270
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 	    	    //$data['datetime'] = $line['lastupdate'];
1280 1280
 	    	    //$data['last_update'] = $line['lastupdate'];
1281 1281
 	    	    if (isset($value['timezone'])) {
1282
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1282
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1283 1283
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284 1284
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285 1285
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1295,14 +1295,14 @@  discard block
 block discarded – undo
1295 1295
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296 1296
 		    if (isset($line['aircraftname'])) {
1297 1297
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1298
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1299
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1300 1300
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301 1301
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302 1302
 	    		else {
1303
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1303
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1304
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1305
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1306 1306
 	    		}
1307 1307
 	    	    }
1308 1308
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 	    //$buffer = $Common->getData($hosts[$id]);
1328 1328
 	    if ($globalDebug) echo 'Get Data...'."\n";
1329 1329
 	    $buffer = $Common->getData($value['host']);
1330
-	    $all_data = json_decode($buffer,true);
1330
+	    $all_data = json_decode($buffer, true);
1331 1331
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1332 1332
 		$reset = 0;
1333 1333
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339 1339
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340 1340
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1341
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1342 1342
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343 1343
 	    	    $data['altitude'] = $line['altitude']; // altitude
1344 1344
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
 	    	    //$data['squawk'] = ''; // squawk
1350 1350
 	    	    //$data['emergency'] = ''; // emergency
1351 1351
 	    	    if (isset($value['timezone'])) {
1352
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1352
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1353 1353
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354 1354
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355 1355
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 	    //$buffer = $Common->getData($hosts[$id]);
1386 1386
 	    if ($globalDebug) echo 'Get Data...'."\n";
1387 1387
 	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1388
+	    $all_data = json_decode($buffer, true);
1389 1389
 	    if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392 1392
 	    	    $data = array();
1393 1393
 	    	    //$data['id'] = $line['id']; // id not usable
1394 1394
 	    	    $data['id'] = trim($line['flight_id']);
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1395
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1396 1396
 	    	    $data['pilot_name'] = $line['pilot_name'];
1397 1397
 	    	    $data['pilot_id'] = $line['pilot_id'];
1398 1398
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1436,24 +1436,24 @@  discard block
 block discarded – undo
1436 1436
 	    //$buffer = $Common->getData($hosts[$id]);
1437 1437
 	    if ($globalDebug) echo 'Get Data...'."\n";
1438 1438
 	    $buffer = $Common->getData($value['host']);
1439
-	    $all_data = json_decode($buffer,true);
1439
+	    $all_data = json_decode($buffer, true);
1440 1440
 	    if ($buffer != '') {
1441 1441
 		$Source->deleteLocationBySource('blitzortung');
1442
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1443
-		$buffer = explode('\n',$buffer);
1442
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1443
+		$buffer = explode('\n', $buffer);
1444 1444
 		foreach ($buffer as $buffer_line) {
1445
-		    $line = json_decode($buffer_line,true);
1445
+		    $line = json_decode($buffer_line, true);
1446 1446
 		    if (isset($line['time'])) {
1447 1447
 			$data = array();
1448 1448
 			$data['altitude'] = $line['alt']; // altitude
1449 1449
 			$data['latitude'] = $line['lat']; // lat
1450 1450
 			$data['longitude'] = $line['lon']; // long
1451
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1451
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1452 1452
 			$data['id_source'] = $id_source;
1453 1453
 			$data['format_source'] = 'blitzortung';
1454 1454
 			$SI->add($data);
1455 1455
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1456
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1456
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1457 1457
 			unset($data);
1458 1458
 		    }
1459 1459
 		}
@@ -1476,11 +1476,11 @@  discard block
 block discarded – undo
1476 1476
 		    //$value = $formats[$nb];
1477 1477
 		    $format = $globalSources[$nb]['format'];
1478 1478
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1479
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1479
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1480 1480
 		    } elseif ($format === 'vrstcp') {
1481 1481
 			$buffer = @socket_read($r, 6000);
1482 1482
 		    } else {
1483
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1483
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1484 1484
 		    }
1485 1485
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486 1486
 		    //echo $buffer."\n";
@@ -1490,8 +1490,8 @@  discard block
 block discarded – undo
1490 1490
 		    //$SI::del();
1491 1491
 		    if ($buffer !== FALSE) {
1492 1492
 			if ($format === 'vrstcp') {
1493
-			    $buffer = explode('},{',$buffer);
1494
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1493
+			    $buffer = explode('},{', $buffer);
1494
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1495 1495
 		    }
1496 1496
 		    // SBS format is CSV format
1497 1497
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 			    $ais_data = $AIS->parse_line(trim($buffer));
1516 1516
 			    $data = array();
1517 1517
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1518
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1519 1519
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520 1520
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521 1521
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1526,13 +1526,13 @@  discard block
 block discarded – undo
1526 1526
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527 1527
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528 1528
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1529
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1530 1530
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531 1531
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532 1532
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1533 1533
 
1534 1534
 			    if (isset($ais_data['timestamp'])) {
1535
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1535
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1536 1536
 			    } else {
1537 1537
 				$data['datetime'] = date('Y-m-d H:i:s');
1538 1538
 			    }
@@ -1543,10 +1543,10 @@  discard block
 block discarded – undo
1543 1543
                         } elseif ($format === 'flightgearsp') {
1544 1544
                     	    //echo $buffer."\n";
1545 1545
                     	    if (strlen($buffer) > 5) {
1546
-				$line = explode(',',$buffer);
1546
+				$line = explode(',', $buffer);
1547 1547
 				$data = array();
1548 1548
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1549
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1549
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1550 1550
 				$data['ident'] = $line[6];
1551 1551
 				$data['aircraft_name'] = $line[7];
1552 1552
 				$data['longitude'] = $line[1];
@@ -1563,16 +1563,16 @@  discard block
 block discarded – undo
1563 1563
                         } elseif ($format === 'acars') {
1564 1564
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565 1565
 			    $ACARS->add(trim($buffer));
1566
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1566
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1567 1567
 			    $ACARS->deleteLiveAcarsData();
1568 1568
 			} elseif ($format === 'flightgearmp') {
1569
-			    if (substr($buffer,0,1) != '#') {
1569
+			    if (substr($buffer, 0, 1) != '#') {
1570 1570
 				$data = array();
1571 1571
 				//echo $buffer."\n";
1572
-				$line = explode(' ',$buffer);
1572
+				$line = explode(' ', $buffer);
1573 1573
 				if (count($line) === 11) {
1574
-				    $userserver = explode('@',$line[0]);
1575
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1574
+				    $userserver = explode('@', $line[0]);
1575
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1576 1576
 				    $data['ident'] = $userserver[0];
1577 1577
 				    $data['registration'] = $userserver[0];
1578 1578
 				    $data['latitude'] = $line[4];
@@ -1580,8 +1580,8 @@  discard block
 block discarded – undo
1580 1580
 				    $data['altitude'] = $line[6];
1581 1581
 				    $data['datetime'] = date('Y-m-d H:i:s');
1582 1582
 				    $aircraft_type = $line[10];
1583
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1583
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1584
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1585 1585
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586 1586
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1587 1587
 				}
@@ -1590,8 +1590,8 @@  discard block
 block discarded – undo
1590 1590
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591 1591
 			    die;
1592 1592
 			} elseif ($format === 'vrstcp') {
1593
-			    foreach($buffer as $all_data) {
1594
-				$line = json_decode('{'.$all_data.'}',true);
1593
+			    foreach ($buffer as $all_data) {
1594
+				$line = json_decode('{'.$all_data.'}', true);
1595 1595
 				$data = array();
1596 1596
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1597 1597
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1617,16 +1617,16 @@  discard block
 block discarded – undo
1617 1617
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1618 1618
 				unset($data);
1619 1619
 			    }
1620
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1620
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1621 1621
 			    $line = explode("\t", $buffer);
1622
-			    for($k = 0; $k < count($line); $k=$k+2) {
1622
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1623 1623
 				$key = $line[$k];
1624
-			        $lined[$key] = $line[$k+1];
1624
+			        $lined[$key] = $line[$k + 1];
1625 1625
 			    }
1626 1626
     			    if (count($lined) > 3) {
1627 1627
     				$data['hex'] = $lined['hexid'];
1628 1628
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1629
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1630 1630
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631 1631
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632 1632
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1645,23 +1645,23 @@  discard block
 block discarded – undo
1645 1645
     			    } else $error = true;
1646 1646
 			} elseif ($format === 'aprs' && $use_aprs) {
1647 1647
 			    if ($aprs_connect === 0) {
1648
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1648
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1649 1649
 				$aprs_connect = 1;
1650 1650
 			    }
1651 1651
 			    
1652
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1652
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1653 1653
 				$aprs_last_tx = time();
1654 1654
 				$data_aprs = "# Keep alive";
1655
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1655
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1656 1656
 			    }
1657 1657
 			    
1658 1658
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659 1659
 			    //echo 'APRS data : '.$buffer."\n";
1660
-			    $buffer = str_replace('APRS <- ','',$buffer);
1661
-			    $buffer = str_replace('APRS -> ','',$buffer);
1660
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1661
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1662 1662
 			    //echo $buffer."\n";
1663 1663
 			    date_default_timezone_set('UTC');
1664
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1664
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1665 1665
 				$line = $APRS->parse($buffer);
1666 1666
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1667 1667
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677 1677
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678 1678
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1679
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1680 1680
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1681 1681
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1682 1682
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1759,29 +1759,29 @@  discard block
 block discarded – undo
1759 1759
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760 1760
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1761 1761
 					$Source->deleteOldLocationByType('gs');
1762
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1763
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1762
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1763
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1764 1764
 					} else {
1765
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1765
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1766 1766
 					}
1767 1767
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 1768
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769 1769
 					if ($globalDebug) echo '# Weather Station added'."\n";
1770 1770
 					$Source->deleteOldLocationByType('wx');
1771 1771
 					$weather_data = json_encode($line);
1772
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1773
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1772
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1773
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1774 1774
 					} else {
1775
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1775
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1776 1776
 					}
1777 1777
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 1778
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779 1779
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1780 1780
 					$Source->deleteOldLocationByType('lightning');
1781
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1782
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1781
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1782
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1783 1783
 					} else {
1784
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1784
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1785 1785
 					}
1786 1786
 				    } elseif ($globalDebug) {
1787 1787
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
 				    unset($data);
1791 1791
 				}
1792 1792
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1793
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1794 1794
 				}
1795 1795
 				/*
1796 1796
 				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')) {
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
 				*/
1800 1800
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1801 1801
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1802
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1802
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1803 1803
 					$Source->deleteOldLocationByType('lightning');
1804 1804
 					$Source->deleteOldLocationByType('wx');
1805 1805
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
 				connect_all($sourceee);
1885 1885
 				$sourceee = array();
1886 1886
 				//connect_all($globalSources);
1887
-				$tt[$format]=0;
1887
+				$tt[$format] = 0;
1888 1888
 				break;
1889 1889
 			    } 
1890 1890
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1894,14 +1894,14 @@  discard block
 block discarded – undo
1894 1894
 	    } else {
1895 1895
 		$error = socket_strerror(socket_last_error());
1896 1896
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1897
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1897
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1898 1898
 			if (isset($globalDebug)) echo "Restarting...\n";
1899 1899
 			// Restart the script if possible
1900 1900
 			if (is_array($sockets)) {
1901 1901
 			    if ($globalDebug) echo "Shutdown all sockets...";
1902 1902
 			    
1903 1903
 			    foreach ($sockets as $sock) {
1904
-				@socket_shutdown($sock,2);
1904
+				@socket_shutdown($sock, 2);
1905 1905
 				@socket_close($sock);
1906 1906
 			    }
1907 1907
 			    
Please login to merge, or discard this patch.
Indentation   +1091 added lines, -1091 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,127 +200,127 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
-	    $hostport = explode(':',$host);
276
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
+		$hostport = explode(':',$host);
276
+		if (isset($hostport[1])) {
277 277
 		$port = $hostport[1];
278 278
 		$hostn = $hostport[0];
279
-	    } else {
279
+		} else {
280 280
 		$port = $globalSources[$id]['port'];
281 281
 		$hostn = $globalSources[$id]['host'];
282
-	    }
283
-	    $Common = new Common();
284
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
-    	    } else {
287
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
-	    }
289
-	    if ($s) {
290
-    	        $sockets[$id] = $s;
291
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
282
+		}
283
+		$Common = new Common();
284
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
+			} else {
287
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
+		}
289
+		if ($s) {
290
+				$sockets[$id] = $s;
291
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293 293
 			//$formats[$id] = 'aprs';
294 294
 			$globalSources[$id]['format'] = 'aprs';
295 295
 			//$aprs_connect = 0;
296 296
 			//$use_aprs = true;
297
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
297
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298 298
 			$globalSources[$id]['format'] = 'vrstcp';
299
-    		    } elseif ($port == '10001') {
300
-        		//$formats[$id] = 'tsv';
301
-        		$globalSources[$id]['format'] = 'tsv';
302
-		    } elseif ($port == '30002') {
303
-        		//$formats[$id] = 'raw';
304
-        		$globalSources[$id]['format'] = 'raw';
305
-		    } elseif ($port == '5001') {
306
-        		//$formats[$id] = 'raw';
307
-        		$globalSources[$id]['format'] = 'flightgearmp';
308
-		    } elseif ($port == '30005') {
299
+				} elseif ($port == '10001') {
300
+				//$formats[$id] = 'tsv';
301
+				$globalSources[$id]['format'] = 'tsv';
302
+			} elseif ($port == '30002') {
303
+				//$formats[$id] = 'raw';
304
+				$globalSources[$id]['format'] = 'raw';
305
+			} elseif ($port == '5001') {
306
+				//$formats[$id] = 'raw';
307
+				$globalSources[$id]['format'] = 'flightgearmp';
308
+			} elseif ($port == '30005') {
309 309
 			// Not yet supported
310
-        		//$formats[$id] = 'beast';
311
-        		$globalSources[$id]['format'] = 'beast';
312
-		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
314
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310
+				//$formats[$id] = 'beast';
311
+				$globalSources[$id]['format'] = 'beast';
312
+			//} else $formats[$id] = 'sbs';
313
+			} else $globalSources[$id]['format'] = 'sbs';
314
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 315
 		}
316 316
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
317
-            } else {
317
+			} else {
318 318
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
319 319
 		sleep(10);
320 320
 		connect_all($hosts);
321
-    	    }
322
-        }
323
-    }
321
+			}
322
+		}
323
+	}
324 324
 }
325 325
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
326 326
 
@@ -343,9 +343,9 @@  discard block
 block discarded – undo
343 343
 //connect_all($globalSources);
344 344
 
345 345
 if (isset($globalProxy) && $globalProxy) {
346
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
346
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347 347
 } else {
348
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
348
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
349 349
 }
350 350
 
351 351
 // APRS Configuration
@@ -354,21 +354,21 @@  discard block
 block discarded – undo
354 354
 	die;
355 355
 }
356 356
 foreach ($globalSources as $key => $source) {
357
-    if (!isset($source['format'])) {
358
-        $globalSources[$key]['format'] = 'auto';
359
-    }
360
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
361
-        unset($globalSources[$key]);
362
-    }
357
+	if (!isset($source['format'])) {
358
+		$globalSources[$key]['format'] = 'auto';
359
+	}
360
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
361
+		unset($globalSources[$key]);
362
+	}
363 363
 }
364 364
 connect_all($globalSources);
365 365
 foreach ($globalSources as $key => $source) {
366
-    if (isset($source['format']) && $source['format'] == 'aprs') {
366
+	if (isset($source['format']) && $source['format'] == 'aprs') {
367 367
 	$aprs_connect = 0;
368 368
 	$use_aprs = true;
369 369
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
370 370
 	break;
371
-    }
371
+	}
372 372
 }
373 373
 
374 374
 if ($use_aprs) {
@@ -409,133 +409,133 @@  discard block
 block discarded – undo
409 409
 
410 410
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 411
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
412
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413 413
 
414
-    if (!$globalDaemon) $i = $endtime-time();
415
-    // Delete old ATC
416
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
414
+	if (!$globalDaemon) $i = $endtime-time();
415
+	// Delete old ATC
416
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
418
-        $ATC->deleteOldATC();
419
-    }
418
+		$ATC->deleteOldATC();
419
+	}
420 420
     
421
-    if (count($last_exec) == count($globalSources)) {
421
+	if (count($last_exec) == count($globalSources)) {
422 422
 	$max = $globalMinFetch;
423 423
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
424
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425 425
 	}
426 426
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
428
-	    sleep($globalMinFetch-$max+2);
427
+		if ($globalDebug) echo 'Sleeping...'."\n";
428
+		sleep($globalMinFetch-$max+2);
429
+	}
429 430
 	}
430
-    }
431 431
 
432 432
     
433
-    //foreach ($formats as $id => $value) {
434
-    foreach ($globalSources as $id => $value) {
433
+	//foreach ($formats as $id => $value) {
434
+	foreach ($globalSources as $id => $value) {
435 435
 	date_default_timezone_set('UTC');
436 436
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437 437
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
438 438
 	if ($value['format'] === 'deltadbtxt' && 
439
-	    (
439
+		(
440 440
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
441 441
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
442
-	    )
442
+		)
443 443
 	) {
444
-	    //$buffer = $Common->getData($hosts[$id]);
445
-	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
447
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
-	    $buffer = explode('\n',$buffer);
449
-	    foreach ($buffer as $line) {
450
-    		if ($line != '' && count($line) > 7) {
451
-    		    $line = explode(',', $line);
452
-	            $data = array();
453
-	            $data['hex'] = $line[1]; // hex
454
-	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
-	            $data['verticalrate'] = ''; // vertical rate
461
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
-	            $data['emergency'] = ''; // emergency
463
-		    $data['datetime'] = date('Y-m-d H:i:s');
464
-		    $data['format_source'] = 'deltadbtxt';
465
-    		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
-    		    $SI->add($data);
470
-		    unset($data);
471
-    		}
472
-    	    }
473
-    	    $last_exec[$id]['last'] = time();
444
+		//$buffer = $Common->getData($hosts[$id]);
445
+		$buffer = $Common->getData($value['host']);
446
+		if ($buffer != '') $reset = 0;
447
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
+		$buffer = explode('\n',$buffer);
449
+		foreach ($buffer as $line) {
450
+			if ($line != '' && count($line) > 7) {
451
+				$line = explode(',', $line);
452
+				$data = array();
453
+				$data['hex'] = $line[1]; // hex
454
+				$data['ident'] = $line[2]; // ident
455
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
+				$data['verticalrate'] = ''; // vertical rate
461
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
+				$data['emergency'] = ''; // emergency
463
+			$data['datetime'] = date('Y-m-d H:i:s');
464
+			$data['format_source'] = 'deltadbtxt';
465
+				$data['id_source'] = $id_source;
466
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
+				$SI->add($data);
470
+			unset($data);
471
+			}
472
+			}
473
+			$last_exec[$id]['last'] = time();
474 474
 	} elseif ($value['format'] === 'aisnmeatxt' && 
475
-	    (
475
+		(
476 476
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
477 477
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
478
-	    )
478
+		)
479 479
 	) {
480
-	    date_default_timezone_set('CET');
481
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
-	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
484
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
-	    $buffer = explode('\n',$buffer);
486
-	    foreach ($buffer as $line) {
480
+		date_default_timezone_set('CET');
481
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
+		date_default_timezone_set('UTC');
483
+		if ($buffer != '') $reset = 0;
484
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
+		$buffer = explode('\n',$buffer);
486
+		foreach ($buffer as $line) {
487 487
 		if ($line != '') {
488
-		    //echo "'".$line."'\n";
489
-		    $add = false;
490
-		    $ais_data = $AIS->parse_line(trim($line));
491
-		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
-		    if (isset($ais_data['timestamp'])) {
488
+			//echo "'".$line."'\n";
489
+			$add = false;
490
+			$ais_data = $AIS->parse_line(trim($line));
491
+			$data = array();
492
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
+			if (isset($ais_data['timestamp'])) {
505 505
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 506
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
507
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
-			    $add = true;
507
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
+				$add = true;
509 509
 			}
510
-		    } else {
510
+			} else {
511 511
 			$data['datetime'] = date('Y-m-d H:i:s');
512 512
 			$add = true;
513
-		    }
514
-		    $data['format_source'] = 'aisnmeatxt';
515
-    		    $data['id_source'] = $id_source;
516
-		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
-		    unset($data);
513
+			}
514
+			$data['format_source'] = 'aisnmeatxt';
515
+				$data['id_source'] = $id_source;
516
+			//print_r($data);
517
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
+			unset($data);
520 520
 		}
521
-    	    }
522
-    	    $last_exec[$id]['last'] = time();
521
+			}
522
+			$last_exec[$id]['last'] = time();
523 523
 	} elseif ($value['format'] === 'aisnmeahttp') {
524
-	    $arr = $httpfeeds;
525
-	    $w = $e = null;
524
+		$arr = $httpfeeds;
525
+		$w = $e = null;
526 526
 	    
527
-	    if (isset($arr[$id])) {
527
+		if (isset($arr[$id])) {
528 528
 		$nn = stream_select($arr,$w,$e,$timeout);
529 529
 		if ($nn > 0) {
530
-		    foreach ($httpfeeds as $feed) {
530
+			foreach ($httpfeeds as $feed) {
531 531
 			$buffer = stream_get_line($feed,2000,"\n");
532 532
 			if ($buffer === FALSE) {
533
-			    connect_all($globalSources);
533
+				connect_all($globalSources);
534 534
 			}
535 535
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
536 536
 			$buffer = explode('\n',$buffer);
537 537
 			foreach ($buffer as $line) {
538
-			    if ($line != '') {
538
+				if ($line != '') {
539 539
 				$ais_data = $AIS->parse_line(trim($line));
540 540
 				$data = array();
541 541
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -553,117 +553,117 @@  discard block
 block discarded – undo
553 553
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554 554
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
555 555
 				if (isset($ais_data['timestamp'])) {
556
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
556
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 557
 				} else {
558
-				    $data['datetime'] = date('Y-m-d H:i:s');
558
+					$data['datetime'] = date('Y-m-d H:i:s');
559 559
 				}
560 560
 				$data['format_source'] = 'aisnmeahttp';
561 561
 				$data['id_source'] = $id_source;
562 562
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563 563
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
564 564
 				unset($data);
565
-			    }
565
+				}
566
+			}
566 567
 			}
567
-		    }
568 568
 		} else {
569
-		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
572
-		    if ($tt[$format] > 30) {
569
+			$format = $value['format'];
570
+			if (isset($tt[$format])) $tt[$format]++;
571
+			else $tt[$format] = 0;
572
+			if ($tt[$format] > 30) {
573 573
 			if ($globalDebug) echo 'Reconnect...'."\n";
574 574
 			sleep(2);
575 575
 			//$sourceeen[] = $value;
576 576
 			//connect_all($sourceeen);
577 577
 			//$sourceeen = array();
578 578
 			connect_all($globalSources);
579
-		    }
579
+			}
580
+		}
580 581
 		}
581
-	    }
582 582
 	} elseif ($value['format'] === 'myshiptracking' && 
583
-	    (
583
+		(
584 584
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
585 585
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
586
-	    )
586
+		)
587 587
 	) {
588
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
589
-	    if ($buffer != '') {
588
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
589
+		if ($buffer != '') {
590 590
 		//echo $buffer;
591 591
 		$all_data = json_decode($buffer,true);
592 592
 		//print_r($all_data);
593 593
 		if (isset($all_data[0]['DATA'])) {
594
-		    foreach ($all_data[0]['DATA'] as $line) {
594
+			foreach ($all_data[0]['DATA'] as $line) {
595 595
 			if ($line != '') {
596
-			    $data = array();
597
-			    $data['ident'] = $line['NAME'];
598
-			    $data['mmsi'] = $line['MMSI'];
599
-			    if (strlen($data['mmsi']) > 9) {
596
+				$data = array();
597
+				$data['ident'] = $line['NAME'];
598
+				$data['mmsi'] = $line['MMSI'];
599
+				if (strlen($data['mmsi']) > 9) {
600 600
 				$data['mmsi'] = substr($data['mmsi'],-9);
601
-			    }
602
-			    $data['speed'] = $line['SOG'];
603
-			    $data['heading'] = $line['COG'];
604
-			    $data['latitude'] = $line['LAT'];
605
-			    $data['longitude'] = $line['LNG'];
606
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
-			    //$data['type_id'] = $line['TYPE'];
608
-			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
-			    $data['format_source'] = 'myshiptracking';
613
-			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
-			    $MI->add($data);
616
-			    unset($data);
601
+				}
602
+				$data['speed'] = $line['SOG'];
603
+				$data['heading'] = $line['COG'];
604
+				$data['latitude'] = $line['LAT'];
605
+				$data['longitude'] = $line['LNG'];
606
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
+				//$data['type_id'] = $line['TYPE'];
608
+				$data['imo'] = $line['IMO'];
609
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
+				$data['format_source'] = 'myshiptracking';
613
+				$data['id_source'] = $id_source;
614
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
+				$MI->add($data);
616
+				unset($data);
617 617
 			}
618
-		    }
618
+			}
619
+		}
619 620
 		}
620
-	    }
621
-	    $last_exec[$id]['last'] = time();
621
+		$last_exec[$id]['last'] = time();
622 622
 	} elseif ($value['format'] === 'boatbeaconapp' && 
623
-	    (
623
+		(
624 624
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
625 625
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
626
-	    )
626
+		)
627 627
 	) {
628
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
-	    if ($buffer != '') {
628
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
+		if ($buffer != '') {
630 630
 		$all_data = json_decode($buffer,true);
631 631
 		if (isset($all_data[0]['mmsi'])) {
632
-		    foreach ($all_data as $line) {
632
+			foreach ($all_data as $line) {
633 633
 			if ($line != '') {
634
-			    $data = array();
635
-			    $data['ident'] = $line['shipname'];
636
-			    $data['callsign'] = $line['callsign'];
637
-			    $data['mmsi'] = substr($line['mmsi'],-9);
638
-			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
-			    $data['latitude'] = $line['latitude'];
641
-			    $data['longitude'] = $line['longitude'];
642
-			    $data['type_id'] = $line['shiptype'];
643
-			    $data['arrival_code'] = $line['destination'];
644
-			    $data['datetime'] = $line['time'];
645
-			    $data['format_source'] = 'boatbeaconapp';
646
-			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
-			    $MI->add($data);
649
-			    unset($data);
634
+				$data = array();
635
+				$data['ident'] = $line['shipname'];
636
+				$data['callsign'] = $line['callsign'];
637
+				$data['mmsi'] = substr($line['mmsi'],-9);
638
+				$data['speed'] = $line['sog'];
639
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
+				$data['latitude'] = $line['latitude'];
641
+				$data['longitude'] = $line['longitude'];
642
+				$data['type_id'] = $line['shiptype'];
643
+				$data['arrival_code'] = $line['destination'];
644
+				$data['datetime'] = $line['time'];
645
+				$data['format_source'] = 'boatbeaconapp';
646
+				$data['id_source'] = $id_source;
647
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
+				$MI->add($data);
649
+				unset($data);
650
+			}
650 651
 			}
651
-		    }
652 652
 		}
653 653
 		
654
-	    }
655
-    	    $last_exec[$id]['last'] = time();
654
+		}
655
+			$last_exec[$id]['last'] = time();
656 656
 	} elseif ($value['format'] === 'boatnerd' && 
657
-	    (
657
+		(
658 658
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
659 659
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
660
-	    )
660
+		)
661 661
 	) {
662
-	    $buffer = $Common->getData($value['host']);
663
-	    if ($buffer != '') {
662
+		$buffer = $Common->getData($value['host']);
663
+		if ($buffer != '') {
664 664
 		$all_data = json_decode($buffer,true);
665 665
 		if (isset($all_data['features'][0]['id'])) {
666
-		    foreach ($all_data['features'] as $line) {
666
+			foreach ($all_data['features'] as $line) {
667 667
 			print_r($line);
668 668
 			$data = array();
669 669
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -683,80 +683,80 @@  discard block
 block discarded – undo
683 683
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684 684
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
685 685
 			unset($data);
686
-		    }
686
+			}
687 687
 		}
688 688
 		
689
-	    }
690
-    	    $last_exec[$id]['last'] = time();
689
+		}
690
+			$last_exec[$id]['last'] = time();
691 691
 	} elseif ($value['format'] === 'shipplotter' && 
692
-	    (
692
+		(
693 693
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
694 694
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
695
-	    )
695
+		)
696 696
 	) {
697
-	    echo 'download...';
698
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
-	    echo 'done !'."\n";
700
-	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
702
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
-	    $buffer = explode('\n',$buffer);
704
-	    foreach ($buffer as $line) {
697
+		echo 'download...';
698
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
+		echo 'done !'."\n";
700
+		// FIXME: Need more work
701
+		if ($buffer != '') $reset = 0;
702
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
+		$buffer = explode('\n',$buffer);
704
+		foreach ($buffer as $line) {
705 705
 		if ($line != '') {
706
-		    $data = array();
707
-		    echo $line."\n";
708
-		    $data['mmsi'] = (int)substr($line,0,9);
709
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
-		    $data['status_id'] = substr($line,21,2);
711
-		    $data['type_id'] = substr($line,24,3);
712
-		    $data['latitude'] = substr($line,29,9);
713
-		    $data['longitude'] = substr($line,41,9);
714
-		    $data['speed'] = round(substr($line,51,5));
715
-		    //$data['course'] = substr($line,57,5);
716
-		    $data['heading'] = round(substr($line,63,3));
717
-		    //$data['draft'] = substr($line,67,4);
718
-		    //$data['length'] = substr($line,72,3);
719
-		    //$data['beam'] = substr($line,76,2);
720
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
-		    //$data['callsign'] = trim(substr($line,100,7);
722
-		    $data['arrival_code'] = substr($line,108,20);
723
-		    //$data['etaDate'] = substr($line,129,5);
724
-		    //$data['etaTime'] = substr($line,135,5);
725
-		    $data['format_source'] = 'shipplotter';
726
-    		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
-		    //print_r($data);
729
-		    echo 'Add...'."\n";
730
-		    $MI->add($data);
731
-		    unset($data);
706
+			$data = array();
707
+			echo $line."\n";
708
+			$data['mmsi'] = (int)substr($line,0,9);
709
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
+			$data['status_id'] = substr($line,21,2);
711
+			$data['type_id'] = substr($line,24,3);
712
+			$data['latitude'] = substr($line,29,9);
713
+			$data['longitude'] = substr($line,41,9);
714
+			$data['speed'] = round(substr($line,51,5));
715
+			//$data['course'] = substr($line,57,5);
716
+			$data['heading'] = round(substr($line,63,3));
717
+			//$data['draft'] = substr($line,67,4);
718
+			//$data['length'] = substr($line,72,3);
719
+			//$data['beam'] = substr($line,76,2);
720
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
+			//$data['callsign'] = trim(substr($line,100,7);
722
+			$data['arrival_code'] = substr($line,108,20);
723
+			//$data['etaDate'] = substr($line,129,5);
724
+			//$data['etaTime'] = substr($line,135,5);
725
+			$data['format_source'] = 'shipplotter';
726
+				$data['id_source'] = $id_source;
727
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
+			//print_r($data);
729
+			echo 'Add...'."\n";
730
+			$MI->add($data);
731
+			unset($data);
732 732
 		}
733
-    	    }
734
-    	    $last_exec[$id]['last'] = time();
733
+			}
734
+			$last_exec[$id]['last'] = time();
735 735
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
736 736
 	} elseif (
737
-	    (
737
+		(
738 738
 		$value['format'] === 'whazzup' && 
739 739
 		(
740
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
740
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
742 742
 		)
743
-	    ) || (
743
+		) || (
744 744
 		$value['format'] === 'vatsimtxt' && 
745 745
 		(
746
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
746
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
748
+		)
748 749
 		)
749
-	    )
750 750
 	) {
751
-	    //$buffer = $Common->getData($hosts[$id]);
752
-	    $buffer = $Common->getData($value['host']);
753
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
-	    $buffer = explode('\n',$buffer);
755
-	    $reset = 0;
756
-	    foreach ($buffer as $line) {
757
-    		if ($line != '') {
758
-    		    $line = explode(':', $line);
759
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
751
+		//$buffer = $Common->getData($hosts[$id]);
752
+		$buffer = $Common->getData($value['host']);
753
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
+		$buffer = explode('\n',$buffer);
755
+		$reset = 0;
756
+		foreach ($buffer as $line) {
757
+			if ($line != '') {
758
+				$line = explode(':', $line);
759
+				if (count($line) > 30 && $line[0] != 'callsign') {
760 760
 			$data = array();
761 761
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762 762
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -769,37 +769,37 @@  discard block
 block discarded – undo
769 769
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770 770
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
771 771
 			$data['latitude'] = $line[5]; // lat
772
-	        	$data['longitude'] = $line[6]; // long
773
-	        	$data['verticalrate'] = ''; // vertical rate
774
-	        	$data['squawk'] = ''; // squawk
775
-	        	$data['emergency'] = ''; // emergency
776
-	        	$data['waypoints'] = $line[30];
772
+				$data['longitude'] = $line[6]; // long
773
+				$data['verticalrate'] = ''; // vertical rate
774
+				$data['squawk'] = ''; // squawk
775
+				$data['emergency'] = ''; // emergency
776
+				$data['waypoints'] = $line[30];
777 777
 			$data['datetime'] = date('Y-m-d H:i:s');
778 778
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
779 779
 			//if (isset($line[37])) $data['last_update'] = $line[37];
780
-		        $data['departure_airport_icao'] = $line[11];
781
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
-		        $data['arrival_airport_icao'] = $line[13];
780
+				$data['departure_airport_icao'] = $line[11];
781
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
+				$data['arrival_airport_icao'] = $line[13];
783 783
 			$data['frequency'] = $line[4];
784 784
 			$data['type'] = $line[18];
785 785
 			$data['range'] = $line[19];
786 786
 			if (isset($line[35])) $data['info'] = $line[35];
787
-    			$data['id_source'] = $id_source;
788
-	    		//$data['arrival_airport_time'] = ;
789
-	    		if ($line[9] != '') {
790
-	    		    $aircraft_data = explode('/',$line[9]);
791
-	    		    if (isset($aircraft_data[1])) {
792
-	    			$data['aircraft_icao'] = $aircraft_data[1];
793
-	    		    }
794
-        		}
795
-	    		/*
787
+				$data['id_source'] = $id_source;
788
+				//$data['arrival_airport_time'] = ;
789
+				if ($line[9] != '') {
790
+					$aircraft_data = explode('/',$line[9]);
791
+					if (isset($aircraft_data[1])) {
792
+					$data['aircraft_icao'] = $aircraft_data[1];
793
+					}
794
+				}
795
+				/*
796 796
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
797 797
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 798
 	    		*/
799
-	    		$data['format_source'] = $value['format'];
799
+				$data['format_source'] = $value['format'];
800 800
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801 801
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
802
+				if ($line[3] === 'PILOT') $SI->add($data);
803 803
 			elseif ($line[3] === 'ATC') {
804 804
 				//print_r($data);
805 805
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -820,21 +820,21 @@  discard block
 block discarded – undo
820 820
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
821 821
 				}
822 822
 			}
823
-    			unset($data);
824
-    		    }
825
-    		}
826
-    	    }
827
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
-    	    $last_exec[$id]['last'] = time();
830
-    	} elseif ($value['format'] === 'airwhere' && 
831
-    	    (
832
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
-    	    )
835
-    	) {
836
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
-	    if ($buffer != '') {
823
+				unset($data);
824
+				}
825
+			}
826
+			}
827
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
+			$last_exec[$id]['last'] = time();
830
+		} elseif ($value['format'] === 'airwhere' && 
831
+			(
832
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
+			)
835
+		) {
836
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
+		if ($buffer != '') {
838 838
 		$all_data = simplexml_load_string($buffer);
839 839
 		foreach($all_data->children() as $childdata) {
840 840
 			$data = array();
@@ -856,10 +856,10 @@  discard block
 block discarded – undo
856 856
 			$SI->add($data);
857 857
 			unset($data);
858 858
 		}
859
-	    }
860
-	    $Source->deleteOldLocationByType('gs');
861
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
-	    if ($buffer != '') {
859
+		}
860
+		$Source->deleteOldLocationByType('gs');
861
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
+		if ($buffer != '') {
863 863
 		$all_data = simplexml_load_string($buffer);
864 864
 		foreach($all_data->children() as $childdata) {
865 865
 			$data = array();
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 			unset($data);
879 879
 		}
880
-	    }
881
-	    $last_exec[$id]['last'] = time();
880
+		}
881
+		$last_exec[$id]['last'] = time();
882 882
 	/*
883 883
 	} if ($value['format'] === 'aircraftlistjson') {
884 884
 	    print_r($globalSources);
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 	    echo $globalMinFetch;
887 887
 	*/
888 888
 	} elseif ($value['format'] === 'aircraftlistjson' && 
889
-	    (
889
+		(
890 890
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
891 891
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
892
-	    )
892
+		)
893 893
 	) {
894
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
895
-	    if ($buffer != '') {
896
-	        $all_data = json_decode($buffer,true);
894
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
895
+		if ($buffer != '') {
896
+			$all_data = json_decode($buffer,true);
897 897
 		if (isset($all_data['acList'])) {
898
-		    $reset = 0;
899
-		    foreach ($all_data['acList'] as $line) {
898
+			$reset = 0;
899
+			foreach ($all_data['acList'] as $line) {
900 900
 			$data = array();
901 901
 			$data['hex'] = $line['Icao']; // hex
902 902
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920 920
 			if (isset($data['latitude'])) $SI->add($data);
921 921
 			unset($data);
922
-		    }
922
+			}
923 923
 		} elseif (is_array($all_data)) {
924
-		    $reset = 0;
925
-		    foreach ($all_data as $line) {
924
+			$reset = 0;
925
+			foreach ($all_data as $line) {
926 926
 			$data = array();
927 927
 			$data['hex'] = $line['hex']; // hex
928 928
 			$data['ident'] = $line['flight']; // ident
@@ -942,291 +942,291 @@  discard block
 block discarded – undo
942 942
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
943 943
 			$SI->add($data);
944 944
 			unset($data);
945
-		    }
945
+			}
946 946
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
948
-    	    //$last_exec['aircraftlistjson'] = time();
949
-    	    $last_exec[$id]['last'] = time();
950
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
952
-    	    (
953
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
-    	    )
956
-    	) {
957
-	    $buffer = $Common->getData($value['host']);
958
-	    $all_data = json_decode($buffer,true);
959
-	    if (isset($all_data['planes'])) {
947
+		} elseif ($globalDebug) echo 'No data'."\n";
948
+			//$last_exec['aircraftlistjson'] = time();
949
+			$last_exec[$id]['last'] = time();
950
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
+		} elseif ($value['format'] === 'planeupdatefaa' && 
952
+			(
953
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
+			)
956
+		) {
957
+		$buffer = $Common->getData($value['host']);
958
+		$all_data = json_decode($buffer,true);
959
+		if (isset($all_data['planes'])) {
960 960
 		$reset = 0;
961 961
 		foreach ($all_data['planes'] as $key => $line) {
962
-		    $data = array();
963
-		    $data['hex'] = $key; // hex
964
-		    $data['ident'] = $line[3]; // ident
965
-		    $data['altitude'] = $line[6]; // altitude
966
-		    $data['speed'] = $line[8]; // speed
967
-		    $data['heading'] = $line[7]; // heading
968
-		    $data['latitude'] = $line[4]; // lat
969
-		    $data['longitude'] = $line[5]; // long
970
-		    //$data['verticalrate'] = $line[]; // verticale rate
971
-		    $data['squawk'] = $line[10]; // squawk
972
-		    $data['emergency'] = ''; // emergency
973
-		    $data['registration'] = $line[2];
974
-		    $data['aircraft_icao'] = $line[0];
975
-		    $deparr = explode('-',$line[1]);
976
-		    if (count($deparr) === 2) {
962
+			$data = array();
963
+			$data['hex'] = $key; // hex
964
+			$data['ident'] = $line[3]; // ident
965
+			$data['altitude'] = $line[6]; // altitude
966
+			$data['speed'] = $line[8]; // speed
967
+			$data['heading'] = $line[7]; // heading
968
+			$data['latitude'] = $line[4]; // lat
969
+			$data['longitude'] = $line[5]; // long
970
+			//$data['verticalrate'] = $line[]; // verticale rate
971
+			$data['squawk'] = $line[10]; // squawk
972
+			$data['emergency'] = ''; // emergency
973
+			$data['registration'] = $line[2];
974
+			$data['aircraft_icao'] = $line[0];
975
+			$deparr = explode('-',$line[1]);
976
+			if (count($deparr) === 2) {
977 977
 			$data['departure_airport_icao'] = $deparr[0];
978 978
 			$data['arrival_airport_icao'] = $deparr[1];
979
-		    }
980
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
-	    	    $data['format_source'] = 'planeupdatefaa';
982
-    		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
-		    $SI->add($data);
986
-		    unset($data);
979
+			}
980
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
+				$data['format_source'] = 'planeupdatefaa';
982
+				$data['id_source'] = $id_source;
983
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
+			$SI->add($data);
986
+			unset($data);
987 987
 		}
988
-	    }
989
-	    //$last_exec['planeupdatefaa'] = time();
990
-	    $last_exec[$id]['last'] = time();
988
+		}
989
+		//$last_exec['planeupdatefaa'] = time();
990
+		$last_exec[$id]['last'] = time();
991 991
 	} elseif ($value['format'] === 'opensky' && 
992
-	    (
992
+		(
993 993
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
994 994
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
995
-	    )
995
+		)
996 996
 	) {
997
-	    $buffer = $Common->getData($value['host']);
998
-	    $all_data = json_decode($buffer,true);
999
-	    if (isset($all_data['states'])) {
997
+		$buffer = $Common->getData($value['host']);
998
+		$all_data = json_decode($buffer,true);
999
+		if (isset($all_data['states'])) {
1000 1000
 		$reset = 0;
1001 1001
 		foreach ($all_data['states'] as $key => $line) {
1002
-		    $data = array();
1003
-		    $data['hex'] = $line[0]; // hex
1004
-		    $data['ident'] = trim($line[1]); // ident
1005
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1006
-		    $data['speed'] = round($line[9]*1.94384); // speed
1007
-		    $data['heading'] = round($line[10]); // heading
1008
-		    $data['latitude'] = $line[6]; // lat
1009
-		    $data['longitude'] = $line[5]; // long
1010
-		    $data['verticalrate'] = $line[11]; // verticale rate
1011
-		    //$data['squawk'] = $line[10]; // squawk
1012
-		    //$data['emergency'] = ''; // emergency
1013
-		    //$data['registration'] = $line[2];
1014
-		    //$data['aircraft_icao'] = $line[0];
1015
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
-		    $data['format_source'] = 'opensky';
1017
-		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
-		    $SI->add($data);
1020
-		    unset($data);
1002
+			$data = array();
1003
+			$data['hex'] = $line[0]; // hex
1004
+			$data['ident'] = trim($line[1]); // ident
1005
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1006
+			$data['speed'] = round($line[9]*1.94384); // speed
1007
+			$data['heading'] = round($line[10]); // heading
1008
+			$data['latitude'] = $line[6]; // lat
1009
+			$data['longitude'] = $line[5]; // long
1010
+			$data['verticalrate'] = $line[11]; // verticale rate
1011
+			//$data['squawk'] = $line[10]; // squawk
1012
+			//$data['emergency'] = ''; // emergency
1013
+			//$data['registration'] = $line[2];
1014
+			//$data['aircraft_icao'] = $line[0];
1015
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
+			$data['format_source'] = 'opensky';
1017
+			$data['id_source'] = $id_source;
1018
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
+			$SI->add($data);
1020
+			unset($data);
1021
+		}
1021 1022
 		}
1022
-	    }
1023
-	    //$last_exec['planeupdatefaa'] = time();
1024
-	    $last_exec[$id]['last'] = time();
1023
+		//$last_exec['planeupdatefaa'] = time();
1024
+		$last_exec[$id]['last'] = time();
1025 1025
 	} elseif ($value['format'] === 'aircraftjson' && 
1026
-	    (
1026
+		(
1027 1027
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1028 1028
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1029
-	    )
1029
+		)
1030 1030
 	) {
1031
-	    $buffer = $Common->getData($value['host']);
1032
-	    $all_data = json_decode($buffer,true);
1033
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1031
+		$buffer = $Common->getData($value['host']);
1032
+		$all_data = json_decode($buffer,true);
1033
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1034 1034
 		$reset = 0;
1035 1035
 		foreach ($all_data['aircraft'] as $key => $line) {
1036
-		    $data = array();
1037
-		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
-		    //$data['emergency'] = ''; // emergency
1048
-		    //$data['registration'] = $line[2];
1049
-		    //$data['aircraft_icao'] = $line[0];
1050
-		    $data['datetime'] = date('Y-m-d H:i:s');
1051
-		    $data['format_source'] = 'aircraftjson';
1052
-		    $data['id_source'] = $id_source;
1053
-		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    $SI->add($data);
1059
-		    unset($data);
1036
+			$data = array();
1037
+			// add support for ground vehicule with ~ in front of hex
1038
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
+			//$data['emergency'] = ''; // emergency
1048
+			//$data['registration'] = $line[2];
1049
+			//$data['aircraft_icao'] = $line[0];
1050
+			$data['datetime'] = date('Y-m-d H:i:s');
1051
+			$data['format_source'] = 'aircraftjson';
1052
+			$data['id_source'] = $id_source;
1053
+			if (isset($value['name']) && $value['name'] != '') {
1054
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
+				else $data['source_name'] = $value['name'];
1056
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
+			$SI->add($data);
1059
+			unset($data);
1060 1060
 		}
1061
-	    }
1062
-	    //$last_exec['planeupdatefaa'] = time();
1063
-	    $last_exec[$id]['last'] = time();
1061
+		}
1062
+		//$last_exec['planeupdatefaa'] = time();
1063
+		$last_exec[$id]['last'] = time();
1064 1064
 	} elseif ($value['format'] === 'planefinderclient' && 
1065
-	    (
1065
+		(
1066 1066
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1067 1067
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1068
-	    )
1068
+		)
1069 1069
 	) {
1070
-	    $buffer = $Common->getData($value['host']);
1071
-	    $all_data = json_decode($buffer,true);
1072
-	    if (isset($all_data['aircraft'])) {
1070
+		$buffer = $Common->getData($value['host']);
1071
+		$all_data = json_decode($buffer,true);
1072
+		if (isset($all_data['aircraft'])) {
1073 1073
 		$reset = 0;
1074 1074
 		foreach ($all_data['aircraft'] as $key => $line) {
1075
-		    $data = array();
1076
-		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
-		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
-		    $data['format_source'] = 'planefinderclient';
1090
-		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
-		    $SI->add($data);
1094
-		    unset($data);
1075
+			$data = array();
1076
+			$data['hex'] = $key; // hex
1077
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
+			//$data['emergency'] = ''; // emergency
1086
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
+			$data['format_source'] = 'planefinderclient';
1090
+			$data['id_source'] = $id_source;
1091
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
+			$SI->add($data);
1094
+			unset($data);
1095 1095
 		}
1096
-	    }
1097
-	    $last_exec[$id]['last'] = time();
1096
+		}
1097
+		$last_exec[$id]['last'] = time();
1098 1098
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1099 1099
 	} elseif ($value['format'] === 'fr24json' && 
1100
-	    (
1100
+		(
1101 1101
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1102 1102
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1103
-	    )
1103
+		)
1104 1104
 	) {
1105
-	    //$buffer = $Common->getData($hosts[$id]);
1106
-	    $buffer = $Common->getData($value['host']);
1107
-	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1109
-	    foreach ($all_data as $key => $line) {
1105
+		//$buffer = $Common->getData($hosts[$id]);
1106
+		$buffer = $Common->getData($value['host']);
1107
+		$all_data = json_decode($buffer,true);
1108
+		if (!empty($all_data)) $reset = 0;
1109
+		foreach ($all_data as $key => $line) {
1110 1110
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111
-		    $data = array();
1112
-		    $data['hex'] = $line[0];
1113
-		    $data['ident'] = $line[16]; //$line[13]
1114
-	    	    $data['altitude'] = $line[4]; // altitude
1115
-	    	    $data['speed'] = $line[5]; // speed
1116
-	    	    $data['heading'] = $line[3]; // heading
1117
-	    	    $data['latitude'] = $line[1]; // lat
1118
-	    	    $data['longitude'] = $line[2]; // long
1119
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1120
-	    	    $data['squawk'] = $line[6]; // squawk
1121
-	    	    $data['aircraft_icao'] = $line[8];
1122
-	    	    $data['registration'] = $line[9];
1123
-		    $data['departure_airport_iata'] = $line[11];
1124
-		    $data['arrival_airport_iata'] = $line[12];
1125
-	    	    $data['emergency'] = ''; // emergency
1126
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
-	    	    $data['format_source'] = 'fr24json';
1128
-    		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
-		    $SI->add($data);
1132
-		    unset($data);
1111
+			$data = array();
1112
+			$data['hex'] = $line[0];
1113
+			$data['ident'] = $line[16]; //$line[13]
1114
+				$data['altitude'] = $line[4]; // altitude
1115
+				$data['speed'] = $line[5]; // speed
1116
+				$data['heading'] = $line[3]; // heading
1117
+				$data['latitude'] = $line[1]; // lat
1118
+				$data['longitude'] = $line[2]; // long
1119
+				$data['verticalrate'] = $line[15]; // verticale rate
1120
+				$data['squawk'] = $line[6]; // squawk
1121
+				$data['aircraft_icao'] = $line[8];
1122
+				$data['registration'] = $line[9];
1123
+			$data['departure_airport_iata'] = $line[11];
1124
+			$data['arrival_airport_iata'] = $line[12];
1125
+				$data['emergency'] = ''; // emergency
1126
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
+				$data['format_source'] = 'fr24json';
1128
+				$data['id_source'] = $id_source;
1129
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
+			$SI->add($data);
1132
+			unset($data);
1133
+		}
1133 1134
 		}
1134
-	    }
1135
-	    //$last_exec['fr24json'] = time();
1136
-	    $last_exec[$id]['last'] = time();
1135
+		//$last_exec['fr24json'] = time();
1136
+		$last_exec[$id]['last'] = time();
1137 1137
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1138 1138
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1139
-	    (
1139
+		(
1140 1140
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1141 1141
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1142
-	    )
1142
+		)
1143 1143
 	) {
1144
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1146
-	    //echo $buffer;
1147
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1148
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
-	    $all_data = json_decode($buffer,true);
1150
-	    if (json_last_error() != JSON_ERROR_NONE) {
1144
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1146
+		//echo $buffer;
1147
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1148
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
+		$all_data = json_decode($buffer,true);
1150
+		if (json_last_error() != JSON_ERROR_NONE) {
1151 1151
 		die(json_last_error_msg());
1152
-	    }
1153
-	    if (isset($all_data['mrkrs'])) {
1152
+		}
1153
+		if (isset($all_data['mrkrs'])) {
1154 1154
 		$reset = 0;
1155 1155
 		foreach ($all_data['mrkrs'] as $key => $line) {
1156
-		    if (isset($line['inf'])) {
1156
+			if (isset($line['inf'])) {
1157 1157
 			$data = array();
1158 1158
 			$data['hex'] = $line['inf']['ia'];
1159 1159
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1160
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
-	    		$data['latitude'] = $line['pt'][0]; // lat
1164
-	    		$data['longitude'] = $line['pt'][1]; // long
1165
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
-	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1160
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
+				$data['latitude'] = $line['pt'][0]; // lat
1164
+				$data['longitude'] = $line['pt'][1]; // long
1165
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
+				//$data['aircraft_icao'] = $line[8];
1168
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1169 1169
 			//$data['departure_airport_iata'] = $line[11];
1170 1170
 			//$data['arrival_airport_iata'] = $line[12];
1171
-	    		//$data['emergency'] = ''; // emergency
1171
+				//$data['emergency'] = ''; // emergency
1172 1172
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173
-	    		$data['format_source'] = 'radarvirtueljson';
1174
-    			$data['id_source'] = $id_source;
1173
+				$data['format_source'] = 'radarvirtueljson';
1174
+				$data['id_source'] = $id_source;
1175 1175
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176 1176
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1177 1177
 			$SI->add($data);
1178 1178
 			unset($data);
1179
-		    }
1179
+			}
1180 1180
 		}
1181
-	    }
1182
-	    //$last_exec['radarvirtueljson'] = time();
1183
-	    $last_exec[$id]['last'] = time();
1181
+		}
1182
+		//$last_exec['radarvirtueljson'] = time();
1183
+		$last_exec[$id]['last'] = time();
1184 1184
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1185 1185
 	} elseif ($value['format'] === 'pirepsjson' && 
1186
-	    (
1186
+		(
1187 1187
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1188 1188
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1189
-	    )
1189
+		)
1190 1190
 	) {
1191
-	    //$buffer = $Common->getData($hosts[$id]);
1192
-	    $buffer = $Common->getData($value['host'].'?'.time());
1193
-	    $all_data = json_decode(utf8_encode($buffer),true);
1191
+		//$buffer = $Common->getData($hosts[$id]);
1192
+		$buffer = $Common->getData($value['host'].'?'.time());
1193
+		$all_data = json_decode(utf8_encode($buffer),true);
1194 1194
 	    
1195
-	    if (isset($all_data['pireps'])) {
1195
+		if (isset($all_data['pireps'])) {
1196 1196
 		$reset = 0;
1197
-	        foreach ($all_data['pireps'] as $line) {
1198
-		    $data = array();
1199
-		    $data['id'] = $line['id'];
1200
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
-		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
-		    $data['latitude'] = $line['lat']; // lat
1209
-		    $data['longitude'] = $line['lon']; // long
1210
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211
-		    //$data['squawk'] = $line['squawk']; // squawk
1212
-		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1221
-		    $data['format_source'] = 'pireps';
1222
-    		    $data['id_source'] = $id_source;
1223
-		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
-		    if ($line['icon'] === 'plane') {
1197
+			foreach ($all_data['pireps'] as $line) {
1198
+			$data = array();
1199
+			$data['id'] = $line['id'];
1200
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
+			$data['ident'] = $line['callsign']; // ident
1202
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
+			$data['latitude'] = $line['lat']; // lat
1209
+			$data['longitude'] = $line['lon']; // long
1210
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1211
+			//$data['squawk'] = $line['squawk']; // squawk
1212
+			//$data['emergency'] = ''; // emergency
1213
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
+			//$data['arrival_airport_time'] = $line['arrtime'];
1217
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
+			else $data['info'] = '';
1221
+			$data['format_source'] = 'pireps';
1222
+				$data['id_source'] = $id_source;
1223
+			$data['datetime'] = date('Y-m-d H:i:s');
1224
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
+			if ($line['icon'] === 'plane') {
1227 1227
 			$SI->add($data);
1228
-		    //    print_r($data);
1229
-    		    } elseif ($line['icon'] === 'ct') {
1228
+			//    print_r($data);
1229
+				} elseif ($line['icon'] === 'ct') {
1230 1230
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1231 1231
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1232
 			$typec = substr($data['ident'],-3);
@@ -1241,209 +1241,209 @@  discard block
 block discarded – undo
1241 1241
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242 1242
 			else $data['type'] = 'Observer';
1243 1243
 			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']);
1244
-		    }
1245
-		    unset($data);
1244
+			}
1245
+			unset($data);
1246 1246
 		}
1247
-	    }
1248
-	    //$last_exec['pirepsjson'] = time();
1249
-	    $last_exec[$id]['last'] = time();
1247
+		}
1248
+		//$last_exec['pirepsjson'] = time();
1249
+		$last_exec[$id]['last'] = time();
1250 1250
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1251 1251
 	} elseif ($value['format'] === 'phpvmacars' && 
1252
-	    (
1252
+		(
1253 1253
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1254 1254
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1255
-	    )
1255
+		)
1256 1256
 	) {
1257
-	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1259
-	    $buffer = $Common->getData($value['host']);
1260
-	    $all_data = json_decode($buffer,true);
1261
-	    if ($buffer != '' && is_array($all_data)) {
1257
+		//$buffer = $Common->getData($hosts[$id]);
1258
+		if ($globalDebug) echo 'Get Data...'."\n";
1259
+		$buffer = $Common->getData($value['host']);
1260
+		$all_data = json_decode($buffer,true);
1261
+		if ($buffer != '' && is_array($all_data)) {
1262 1262
 		$reset = 0;
1263 1263
 		foreach ($all_data as $line) {
1264
-	    	    $data = array();
1265
-	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
-	    	    $data['ident'] = $line['flightnum']; // ident
1271
-	    	    $data['altitude'] = $line['alt']; // altitude
1272
-	    	    $data['speed'] = $line['gs']; // speed
1273
-	    	    $data['heading'] = $line['heading']; // heading
1274
-	    	    $data['latitude'] = $line['lat']; // lat
1275
-	    	    $data['longitude'] = $line['lng']; // long
1276
-	    	    $data['verticalrate'] = ''; // verticale rate
1277
-	    	    $data['squawk'] = ''; // squawk
1278
-	    	    $data['emergency'] = ''; // emergency
1279
-	    	    //$data['datetime'] = $line['lastupdate'];
1280
-	    	    //$data['last_update'] = $line['lastupdate'];
1281
-	    	    if (isset($value['timezone'])) {
1282
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1286
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1287
-	    	    $data['departure_airport_time'] = $line['deptime'];
1288
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1289
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1290
-    		    if (isset($line['registration'])) {
1291
-    			$data['registration'] = $line['registration'];
1292
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
-		    if (isset($line['aircraftname'])) {
1264
+				$data = array();
1265
+				//$data['id'] = $line['id']; // id not usable
1266
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
+				$data['ident'] = $line['flightnum']; // ident
1271
+				$data['altitude'] = $line['alt']; // altitude
1272
+				$data['speed'] = $line['gs']; // speed
1273
+				$data['heading'] = $line['heading']; // heading
1274
+				$data['latitude'] = $line['lat']; // lat
1275
+				$data['longitude'] = $line['lng']; // long
1276
+				$data['verticalrate'] = ''; // verticale rate
1277
+				$data['squawk'] = ''; // squawk
1278
+				$data['emergency'] = ''; // emergency
1279
+				//$data['datetime'] = $line['lastupdate'];
1280
+				//$data['last_update'] = $line['lastupdate'];
1281
+				if (isset($value['timezone'])) {
1282
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1286
+				$data['departure_airport_icao'] = $line['depicao'];
1287
+				$data['departure_airport_time'] = $line['deptime'];
1288
+				$data['arrival_airport_icao'] = $line['arricao'];
1289
+				$data['arrival_airport_time'] = $line['arrtime'];
1290
+				if (isset($line['registration'])) {
1291
+				$data['registration'] = $line['registration'];
1292
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
+				} else $data['registration'] = $line['aircraft'];
1294
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
+			if (isset($line['aircraftname'])) {
1297 1297
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1298
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1303
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
-	    		}
1307
-	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
-    		    $data['id_source'] = $id_source;
1310
-	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
-		    $SI->add($data);
1313
-		    unset($data);
1299
+				$aircraft_data = explode('-',$line['aircraftname']);
1300
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
+				else {
1303
+					$aircraft_data = explode(' ',$line['aircraftname']);
1304
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
+				}
1307
+				}
1308
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
+				$data['id_source'] = $id_source;
1310
+				$data['format_source'] = 'phpvmacars';
1311
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
+			$SI->add($data);
1313
+			unset($data);
1314 1314
 		}
1315 1315
 		if ($globalDebug) echo 'No more data...'."\n";
1316 1316
 		unset($buffer);
1317 1317
 		unset($all_data);
1318
-	    }
1319
-	    //$last_exec['phpvmacars'] = time();
1320
-	    $last_exec[$id]['last'] = time();
1318
+		}
1319
+		//$last_exec['phpvmacars'] = time();
1320
+		$last_exec[$id]['last'] = time();
1321 1321
 	} elseif ($value['format'] === 'vaos' && 
1322
-	    (
1322
+		(
1323 1323
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1324 1324
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1325
-	    )
1325
+		)
1326 1326
 	) {
1327
-	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1329
-	    $buffer = $Common->getData($value['host']);
1330
-	    $all_data = json_decode($buffer,true);
1331
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1327
+		//$buffer = $Common->getData($hosts[$id]);
1328
+		if ($globalDebug) echo 'Get Data...'."\n";
1329
+		$buffer = $Common->getData($value['host']);
1330
+		$all_data = json_decode($buffer,true);
1331
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1332 1332
 		$reset = 0;
1333 1333
 		foreach ($all_data['ACARSData'] as $line) {
1334
-		    //print_r($line);
1335
-	    	    $data = array();
1336
-	    	    //$data['id'] = $line['id']; // id not usable
1337
-	    	    $data['id'] = $line['id'];
1338
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
-	    	    $data['altitude'] = $line['altitude']; // altitude
1344
-	    	    $data['speed'] = $line['groundspeed']; // speed
1345
-	    	    $data['heading'] = $line['heading']; // heading
1346
-	    	    $data['latitude'] = $line['lat']; // lat
1347
-	    	    $data['longitude'] = $line['lon']; // long
1348
-	    	    //$data['verticalrate'] = ''; // verticale rate
1349
-	    	    //$data['squawk'] = ''; // squawk
1350
-	    	    //$data['emergency'] = ''; // emergency
1351
-	    	    if (isset($value['timezone'])) {
1352
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1334
+			//print_r($line);
1335
+				$data = array();
1336
+				//$data['id'] = $line['id']; // id not usable
1337
+				$data['id'] = $line['id'];
1338
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
+				$data['altitude'] = $line['altitude']; // altitude
1344
+				$data['speed'] = $line['groundspeed']; // speed
1345
+				$data['heading'] = $line['heading']; // heading
1346
+				$data['latitude'] = $line['lat']; // lat
1347
+				$data['longitude'] = $line['lon']; // long
1348
+				//$data['verticalrate'] = ''; // verticale rate
1349
+				//$data['squawk'] = ''; // squawk
1350
+				//$data['emergency'] = ''; // emergency
1351
+				if (isset($value['timezone'])) {
1352
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1356 1356
 	    	    
1357
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1359
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1357
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1359
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1362 1362
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1363
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1366
 
1367
-    		    $data['id_source'] = $id_source;
1368
-	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
-		    $SI->add($data);
1371
-		    unset($data);
1367
+				$data['id_source'] = $id_source;
1368
+				$data['format_source'] = 'vaos';
1369
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
+			$SI->add($data);
1371
+			unset($data);
1372 1372
 		}
1373 1373
 		if ($globalDebug) echo 'No more data...'."\n";
1374 1374
 		unset($buffer);
1375 1375
 		unset($all_data);
1376
-	    }
1377
-	    //$last_exec['phpvmacars'] = time();
1378
-	    $last_exec[$id]['last'] = time();
1376
+		}
1377
+		//$last_exec['phpvmacars'] = time();
1378
+		$last_exec[$id]['last'] = time();
1379 1379
 	} elseif ($value['format'] === 'vam' && 
1380
-	    (
1380
+		(
1381 1381
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1382 1382
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1383
-	    )
1383
+		)
1384 1384
 	) {
1385
-	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1387
-	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1389
-	    if ($buffer != '' && is_array($all_data)) {
1385
+		//$buffer = $Common->getData($hosts[$id]);
1386
+		if ($globalDebug) echo 'Get Data...'."\n";
1387
+		$buffer = $Common->getData($value['host']);
1388
+		$all_data = json_decode($buffer,true);
1389
+		if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392
-	    	    $data = array();
1393
-	    	    //$data['id'] = $line['id']; // id not usable
1394
-	    	    $data['id'] = trim($line['flight_id']);
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
-	    	    $data['pilot_name'] = $line['pilot_name'];
1397
-	    	    $data['pilot_id'] = $line['pilot_id'];
1398
-	    	    $data['ident'] = trim($line['callsign']); // ident
1399
-	    	    $data['altitude'] = $line['altitude']; // altitude
1400
-	    	    $data['speed'] = $line['gs']; // speed
1401
-	    	    $data['heading'] = $line['heading']; // heading
1402
-	    	    $data['latitude'] = $line['latitude']; // lat
1403
-	    	    $data['longitude'] = $line['longitude']; // long
1404
-	    	    $data['verticalrate'] = ''; // verticale rate
1405
-	    	    $data['squawk'] = ''; // squawk
1406
-	    	    $data['emergency'] = ''; // emergency
1407
-	    	    //$data['datetime'] = $line['lastupdate'];
1408
-	    	    $data['last_update'] = $line['last_update'];
1409
-		    $data['datetime'] = date('Y-m-d H:i:s');
1410
-	    	    $data['departure_airport_icao'] = $line['departure'];
1411
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1412
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414
-    		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1417
-    		    $data['id_source'] = $id_source;
1418
-	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
-		    $SI->add($data);
1422
-		    unset($data);
1392
+				$data = array();
1393
+				//$data['id'] = $line['id']; // id not usable
1394
+				$data['id'] = trim($line['flight_id']);
1395
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
+				$data['pilot_name'] = $line['pilot_name'];
1397
+				$data['pilot_id'] = $line['pilot_id'];
1398
+				$data['ident'] = trim($line['callsign']); // ident
1399
+				$data['altitude'] = $line['altitude']; // altitude
1400
+				$data['speed'] = $line['gs']; // speed
1401
+				$data['heading'] = $line['heading']; // heading
1402
+				$data['latitude'] = $line['latitude']; // lat
1403
+				$data['longitude'] = $line['longitude']; // long
1404
+				$data['verticalrate'] = ''; // verticale rate
1405
+				$data['squawk'] = ''; // squawk
1406
+				$data['emergency'] = ''; // emergency
1407
+				//$data['datetime'] = $line['lastupdate'];
1408
+				$data['last_update'] = $line['last_update'];
1409
+			$data['datetime'] = date('Y-m-d H:i:s');
1410
+				$data['departure_airport_icao'] = $line['departure'];
1411
+				//$data['departure_airport_time'] = $line['departure_time'];
1412
+				$data['arrival_airport_icao'] = $line['arrival'];
1413
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1414
+				//$data['registration'] = $line['aircraft'];
1415
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
+				$data['aircraft_icao'] = $line['plane_type'];
1417
+				$data['id_source'] = $id_source;
1418
+				$data['format_source'] = 'vam';
1419
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
+			$SI->add($data);
1422
+			unset($data);
1423 1423
 		}
1424 1424
 		if ($globalDebug) echo 'No more data...'."\n";
1425 1425
 		unset($buffer);
1426 1426
 		unset($all_data);
1427
-	    }
1428
-	    //$last_exec['phpvmacars'] = time();
1429
-	    $last_exec[$id]['last'] = time();
1427
+		}
1428
+		//$last_exec['phpvmacars'] = time();
1429
+		$last_exec[$id]['last'] = time();
1430 1430
 	} elseif ($value['format'] === 'blitzortung' && 
1431
-	    (
1431
+		(
1432 1432
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1433 1433
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1434
-	    )
1434
+		)
1435 1435
 	) {
1436
-	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1438
-	    $buffer = $Common->getData($value['host']);
1439
-	    $all_data = json_decode($buffer,true);
1440
-	    if ($buffer != '') {
1436
+		//$buffer = $Common->getData($hosts[$id]);
1437
+		if ($globalDebug) echo 'Get Data...'."\n";
1438
+		$buffer = $Common->getData($value['host']);
1439
+		$all_data = json_decode($buffer,true);
1440
+		if ($buffer != '') {
1441 1441
 		$Source->deleteLocationBySource('blitzortung');
1442 1442
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1443 1443
 		$buffer = explode('\n',$buffer);
1444 1444
 		foreach ($buffer as $buffer_line) {
1445
-		    $line = json_decode($buffer_line,true);
1446
-		    if (isset($line['time'])) {
1445
+			$line = json_decode($buffer_line,true);
1446
+			if (isset($line['time'])) {
1447 1447
 			$data = array();
1448 1448
 			$data['altitude'] = $line['alt']; // altitude
1449 1449
 			$data['latitude'] = $line['lat']; // lat
@@ -1455,94 +1455,94 @@  discard block
 block discarded – undo
1455 1455
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1456 1456
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 1457
 			unset($data);
1458
-		    }
1458
+			}
1459 1459
 		}
1460 1460
 		if ($globalDebug) echo 'No more data...'."\n";
1461 1461
 		unset($buffer);
1462
-	    }
1463
-	    $last_exec[$id]['last'] = time();
1462
+		}
1463
+		$last_exec[$id]['last'] = time();
1464 1464
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1465 1465
 	} 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') {
1466
-	    //$last_exec[$id]['last'] = time();
1467
-	    //$read = array( $sockets[$id] );
1468
-	    $read = $sockets;
1469
-	    $write = NULL;
1470
-	    $e = NULL;
1471
-	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
1473
-	    if ($n > 0) {
1466
+		//$last_exec[$id]['last'] = time();
1467
+		//$read = array( $sockets[$id] );
1468
+		$read = $sockets;
1469
+		$write = NULL;
1470
+		$e = NULL;
1471
+		$n = socket_select($read, $write, $e, $timeout);
1472
+		if ($e != NULL) var_dump($e);
1473
+		if ($n > 0) {
1474 1474
 		$reset = 0;
1475 1475
 		foreach ($read as $nb => $r) {
1476
-		    //$value = $formats[$nb];
1477
-		    $format = $globalSources[$nb]['format'];
1478
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1476
+			//$value = $formats[$nb];
1477
+			$format = $globalSources[$nb]['format'];
1478
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1479 1479
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1480
-		    } elseif ($format === 'vrstcp') {
1480
+			} elseif ($format === 'vrstcp') {
1481 1481
 			$buffer = @socket_read($r, 6000);
1482
-		    } else {
1482
+			} else {
1483 1483
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1484
-		    }
1485
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
-		    //echo $buffer."\n";
1487
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1488
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
-		    $error = false;
1490
-		    //$SI::del();
1491
-		    if ($buffer !== FALSE) {
1484
+			}
1485
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
+			//echo $buffer."\n";
1487
+			// lets play nice and handle signals such as ctrl-c/kill properly
1488
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
+			$error = false;
1490
+			//$SI::del();
1491
+			if ($buffer !== FALSE) {
1492 1492
 			if ($format === 'vrstcp') {
1493
-			    $buffer = explode('},{',$buffer);
1493
+				$buffer = explode('},{',$buffer);
1494 1494
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1495
-		    }
1496
-		    // SBS format is CSV format
1497
-		    if ($buffer !== FALSE && $buffer !== '') {
1495
+			}
1496
+			// SBS format is CSV format
1497
+			if ($buffer !== FALSE && $buffer !== '') {
1498 1498
 			$tt[$format] = 0;
1499 1499
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
-			    $ACARS->add(trim($buffer));
1502
-			    $ACARS->deleteLiveAcarsData();
1500
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
+				$ACARS->add(trim($buffer));
1502
+				$ACARS->deleteLiveAcarsData();
1503 1503
 			} elseif ($format === 'raw') {
1504
-			    // AVR format
1505
-			    $data = $SBS->parse($buffer);
1506
-			    if (is_array($data)) {
1504
+				// AVR format
1505
+				$data = $SBS->parse($buffer);
1506
+				if (is_array($data)) {
1507 1507
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 1508
 				$data['format_source'] = 'raw';
1509 1509
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510 1510
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511 1511
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512 1512
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1513
-			    }
1513
+				}
1514 1514
 			} elseif ($format === 'ais') {
1515
-			    $ais_data = $AIS->parse_line(trim($buffer));
1516
-			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1515
+				$ais_data = $AIS->parse_line(trim($buffer));
1516
+				$data = array();
1517
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1533 1533
 
1534
-			    if (isset($ais_data['timestamp'])) {
1534
+				if (isset($ais_data['timestamp'])) {
1535 1535
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1536
-			    } else {
1536
+				} else {
1537 1537
 				$data['datetime'] = date('Y-m-d H:i:s');
1538
-			    }
1539
-			    $data['format_source'] = 'aisnmea';
1540
-    			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
-			    unset($data);
1543
-                        } elseif ($format === 'flightgearsp') {
1544
-                    	    //echo $buffer."\n";
1545
-                    	    if (strlen($buffer) > 5) {
1538
+				}
1539
+				$data['format_source'] = 'aisnmea';
1540
+					$data['id_source'] = $id_source;
1541
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
+				unset($data);
1543
+						} elseif ($format === 'flightgearsp') {
1544
+							//echo $buffer."\n";
1545
+							if (strlen($buffer) > 5) {
1546 1546
 				$line = explode(',',$buffer);
1547 1547
 				$data = array();
1548 1548
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1559,38 +1559,38 @@  discard block
 block discarded – undo
1559 1559
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560 1560
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1561 1561
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562
-			    }
1563
-                        } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
-			    $ACARS->add(trim($buffer));
1566
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
-			    $ACARS->deleteLiveAcarsData();
1562
+				}
1563
+						} elseif ($format === 'acars') {
1564
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
+				$ACARS->add(trim($buffer));
1566
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
+				$ACARS->deleteLiveAcarsData();
1568 1568
 			} elseif ($format === 'flightgearmp') {
1569
-			    if (substr($buffer,0,1) != '#') {
1569
+				if (substr($buffer,0,1) != '#') {
1570 1570
 				$data = array();
1571 1571
 				//echo $buffer."\n";
1572 1572
 				$line = explode(' ',$buffer);
1573 1573
 				if (count($line) === 11) {
1574
-				    $userserver = explode('@',$line[0]);
1575
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
-				    $data['ident'] = $userserver[0];
1577
-				    $data['registration'] = $userserver[0];
1578
-				    $data['latitude'] = $line[4];
1579
-				    $data['longitude'] = $line[5];
1580
-				    $data['altitude'] = $line[6];
1581
-				    $data['datetime'] = date('Y-m-d H:i:s');
1582
-				    $aircraft_type = $line[10];
1583
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1574
+					$userserver = explode('@',$line[0]);
1575
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
+					$data['ident'] = $userserver[0];
1577
+					$data['registration'] = $userserver[0];
1578
+					$data['latitude'] = $line[4];
1579
+					$data['longitude'] = $line[5];
1580
+					$data['altitude'] = $line[6];
1581
+					$data['datetime'] = date('Y-m-d H:i:s');
1582
+					$aircraft_type = $line[10];
1583
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1584
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1587
+				}
1587 1588
 				}
1588
-			    }
1589 1589
 			} elseif ($format === 'beast') {
1590
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
-			    die;
1590
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
+				die;
1592 1592
 			} elseif ($format === 'vrstcp') {
1593
-			    foreach($buffer as $all_data) {
1593
+				foreach($buffer as $all_data) {
1594 1594
 				$line = json_decode('{'.$all_data.'}',true);
1595 1595
 				$data = array();
1596 1596
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1610,153 +1610,153 @@  discard block
 block discarded – undo
1610 1610
 				*/
1611 1611
 				$data['datetime'] = date('Y-m-d H:i:s');
1612 1612
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1613
-		    		$data['format_source'] = 'vrstcp';
1613
+					$data['format_source'] = 'vrstcp';
1614 1614
 				$data['id_source'] = $id_source;
1615 1615
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616 1616
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617 1617
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1618 1618
 				unset($data);
1619
-			    }
1619
+				}
1620 1620
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1621
-			    $line = explode("\t", $buffer);
1622
-			    for($k = 0; $k < count($line); $k=$k+2) {
1621
+				$line = explode("\t", $buffer);
1622
+				for($k = 0; $k < count($line); $k=$k+2) {
1623 1623
 				$key = $line[$k];
1624
-			        $lined[$key] = $line[$k+1];
1625
-			    }
1626
-    			    if (count($lined) > 3) {
1627
-    				$data['hex'] = $lined['hexid'];
1628
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
-    				$data['id_source'] = $id_source;
1638
-    				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+					$lined[$key] = $line[$k+1];
1625
+				}
1626
+					if (count($lined) > 3) {
1627
+					$data['hex'] = $lined['hexid'];
1628
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
+					$data['datetime'] = date('Y-m-d H:i:s');;
1630
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
+					$data['id_source'] = $id_source;
1638
+					$data['format_source'] = 'tsv';
1639
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641 1641
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
-    				unset($lined);
1644
-    				unset($data);
1645
-    			    } else $error = true;
1642
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
+					unset($lined);
1644
+					unset($data);
1645
+					} else $error = true;
1646 1646
 			} elseif ($format === 'aprs' && $use_aprs) {
1647
-			    if ($aprs_connect === 0) {
1647
+				if ($aprs_connect === 0) {
1648 1648
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1649 1649
 				$aprs_connect = 1;
1650
-			    }
1650
+				}
1651 1651
 			    
1652
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1652
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1653 1653
 				$aprs_last_tx = time();
1654 1654
 				$data_aprs = "# Keep alive";
1655 1655
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1656
-			    }
1656
+				}
1657 1657
 			    
1658
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
-			    //echo 'APRS data : '.$buffer."\n";
1660
-			    $buffer = str_replace('APRS <- ','',$buffer);
1661
-			    $buffer = str_replace('APRS -> ','',$buffer);
1662
-			    //echo $buffer."\n";
1663
-			    date_default_timezone_set('UTC');
1664
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1658
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
+				//echo 'APRS data : '.$buffer."\n";
1660
+				$buffer = str_replace('APRS <- ','',$buffer);
1661
+				$buffer = str_replace('APRS -> ','',$buffer);
1662
+				//echo $buffer."\n";
1663
+				date_default_timezone_set('UTC');
1664
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1665 1665
 				$line = $APRS->parse($buffer);
1666 1666
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1667 1667
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1668
-				    $aprs_last_tx = time();
1669
-				    $data = array();
1670
-				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1681
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
-				    $data['latitude'] = $line['latitude'];
1684
-				    $data['longitude'] = $line['longitude'];
1685
-				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
-				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1668
+					$aprs_last_tx = time();
1669
+					$data = array();
1670
+					//print_r($line);
1671
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1672
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
+					else $data['datetime'] = date('Y-m-d H:i:s');
1681
+					//$data['datetime'] = date('Y-m-d H:i:s');
1682
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
+					$data['latitude'] = $line['latitude'];
1684
+					$data['longitude'] = $line['longitude'];
1685
+					//$data['verticalrate'] = $line[16];
1686
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
+					//else $data['speed'] = 0;
1688
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 1692
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
-				    //else echo 'No heading...'."\n";
1695
-				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
-    				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
1705
-				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
-				    $currentdate = date('Y-m-d H:i:s');
1710
-				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
-				    // Accept data if time <= system time + 20s
1713
-				    //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'])))) {
1714
-				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1693
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
+					//else echo 'No heading...'."\n";
1695
+					//else $data['heading'] = 0;
1696
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
+						$data['id_source'] = $id_source;
1703
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
+					else $data['format_source'] = 'aprs';
1705
+					$data['source_name'] = $line['source'];
1706
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
+					else $data['source_type'] = 'flarm';
1708
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
+					$currentdate = date('Y-m-d H:i:s');
1710
+					$aprsdate = strtotime($data['datetime']);
1711
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
+					// Accept data if time <= system time + 20s
1713
+					//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'])))) {
1714
+					if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 1715
 					$send = $SI->add($data);
1716
-				    } elseif ($data['source_type'] === 'ais') {
1716
+					} elseif ($data['source_type'] === 'ais') {
1717 1717
 					$data['type'] = '';
1718 1718
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1719
-				    } elseif (isset($line['stealth'])) {
1719
+					} elseif (isset($line['stealth'])) {
1720 1720
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721 1721
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1722
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
-					    //$line['symbol'] === 'Balloon' ||
1724
-					    $line['symbol'] === 'Glider' || 
1725
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
-					    $send = $SI->add($data);
1729
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
-					    $line['symbol'] === 'Yacht (Sail)' || 
1731
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1732
-					    $send = $MI->add($data);
1733
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
-					    $line['symbol'] === 'Car' || 
1735
-					    $line['symbol'] === 'Ambulance' || 
1736
-					    $line['symbol'] === 'Van' || 
1737
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
-					    $line['symbol'] === 'Motorcycle' || 
1739
-					    $line['symbol'] === 'Tractor' || 
1740
-					    $line['symbol'] === 'Police' || 
1741
-					    $line['symbol'] === 'Bike' || 
1742
-					    $line['symbol'] === 'Jogger' || 
1743
-					    $line['symbol'] === 'Horse' || 
1744
-					    $line['symbol'] === 'Bus' || 
1745
-					    $line['symbol'] === 'Jeep' || 
1746
-					    $line['symbol'] === 'Recreational Vehicle' || 
1747
-					    $line['symbol'] === 'Yacht (Sail)' || 
1748
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1749
-					    $line['symbol'] === 'Firetruck' || 
1750
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
-					    $line['symbol'] === 'SUV' ||
1753
-					    $line['symbol'] === 'Snowmobile' ||
1754
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1755
-				    //} 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') {
1722
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
+						//$line['symbol'] === 'Balloon' ||
1724
+						$line['symbol'] === 'Glider' || 
1725
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
+						$send = $SI->add($data);
1729
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
+						$line['symbol'] === 'Yacht (Sail)' || 
1731
+						$line['symbol'] === 'Ship (Power Boat)')) {
1732
+						$send = $MI->add($data);
1733
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
+						$line['symbol'] === 'Car' || 
1735
+						$line['symbol'] === 'Ambulance' || 
1736
+						$line['symbol'] === 'Van' || 
1737
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
+						$line['symbol'] === 'Motorcycle' || 
1739
+						$line['symbol'] === 'Tractor' || 
1740
+						$line['symbol'] === 'Police' || 
1741
+						$line['symbol'] === 'Bike' || 
1742
+						$line['symbol'] === 'Jogger' || 
1743
+						$line['symbol'] === 'Horse' || 
1744
+						$line['symbol'] === 'Bus' || 
1745
+						$line['symbol'] === 'Jeep' || 
1746
+						$line['symbol'] === 'Recreational Vehicle' || 
1747
+						$line['symbol'] === 'Yacht (Sail)' || 
1748
+						$line['symbol'] === 'Ship (Power Boat)' || 
1749
+						$line['symbol'] === 'Firetruck' || 
1750
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
+						$line['symbol'] === 'SUV' ||
1753
+						$line['symbol'] === 'Snowmobile' ||
1754
+						$line['symbol'] === 'Mobile Satellite Station')) {
1755
+					//} 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') {
1756 1756
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') {
1757 1757
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758 1758
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1759
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1759
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760 1760
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1761 1761
 					$Source->deleteOldLocationByType('gs');
1762 1762
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 					} else {
1765 1765
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1766 1766
 					}
1767
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1767
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 1768
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769 1769
 					if ($globalDebug) echo '# Weather Station added'."\n";
1770 1770
 					$Source->deleteOldLocationByType('wx');
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 					} else {
1775 1775
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1776 1776
 					}
1777
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1777
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 1778
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779 1779
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1780 1780
 					$Source->deleteOldLocationByType('lightning');
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
 					} else {
1784 1784
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1785 1785
 					}
1786
-				    } elseif ($globalDebug) {
1787
-				    	echo '/!\ Not added: '.$buffer."\n";
1788
-				    	print_r($line);
1789
-				    }
1790
-				    unset($data);
1786
+					} elseif ($globalDebug) {
1787
+						echo '/!\ Not added: '.$buffer."\n";
1788
+						print_r($line);
1789
+					}
1790
+					unset($data);
1791 1791
 				}
1792 1792
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 1793
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1806,12 +1806,12 @@  discard block
 block discarded – undo
1806 1806
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1807 1807
 					$globalSources[$nb]['last_weather_clean'] = time();
1808 1808
 				}
1809
-			    }
1809
+				}
1810 1810
 			} else {
1811
-			    $line = explode(',', $buffer);
1812
-    			    if (count($line) > 20) {
1813
-    			    	$data['hex'] = $line[4];
1814
-    				/*
1811
+				$line = explode(',', $buffer);
1812
+					if (count($line) > 20) {
1813
+						$data['hex'] = $line[4];
1814
+					/*
1815 1815
     				$data['datetime'] = $line[6].' '.$line[7];
1816 1816
     					date_default_timezone_set($globalTimezone);
1817 1817
     					$datetime = new DateTime($data['datetime']);
@@ -1819,31 +1819,31 @@  discard block
 block discarded – undo
1819 1819
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1820 1820
     					date_default_timezone_set('UTC');
1821 1821
     				*/
1822
-    				// Force datetime to current UTC datetime
1823
-    				date_default_timezone_set('UTC');
1824
-    				$data['datetime'] = date('Y-m-d H:i:s');
1825
-    				$data['ident'] = trim($line[10]);
1826
-    				$data['latitude'] = $line[14];
1827
-    				$data['longitude'] = $line[15];
1828
-    				$data['verticalrate'] = $line[16];
1829
-    				$data['emergency'] = $line[20];
1830
-    				$data['speed'] = $line[12];
1831
-    				$data['squawk'] = $line[17];
1832
-    				$data['altitude'] = $line[11];
1833
-    				$data['heading'] = $line[13];
1834
-    				$data['ground'] = $line[21];
1835
-    				$data['emergency'] = $line[19];
1836
-    				$data['format_source'] = 'sbs';
1822
+					// Force datetime to current UTC datetime
1823
+					date_default_timezone_set('UTC');
1824
+					$data['datetime'] = date('Y-m-d H:i:s');
1825
+					$data['ident'] = trim($line[10]);
1826
+					$data['latitude'] = $line[14];
1827
+					$data['longitude'] = $line[15];
1828
+					$data['verticalrate'] = $line[16];
1829
+					$data['emergency'] = $line[20];
1830
+					$data['speed'] = $line[12];
1831
+					$data['squawk'] = $line[17];
1832
+					$data['altitude'] = $line[11];
1833
+					$data['heading'] = $line[13];
1834
+					$data['ground'] = $line[21];
1835
+					$data['emergency'] = $line[19];
1836
+					$data['format_source'] = 'sbs';
1837 1837
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838 1838
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1839
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1839
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1840 1840
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1841
-    				$data['id_source'] = $id_source;
1842
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1843
-    				else $error = true;
1844
-    				unset($data);
1845
-    			    } else $error = true;
1846
-			    if ($error) {
1841
+					$data['id_source'] = $id_source;
1842
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1843
+					else $error = true;
1844
+					unset($data);
1845
+					} else $error = true;
1846
+				if ($error) {
1847 1847
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1848 1848
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1849 1849
 				} else {
@@ -1859,13 +1859,13 @@  discard block
 block discarded – undo
1859 1859
 					connect_all($sourceer);
1860 1860
 					$sourceer = array();
1861 1861
 				}
1862
-			    }
1862
+				}
1863 1863
 			}
1864 1864
 			// Sleep for xxx microseconds
1865 1865
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1866
-		    } else {
1866
+			} else {
1867 1867
 			if ($format === 'flightgearmp') {
1868
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1868
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1869 1869
 				//@socket_close($r);
1870 1870
 				sleep($globalMinFetch);
1871 1871
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1874,9 +1874,9 @@  discard block
 block discarded – undo
1874 1874
 				break;
1875 1875
 				
1876 1876
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1877
-			    if (isset($tt[$format])) $tt[$format]++;
1878
-			    else $tt[$format] = 0;
1879
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1877
+				if (isset($tt[$format])) $tt[$format]++;
1878
+				else $tt[$format] = 0;
1879
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1880 1880
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1881 1881
 				//@socket_close($r);
1882 1882
 				sleep(2);
@@ -1887,24 +1887,24 @@  discard block
 block discarded – undo
1887 1887
 				//connect_all($globalSources);
1888 1888
 				$tt[$format]=0;
1889 1889
 				break;
1890
-			    } 
1891
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1890
+				} 
1891
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1892
+			}
1892 1893
 			}
1893
-		    }
1894 1894
 		}
1895
-	    } else {
1895
+		} else {
1896 1896
 		$error = socket_strerror(socket_last_error());
1897 1897
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1898 1898
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1899 1899
 			if (isset($globalDebug)) echo "Restarting...\n";
1900 1900
 			// Restart the script if possible
1901 1901
 			if (is_array($sockets)) {
1902
-			    if ($globalDebug) echo "Shutdown all sockets...";
1902
+				if ($globalDebug) echo "Shutdown all sockets...";
1903 1903
 			    
1904
-			    foreach ($sockets as $sock) {
1904
+				foreach ($sockets as $sock) {
1905 1905
 				@socket_shutdown($sock,2);
1906 1906
 				@socket_close($sock);
1907
-			    }
1907
+				}
1908 1908
 			    
1909 1909
 			}
1910 1910
 			if ($globalDebug) echo "Waiting...";
@@ -1919,15 +1919,15 @@  discard block
 block discarded – undo
1919 1919
 			if ($globalDebug) echo "Restart all connections...";
1920 1920
 			connect_all($globalSources);
1921 1921
 		}
1922
-	    }
1922
+		}
1923 1923
 	}
1924 1924
 	if ($globalDaemon === false) {
1925
-	    if ($globalDebug) echo 'Check all...'."\n";
1926
-	    if (isset($SI)) $SI->checkAll();
1927
-	    if (isset($TI)) $TI->checkAll();
1928
-	    if (isset($MI)) $MI->checkAll();
1925
+		if ($globalDebug) echo 'Check all...'."\n";
1926
+		if (isset($SI)) $SI->checkAll();
1927
+		if (isset($TI)) $TI->checkAll();
1928
+		if (isset($MI)) $MI->checkAll();
1929
+	}
1929 1930
 	}
1930
-    }
1931 1931
 }
1932 1932
 
1933 1933
 ?>
Please login to merge, or discard this patch.
Braces   +1192 added lines, -400 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,16 +342,24 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug) {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+    		}
274 363
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275 364
 	    $hostport = explode(':',$host);
276 365
 	    if (isset($hostport[1])) {
@@ -310,19 +399,27 @@  discard block
 block discarded – undo
310 399
         		//$formats[$id] = 'beast';
311 400
         		$globalSources[$id]['format'] = 'beast';
312 401
 		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
402
+		    } else {
403
+		    	$globalSources[$id]['format'] = 'sbs';
404
+		    }
314 405
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 406
 		}
316
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
407
+		if ($globalDebug) {
408
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		}
317 410
             } else {
318
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
411
+		if ($globalDebug) {
412
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		}
319 414
 		sleep(10);
320 415
 		connect_all($hosts);
321 416
     	    }
322 417
         }
323 418
     }
324 419
 }
325
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
420
+if (!isset($globalMinFetch)) {
421
+	$globalMinFetch = 15;
422
+}
326 423
 
327 424
 // Initialize all
328 425
 $status = array();
@@ -331,13 +428,19 @@  discard block
 block discarded – undo
331 428
 $formats = array();
332 429
 $last_exec = array();
333 430
 $time = time();
334
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
335
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
336
-else $timeout = 20;
431
+if (isset($globalSourcesTimeout)) {
432
+	$timeout = $globalSourcesTimeOut;
433
+} else if (isset($globalSBS1TimeOut)) {
434
+	$timeout = $globalSBS1TimeOut;
435
+} else {
436
+	$timeout = 20;
437
+}
337 438
 $errno = '';
338 439
 $errstr='';
339 440
 
340
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
441
+if (!isset($globalDaemon)) {
442
+	$globalDaemon = TRUE;
443
+}
341 444
 /* Initiate connections to all the hosts simultaneously */
342 445
 //connect_all($hosts);
343 446
 //connect_all($globalSources);
@@ -366,7 +469,9 @@  discard block
 block discarded – undo
366 469
     if (isset($source['format']) && $source['format'] == 'aprs') {
367 470
 	$aprs_connect = 0;
368 471
 	$use_aprs = true;
369
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
472
+	if (isset($source['port']) && $source['port'] == '10152') {
473
+		$aprs_full = true;
474
+	}
370 475
 	break;
371 476
     }
372 477
 }
@@ -377,25 +482,46 @@  discard block
 block discarded – undo
377 482
 	$aprs_connect = 0;
378 483
 	$aprs_keep = 120;
379 484
 	$aprs_last_tx = time();
380
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
381
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
382
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
383
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
384
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
385
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386
-	if ($aprs_full) $aprs_filter = '';
387
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
388
-	else $aprs_pass = '-1';
485
+	if (isset($globalAPRSversion)) {
486
+		$aprs_version = $globalAPRSversion;
487
+	} else {
488
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
489
+	}
490
+	if (isset($globalAPRSssid)) {
491
+		$aprs_ssid = $globalAPRSssid;
492
+	} else {
493
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
494
+	}
495
+	if (isset($globalAPRSfilter)) {
496
+		$aprs_filter = $globalAPRSfilter;
497
+	} else {
498
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
499
+	}
500
+	if ($aprs_full) {
501
+		$aprs_filter = '';
502
+	}
503
+	if (isset($globalAPRSpass)) {
504
+		$aprs_pass = $globalAPRSpass;
505
+	} else {
506
+		$aprs_pass = '-1';
507
+	}
389 508
 
390
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
391
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
392
-}
509
+	if ($aprs_filter != '') {
510
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
511
+	} else {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
513
+	}
514
+	}
393 515
 
394 516
 // connected - lets do some work
395 517
 //if ($globalDebug) echo "Connected!\n";
396 518
 sleep(1);
397
-if ($globalDebug) echo "SCAN MODE \n\n";
398
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
519
+if ($globalDebug) {
520
+	echo "SCAN MODE \n\n";
521
+}
522
+if (!isset($globalCronEnd)) {
523
+	$globalCronEnd = 60;
524
+}
399 525
 $endtime = time()+$globalCronEnd;
400 526
 $i = 1;
401 527
 $tt = array();
@@ -409,22 +535,32 @@  discard block
 block discarded – undo
409 535
 
410 536
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 537
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
538
+    if (function_exists('pcntl_fork')) {
539
+    	pcntl_signal_dispatch();
540
+    }
413 541
 
414
-    if (!$globalDaemon) $i = $endtime-time();
542
+    if (!$globalDaemon) {
543
+    	$i = $endtime-time();
544
+    }
415 545
     // Delete old ATC
416 546
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
547
+	if ($globalDebug) {
548
+		echo 'Delete old ATC...'."\n";
549
+	}
418 550
         $ATC->deleteOldATC();
419 551
     }
420 552
     
421 553
     if (count($last_exec) == count($globalSources)) {
422 554
 	$max = $globalMinFetch;
423 555
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
556
+	    if ((time() - $last['last']) < $max) {
557
+	    	$max = time() - $last['last'];
558
+	    }
425 559
 	}
426 560
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
561
+	    if ($globalDebug) {
562
+	    	echo 'Sleeping...'."\n";
563
+	    }
428 564
 	    sleep($globalMinFetch-$max+2);
429 565
 	}
430 566
     }
@@ -434,7 +570,9 @@  discard block
 block discarded – undo
434 570
     foreach ($globalSources as $id => $value) {
435 571
 	date_default_timezone_set('UTC');
436 572
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
573
+	if (!isset($last_exec[$id]['last'])) {
574
+		$last_exec[$id]['last'] = 0;
575
+	}
438 576
 	if ($value['format'] === 'deltadbtxt' && 
439 577
 	    (
440 578
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -443,7 +581,9 @@  discard block
 block discarded – undo
443 581
 	) {
444 582
 	    //$buffer = $Common->getData($hosts[$id]);
445 583
 	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
584
+	    if ($buffer != '') {
585
+	    	$reset = 0;
586
+	    }
447 587
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448 588
 	    $buffer = explode('\n',$buffer);
449 589
 	    foreach ($buffer as $line) {
@@ -452,20 +592,41 @@  discard block
 block discarded – undo
452 592
 	            $data = array();
453 593
 	            $data['hex'] = $line[1]; // hex
454 594
 	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
595
+	            if (isset($line[3])) {
596
+	            	$data['altitude'] = $line[3];
597
+	            }
598
+	            // altitude
599
+	            if (isset($line[4])) {
600
+	            	$data['speed'] = $line[4];
601
+	            }
602
+	            // speed
603
+	            if (isset($line[5])) {
604
+	            	$data['heading'] = $line[5];
605
+	            }
606
+	            // heading
607
+	            if (isset($line[6])) {
608
+	            	$data['latitude'] = $line[6];
609
+	            }
610
+	            // lat
611
+	            if (isset($line[7])) {
612
+	            	$data['longitude'] = $line[7];
613
+	            }
614
+	            // long
460 615
 	            $data['verticalrate'] = ''; // vertical rate
461 616
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462 617
 	            $data['emergency'] = ''; // emergency
463 618
 		    $data['datetime'] = date('Y-m-d H:i:s');
464 619
 		    $data['format_source'] = 'deltadbtxt';
465 620
     		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
621
+		    if (isset($value['name']) && $value['name'] != '') {
622
+		    	$data['source_name'] = $value['name'];
623
+		    }
624
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
625
+		    	$data['noarchive'] = true;
626
+		    }
627
+		    if (isset($value['sourcestats'])) {
628
+		    	$data['sourcestats'] = $value['sourcestats'];
629
+		    }
469 630
     		    $SI->add($data);
470 631
 		    unset($data);
471 632
     		}
@@ -480,7 +641,9 @@  discard block
 block discarded – undo
480 641
 	    date_default_timezone_set('CET');
481 642
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482 643
 	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
644
+	    if ($buffer != '') {
645
+	    	$reset = 0;
646
+	    }
484 647
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485 648
 	    $buffer = explode('\n',$buffer);
486 649
 	    foreach ($buffer as $line) {
@@ -489,18 +652,42 @@  discard block
 block discarded – undo
489 652
 		    $add = false;
490 653
 		    $ais_data = $AIS->parse_line(trim($line));
491 654
 		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
655
+		    if (isset($ais_data['ident'])) {
656
+		    	$data['ident'] = $ais_data['ident'];
657
+		    }
658
+		    if (isset($ais_data['mmsi'])) {
659
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
660
+		    }
661
+		    if (isset($ais_data['speed'])) {
662
+		    	$data['speed'] = $ais_data['speed'];
663
+		    }
664
+		    if (isset($ais_data['heading'])) {
665
+		    	$data['heading'] = $ais_data['heading'];
666
+		    }
667
+		    if (isset($ais_data['latitude'])) {
668
+		    	$data['latitude'] = $ais_data['latitude'];
669
+		    }
670
+		    if (isset($ais_data['longitude'])) {
671
+		    	$data['longitude'] = $ais_data['longitude'];
672
+		    }
673
+		    if (isset($ais_data['status'])) {
674
+		    	$data['status'] = $ais_data['status'];
675
+		    }
676
+		    if (isset($ais_data['statusid'])) {
677
+		    	$data['status_id'] = $ais_data['statusid'];
678
+		    }
679
+		    if (isset($ais_data['type'])) {
680
+		    	$data['type'] = $ais_data['type'];
681
+		    }
682
+		    if (isset($ais_data['typeid'])) {
683
+		    	$data['type_id'] = $ais_data['typeid'];
684
+		    }
685
+		    if (isset($ais_data['imo'])) {
686
+		    	$data['imo'] = $ais_data['imo'];
687
+		    }
688
+		    if (isset($ais_data['callsign'])) {
689
+		    	$data['callsign'] = $ais_data['callsign'];
690
+		    }
504 691
 		    if (isset($ais_data['timestamp'])) {
505 692
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 693
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -514,8 +701,12 @@  discard block
 block discarded – undo
514 701
 		    $data['format_source'] = 'aisnmeatxt';
515 702
     		    $data['id_source'] = $id_source;
516 703
 		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
704
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
705
+		    	$data['noarchive'] = true;
706
+		    }
707
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
708
+		    	$MI->add($data);
709
+		    }
519 710
 		    unset($data);
520 711
 		}
521 712
     	    }
@@ -538,20 +729,48 @@  discard block
 block discarded – undo
538 729
 			    if ($line != '') {
539 730
 				$ais_data = $AIS->parse_line(trim($line));
540 731
 				$data = array();
541
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
542
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
544
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
545
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
546
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
547
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
548
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
549
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
550
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
551
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
552
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
732
+				if (isset($ais_data['ident'])) {
733
+					$data['ident'] = $ais_data['ident'];
734
+				}
735
+				if (isset($ais_data['mmsi'])) {
736
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
737
+				}
738
+				if (isset($ais_data['speed'])) {
739
+					$data['speed'] = $ais_data['speed'];
740
+				}
741
+				if (isset($ais_data['heading'])) {
742
+					$data['heading'] = $ais_data['heading'];
743
+				}
744
+				if (isset($ais_data['latitude'])) {
745
+					$data['latitude'] = $ais_data['latitude'];
746
+				}
747
+				if (isset($ais_data['longitude'])) {
748
+					$data['longitude'] = $ais_data['longitude'];
749
+				}
750
+				if (isset($ais_data['status'])) {
751
+					$data['status'] = $ais_data['status'];
752
+				}
753
+				if (isset($ais_data['statusid'])) {
754
+					$data['status_id'] = $ais_data['statusid'];
755
+				}
756
+				if (isset($ais_data['type'])) {
757
+					$data['type'] = $ais_data['type'];
758
+				}
759
+				if (isset($ais_data['typeid'])) {
760
+					$data['type_id'] = $ais_data['typeid'];
761
+				}
762
+				if (isset($ais_data['imo'])) {
763
+					$data['imo'] = $ais_data['imo'];
764
+				}
765
+				if (isset($ais_data['callsign'])) {
766
+					$data['callsign'] = $ais_data['callsign'];
767
+				}
768
+				if (isset($ais_data['destination'])) {
769
+					$data['arrival_code'] = $ais_data['destination'];
770
+				}
771
+				if (isset($ais_data['eta_ts'])) {
772
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
773
+				}
555 774
 				if (isset($ais_data['timestamp'])) {
556 775
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 776
 				} else {
@@ -559,18 +778,27 @@  discard block
 block discarded – undo
559 778
 				}
560 779
 				$data['format_source'] = 'aisnmeahttp';
561 780
 				$data['id_source'] = $id_source;
562
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
781
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
782
+					$data['noarchive'] = true;
783
+				}
784
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
785
+					$MI->add($data);
786
+				}
564 787
 				unset($data);
565 788
 			    }
566 789
 			}
567 790
 		    }
568 791
 		} else {
569 792
 		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
793
+		    if (isset($tt[$format])) {
794
+		    	$tt[$format]++;
795
+		    } else {
796
+		    	$tt[$format] = 0;
797
+		    }
572 798
 		    if ($tt[$format] > 30) {
573
-			if ($globalDebug) echo 'Reconnect...'."\n";
799
+			if ($globalDebug) {
800
+				echo 'Reconnect...'."\n";
801
+			}
574 802
 			sleep(2);
575 803
 			//$sourceeen[] = $value;
576 804
 			//connect_all($sourceeen);
@@ -606,12 +834,18 @@  discard block
 block discarded – undo
606 834
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607 835
 			    //$data['type_id'] = $line['TYPE'];
608 836
 			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
837
+			    if ($line['DEST'] != '') {
838
+			    	$data['arrival_code'] = $line['DEST'];
839
+			    }
840
+			    if ($line['ARV'] != '') {
841
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
842
+			    }
611 843
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612 844
 			    $data['format_source'] = 'myshiptracking';
613 845
 			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
846
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
847
+			    	$data['noarchive'] = true;
848
+			    }
615 849
 			    $MI->add($data);
616 850
 			    unset($data);
617 851
 			}
@@ -636,7 +870,9 @@  discard block
 block discarded – undo
636 870
 			    $data['callsign'] = $line['callsign'];
637 871
 			    $data['mmsi'] = substr($line['mmsi'],-9);
638 872
 			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
873
+			    if ($line['heading'] != '511') {
874
+			    	$data['heading'] = $line['heading'];
875
+			    }
640 876
 			    $data['latitude'] = $line['latitude'];
641 877
 			    $data['longitude'] = $line['longitude'];
642 878
 			    $data['type_id'] = $line['shiptype'];
@@ -644,7 +880,9 @@  discard block
 block discarded – undo
644 880
 			    $data['datetime'] = $line['time'];
645 881
 			    $data['format_source'] = 'boatbeaconapp';
646 882
 			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
883
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
884
+			    	$data['noarchive'] = true;
885
+			    }
648 886
 			    $MI->add($data);
649 887
 			    unset($data);
650 888
 			}
@@ -666,22 +904,44 @@  discard block
 block discarded – undo
666 904
 		    foreach ($all_data['features'] as $line) {
667 905
 			print_r($line);
668 906
 			$data = array();
669
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
670
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
671
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
672
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
673
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
674
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
907
+			if (isset($line['properties']['name'])) {
908
+				$data['ident'] = $line['properties']['name'];
909
+			}
910
+			if (isset($line['properties']['callsign'])) {
911
+				$data['callsign'] = $line['properties']['callsign'];
912
+			}
913
+			if (isset($line['properties']['mmsi'])) {
914
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
915
+			}
916
+			if (isset($line['properties']['imo'])) {
917
+				$data['imo'] = $line['properties']['imo'];
918
+			}
919
+			if (isset($line['properties']['speed'])) {
920
+				$data['speed'] = $line['properties']['speed'];
921
+			}
922
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
923
+				$data['heading'] = $line['properties']['heading'];
924
+			}
675 925
 			$data['latitude'] = $line['geometry']['coordinates'][1];
676 926
 			$data['longitude'] = $line['geometry']['coordinates'][0];
677
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
678
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
679
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
927
+			if (isset($line['properties']['vesselType'])) {
928
+				$data['type'] = $line['properties']['vesselType'];
929
+			}
930
+			if (isset($line['properties']['destination'])) {
931
+				$data['arrival_code'] = $line['properties']['destination'];
932
+			}
933
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
934
+				$data['arrival_date'] = $line['properties']['eta'];
935
+			}
680 936
 			$data['format_source'] = 'boatnerd';
681 937
 			$data['id_source'] = $id_source;
682 938
 			$data['datetime'] = date('Y-m-d H:i:s');
683
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
939
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
940
+				$data['noarchive'] = true;
941
+			}
942
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
943
+				$MI->add($data);
944
+			}
685 945
 			unset($data);
686 946
 		    }
687 947
 		}
@@ -698,7 +958,9 @@  discard block
 block discarded – undo
698 958
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699 959
 	    echo 'done !'."\n";
700 960
 	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
961
+	    if ($buffer != '') {
962
+	    	$reset = 0;
963
+	    }
702 964
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703 965
 	    $buffer = explode('\n',$buffer);
704 966
 	    foreach ($buffer as $line) {
@@ -724,7 +986,9 @@  discard block
 block discarded – undo
724 986
 		    //$data['etaTime'] = substr($line,135,5);
725 987
 		    $data['format_source'] = 'shipplotter';
726 988
     		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
989
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
990
+		    	$data['noarchive'] = true;
991
+		    }
728 992
 		    //print_r($data);
729 993
 		    echo 'Add...'."\n";
730 994
 		    $MI->add($data);
@@ -758,16 +1022,28 @@  discard block
 block discarded – undo
758 1022
     		    $line = explode(':', $line);
759 1023
     		    if (count($line) > 30 && $line[0] != 'callsign') {
760 1024
 			$data = array();
761
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1025
+			if (isset($line[37]) && $line[37] != '') {
1026
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1027
+			} else {
1028
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1029
+			}
763 1030
 			$data['pilot_id'] = $line[1];
764 1031
 			$data['pilot_name'] = $line[2];
765 1032
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
766 1033
 			$data['ident'] = $line[0]; // ident
767
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1034
+			if ($line[7] != '' && $line[7] != 0) {
1035
+				$data['altitude'] = $line[7];
1036
+			}
1037
+			// altitude
768 1038
 			$data['speed'] = $line[8]; // speed
769
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1039
+			if (isset($line[45])) {
1040
+				$data['heading'] = $line[45];
1041
+			}
1042
+			// heading
1043
+			elseif (isset($line[38])) {
1044
+				$data['heading'] = $line[38];
1045
+			}
1046
+			// heading
771 1047
 			$data['latitude'] = $line[5]; // lat
772 1048
 	        	$data['longitude'] = $line[6]; // long
773 1049
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -783,7 +1059,9 @@  discard block
 block discarded – undo
783 1059
 			$data['frequency'] = $line[4];
784 1060
 			$data['type'] = $line[18];
785 1061
 			$data['range'] = $line[19];
786
-			if (isset($line[35])) $data['info'] = $line[35];
1062
+			if (isset($line[35])) {
1063
+				$data['info'] = $line[35];
1064
+			}
787 1065
     			$data['id_source'] = $id_source;
788 1066
 	    		//$data['arrival_airport_time'] = ;
789 1067
 	    		if ($line[9] != '') {
@@ -797,27 +1075,47 @@  discard block
 block discarded – undo
797 1075
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 1076
 	    		*/
799 1077
 	    		$data['format_source'] = $value['format'];
800
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
803
-			elseif ($line[3] === 'ATC') {
1078
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1079
+				$data['noarchive'] = true;
1080
+			}
1081
+			if (isset($value['name']) && $value['name'] != '') {
1082
+				$data['source_name'] = $value['name'];
1083
+			}
1084
+    			if ($line[3] === 'PILOT') {
1085
+    				$SI->add($data);
1086
+    			} elseif ($line[3] === 'ATC') {
804 1087
 				//print_r($data);
805 1088
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
806 1089
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
807 1090
 				$typec = substr($data['ident'],-3);
808
-				if ($typec === 'APP') $data['type'] = 'Approach';
809
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
810
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
811
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
812
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
813
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
814
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
815
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
816
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
817
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1091
+				if ($typec === 'APP') {
1092
+					$data['type'] = 'Approach';
1093
+				} elseif ($typec === 'TWR') {
1094
+					$data['type'] = 'Tower';
1095
+				} elseif ($typec === 'OBS') {
1096
+					$data['type'] = 'Observer';
1097
+				} elseif ($typec === 'GND') {
1098
+					$data['type'] = 'Ground';
1099
+				} elseif ($typec === 'DEL') {
1100
+					$data['type'] = 'Delivery';
1101
+				} elseif ($typec === 'DEP') {
1102
+					$data['type'] = 'Departure';
1103
+				} elseif ($typec === 'FSS') {
1104
+					$data['type'] = 'Flight Service Station';
1105
+				} elseif ($typec === 'CTR') {
1106
+					$data['type'] = 'Control Radar or Centre';
1107
+				} elseif ($data['type'] === '') {
1108
+					$data['type'] = 'Observer';
1109
+				}
1110
+				if (!isset($data['source_name'])) {
1111
+					$data['source_name'] = '';
1112
+				}
818 1113
 				if (isset($ATC)) {
819
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
820
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1114
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1115
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1116
+					} else {
1117
+						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']);
1118
+					}
821 1119
 				}
822 1120
 			}
823 1121
     			unset($data);
@@ -844,14 +1142,20 @@  discard block
 block discarded – undo
844 1142
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
845 1143
 			$data['latitude'] = (float)$line['pktLatitude'];
846 1144
 			$data['longitude'] = (float)$line['pktLongitude'];
847
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
848
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1145
+			if ((float)$line['pktTrack'] != 0) {
1146
+				$data['heading'] = (float)$line['pktTrack'];
1147
+			}
1148
+			if ((int)$line['pktSpeed'] != 0) {
1149
+				$data['speed'] = (int)$line['pktSpeed'];
1150
+			}
849 1151
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
850 1152
 			$data['altitude_relative'] = 'AMSL';
851 1153
 			$data['pilot_id'] = (int)$line['pktPilotID'];
852 1154
 			$data['aircraft_icao'] = 'PARAGLIDER';
853 1155
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
854
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1156
+			if (isset($pilot_data[4])) {
1157
+				$data['pilot_name'] = $pilot_data[4];
1158
+			}
855 1159
 			$data['format_source'] = $value['format'];
856 1160
 			$SI->add($data);
857 1161
 			unset($data);
@@ -899,25 +1203,59 @@  discard block
 block discarded – undo
899 1203
 		    foreach ($all_data['acList'] as $line) {
900 1204
 			$data = array();
901 1205
 			$data['hex'] = $line['Icao']; // hex
902
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
903
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
904
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
905
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
906
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
907
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1206
+			if (isset($line['Call'])) {
1207
+				$data['ident'] = $line['Call'];
1208
+			}
1209
+			// ident
1210
+			if (isset($line['Alt'])) {
1211
+				$data['altitude'] = $line['Alt'];
1212
+			}
1213
+			// altitude
1214
+			if (isset($line['Spd'])) {
1215
+				$data['speed'] = $line['Spd'];
1216
+			}
1217
+			// speed
1218
+			if (isset($line['Trak'])) {
1219
+				$data['heading'] = $line['Trak'];
1220
+			}
1221
+			// heading
1222
+			if (isset($line['Lat'])) {
1223
+				$data['latitude'] = $line['Lat'];
1224
+			}
1225
+			// lat
1226
+			if (isset($line['Long'])) {
1227
+				$data['longitude'] = $line['Long'];
1228
+			}
1229
+			// long
908 1230
 			//$data['verticalrate'] = $line['']; // verticale rate
909
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1231
+			if (isset($line['Sqk'])) {
1232
+				$data['squawk'] = $line['Sqk'];
1233
+			}
1234
+			// squawk
910 1235
 			$data['emergency'] = ''; // emergency
911
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
912
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
913
-			else $data['datetime'] = date('Y-m-d H:i:s');
1236
+			if (isset($line['Reg'])) {
1237
+				$data['registration'] = $line['Reg'];
1238
+			}
1239
+			if (isset($line['PosTime'])) {
1240
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1241
+			} else {
1242
+				$data['datetime'] = date('Y-m-d H:i:s');
1243
+			}
914 1244
 			//$data['datetime'] = date('Y-m-d H:i:s');
915
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1245
+			if (isset($line['Type'])) {
1246
+				$data['aircraft_icao'] = $line['Type'];
1247
+			}
916 1248
 			$data['format_source'] = 'aircraftlistjson';
917 1249
 			$data['id_source'] = $id_source;
918
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
919
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920
-			if (isset($data['latitude'])) $SI->add($data);
1250
+			if (isset($value['name']) && $value['name'] != '') {
1251
+				$data['source_name'] = $value['name'];
1252
+			}
1253
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1254
+				$data['noarchive'] = true;
1255
+			}
1256
+			if (isset($data['latitude'])) {
1257
+				$SI->add($data);
1258
+			}
921 1259
 			unset($data);
922 1260
 		    }
923 1261
 		} elseif (is_array($all_data)) {
@@ -934,17 +1272,26 @@  discard block
 block discarded – undo
934 1272
 			$data['verticalrate'] = $line['vrt']; // verticale rate
935 1273
 			$data['squawk'] = $line['squawk']; // squawk
936 1274
 			$data['emergency'] = ''; // emergency
937
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
938
-			else $data['datetime'] = date('Y-m-d H:i:s');
1275
+			if (isset($line['PosTime'])) {
1276
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1277
+			} else {
1278
+				$data['datetime'] = date('Y-m-d H:i:s');
1279
+			}
939 1280
 			$data['format_source'] = 'aircraftlistjson';
940 1281
 			$data['id_source'] = $id_source;
941
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
942
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1282
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1283
+				$data['noarchive'] = true;
1284
+			}
1285
+			if (isset($value['name']) && $value['name'] != '') {
1286
+				$data['source_name'] = $value['name'];
1287
+			}
943 1288
 			$SI->add($data);
944 1289
 			unset($data);
945 1290
 		    }
946 1291
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
1292
+	    } elseif ($globalDebug) {
1293
+	    	echo 'No data'."\n";
1294
+	    }
948 1295
     	    //$last_exec['aircraftlistjson'] = time();
949 1296
     	    $last_exec[$id]['last'] = time();
950 1297
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -980,8 +1327,12 @@  discard block
 block discarded – undo
980 1327
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981 1328
 	    	    $data['format_source'] = 'planeupdatefaa';
982 1329
     		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1330
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1331
+		    	$data['noarchive'] = true;
1332
+		    }
1333
+		    if (isset($value['name']) && $value['name'] != '') {
1334
+		    	$data['source_name'] = $value['name'];
1335
+		    }
985 1336
 		    $SI->add($data);
986 1337
 		    unset($data);
987 1338
 		}
@@ -1015,7 +1366,9 @@  discard block
 block discarded – undo
1015 1366
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016 1367
 		    $data['format_source'] = 'opensky';
1017 1368
 		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1369
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1370
+		    	$data['noarchive'] = true;
1371
+		    }
1019 1372
 		    $SI->add($data);
1020 1373
 		    unset($data);
1021 1374
 		}
@@ -1035,15 +1388,42 @@  discard block
 block discarded – undo
1035 1388
 		foreach ($all_data['aircraft'] as $key => $line) {
1036 1389
 		    $data = array();
1037 1390
 		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1391
+		    if (isset($line['hex'])) {
1392
+		    	$data['hex'] = $line['hex'];
1393
+		    }
1394
+		    // hex
1395
+		    if (isset($line['flight'])) {
1396
+		    	$data['ident'] = trim($line['flight']);
1397
+		    }
1398
+		    // ident
1399
+		    if (isset($line['altitude'])) {
1400
+		    	$data['altitude'] = $line['altitude'];
1401
+		    }
1402
+		    // altitude
1403
+		    if (isset($line['speed'])) {
1404
+		    	$data['speed'] = $line['speed'];
1405
+		    }
1406
+		    // speed
1407
+		    if (isset($line['track'])) {
1408
+		    	$data['heading'] = $line['track'];
1409
+		    }
1410
+		    // heading
1411
+		    if (isset($line['lat'])) {
1412
+		    	$data['latitude'] = $line['lat'];
1413
+		    }
1414
+		    // lat
1415
+		    if (isset($line['lon'])) {
1416
+		    	$data['longitude'] = $line['lon'];
1417
+		    }
1418
+		    // long
1419
+		    if (isset($line['vert_rate'])) {
1420
+		    	$data['verticalrate'] = $line['vert_rate'];
1421
+		    }
1422
+		    // verticale rate
1423
+		    if (isset($line['squawk'])) {
1424
+		    	$data['squawk'] = $line['squawk'];
1425
+		    }
1426
+		    // squawk
1047 1427
 		    //$data['emergency'] = ''; // emergency
1048 1428
 		    //$data['registration'] = $line[2];
1049 1429
 		    //$data['aircraft_icao'] = $line[0];
@@ -1051,10 +1431,17 @@  discard block
 block discarded – undo
1051 1431
 		    $data['format_source'] = 'aircraftjson';
1052 1432
 		    $data['id_source'] = $id_source;
1053 1433
 		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1434
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1435
+			    	$data['source_name'] = $value['name'].'_MLAT';
1436
+			    } else {
1437
+			    	$data['source_name'] = $value['name'];
1438
+			    }
1439
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1440
+		    	$data['source_name'] = 'MLAT';
1441
+		    }
1442
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1443
+		    	$data['noarchive'] = true;
1444
+		    }
1058 1445
 		    $SI->add($data);
1059 1446
 		    unset($data);
1060 1447
 		}
@@ -1074,22 +1461,54 @@  discard block
 block discarded – undo
1074 1461
 		foreach ($all_data['aircraft'] as $key => $line) {
1075 1462
 		    $data = array();
1076 1463
 		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1464
+		    if (isset($line['callsign'])) {
1465
+		    	$data['ident'] = trim($line['callsign']);
1466
+		    }
1467
+		    // ident
1468
+		    if (isset($line['altitude'])) {
1469
+		    	$data['altitude'] = $line['altitude'];
1470
+		    }
1471
+		    // altitude
1472
+		    if (isset($line['speed'])) {
1473
+		    	$data['speed'] = $line['speed'];
1474
+		    }
1475
+		    // speed
1476
+		    if (isset($line['heading'])) {
1477
+		    	$data['heading'] = $line['heading'];
1478
+		    }
1479
+		    // heading
1480
+		    if (isset($line['lat'])) {
1481
+		    	$data['latitude'] = $line['lat'];
1482
+		    }
1483
+		    // lat
1484
+		    if (isset($line['lon'])) {
1485
+		    	$data['longitude'] = $line['lon'];
1486
+		    }
1487
+		    // long
1488
+		    if (isset($line['vert_rate'])) {
1489
+		    	$data['verticalrate'] = $line['vert_rate'];
1490
+		    }
1491
+		    // verticale rate
1492
+		    if (isset($line['squawk'])) {
1493
+		    	$data['squawk'] = $line['squawk'];
1494
+		    }
1495
+		    // squawk
1085 1496
 		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1497
+		    if (isset($line['reg'])) {
1498
+		    	$data['registration'] = $line['reg'];
1499
+		    }
1500
+		    if (isset($line['type'])) {
1501
+		    	$data['aircraft_icao'] = $line['type'];
1502
+		    }
1088 1503
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089 1504
 		    $data['format_source'] = 'planefinderclient';
1090 1505
 		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1506
+		    if (isset($value['name']) && $value['name'] != '') {
1507
+		    	$data['source_name'] = $value['name'];
1508
+		    }
1509
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1510
+		    	$data['noarchive'] = true;
1511
+		    }
1093 1512
 		    $SI->add($data);
1094 1513
 		    unset($data);
1095 1514
 		}
@@ -1105,7 +1524,9 @@  discard block
 block discarded – undo
1105 1524
 	    //$buffer = $Common->getData($hosts[$id]);
1106 1525
 	    $buffer = $Common->getData($value['host']);
1107 1526
 	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1527
+	    if (!empty($all_data)) {
1528
+	    	$reset = 0;
1529
+	    }
1109 1530
 	    foreach ($all_data as $key => $line) {
1110 1531
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111 1532
 		    $data = array();
@@ -1126,8 +1547,12 @@  discard block
 block discarded – undo
1126 1547
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127 1548
 	    	    $data['format_source'] = 'fr24json';
1128 1549
     		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1550
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1551
+		    	$data['noarchive'] = true;
1552
+		    }
1553
+		    if (isset($value['name']) && $value['name'] != '') {
1554
+		    	$data['source_name'] = $value['name'];
1555
+		    }
1131 1556
 		    $SI->add($data);
1132 1557
 		    unset($data);
1133 1558
 		}
@@ -1156,24 +1581,42 @@  discard block
 block discarded – undo
1156 1581
 		    if (isset($line['inf'])) {
1157 1582
 			$data = array();
1158 1583
 			$data['hex'] = $line['inf']['ia'];
1159
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1584
+			if (isset($line['inf']['cs'])) {
1585
+				$data['ident'] = $line['inf']['cs'];
1586
+			}
1587
+			//$line[13]
1160 1588
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1589
+	    		if (isset($line['inf']['gs'])) {
1590
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1591
+	    		}
1592
+	    		// speed
1593
+	    		if (isset($line['inf']['tr'])) {
1594
+	    			$data['heading'] = $line['inf']['tr'];
1595
+	    		}
1596
+	    		// heading
1163 1597
 	    		$data['latitude'] = $line['pt'][0]; // lat
1164 1598
 	    		$data['longitude'] = $line['pt'][1]; // long
1165 1599
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1600
+	    		if (isset($line['inf']['sq'])) {
1601
+	    			$data['squawk'] = $line['inf']['sq'];
1602
+	    		}
1603
+	    		// squawk
1167 1604
 	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1605
+	    		if (isset($line['inf']['rc'])) {
1606
+	    			$data['registration'] = $line['inf']['rc'];
1607
+	    		}
1169 1608
 			//$data['departure_airport_iata'] = $line[11];
1170 1609
 			//$data['arrival_airport_iata'] = $line[12];
1171 1610
 	    		//$data['emergency'] = ''; // emergency
1172 1611
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173 1612
 	    		$data['format_source'] = 'radarvirtueljson';
1174 1613
     			$data['id_source'] = $id_source;
1175
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1614
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1615
+				$data['noarchive'] = true;
1616
+			}
1617
+			if (isset($value['name']) && $value['name'] != '') {
1618
+				$data['source_name'] = $value['name'];
1619
+			}
1177 1620
 			$SI->add($data);
1178 1621
 			unset($data);
1179 1622
 		    }
@@ -1199,30 +1642,65 @@  discard block
 block discarded – undo
1199 1642
 		    $data['id'] = $line['id'];
1200 1643
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201 1644
 		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1645
+		    if (isset($line['pilotid'])) {
1646
+		    	$data['pilot_id'] = $line['pilotid'];
1647
+		    }
1648
+		    // pilot id
1649
+		    if (isset($line['name'])) {
1650
+		    	$data['pilot_name'] = $line['name'];
1651
+		    }
1652
+		    // pilot name
1653
+		    if (isset($line['alt'])) {
1654
+		    	$data['altitude'] = $line['alt'];
1655
+		    }
1656
+		    // altitude
1657
+		    if (isset($line['gs'])) {
1658
+		    	$data['speed'] = $line['gs'];
1659
+		    }
1660
+		    // speed
1661
+		    if (isset($line['heading'])) {
1662
+		    	$data['heading'] = $line['heading'];
1663
+		    }
1664
+		    // heading
1665
+		    if (isset($line['route'])) {
1666
+		    	$data['waypoints'] = $line['route'];
1667
+		    }
1668
+		    // route
1208 1669
 		    $data['latitude'] = $line['lat']; // lat
1209 1670
 		    $data['longitude'] = $line['lon']; // long
1210 1671
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211 1672
 		    //$data['squawk'] = $line['squawk']; // squawk
1212 1673
 		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1674
+		    if (isset($line['depicao'])) {
1675
+		    	$data['departure_airport_icao'] = $line['depicao'];
1676
+		    }
1677
+		    if (isset($line['deptime'])) {
1678
+		    	$data['departure_airport_time'] = $line['deptime'];
1679
+		    }
1680
+		    if (isset($line['arricao'])) {
1681
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1682
+		    }
1216 1683
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1684
+		    if (isset($line['aircraft'])) {
1685
+		    	$data['aircraft_icao'] = $line['aircraft'];
1686
+		    }
1687
+		    if (isset($line['transponder'])) {
1688
+		    	$data['squawk'] = $line['transponder'];
1689
+		    }
1690
+		    if (isset($line['atis'])) {
1691
+		    	$data['info'] = $line['atis'];
1692
+		    } else {
1693
+		    	$data['info'] = '';
1694
+		    }
1221 1695
 		    $data['format_source'] = 'pireps';
1222 1696
     		    $data['id_source'] = $id_source;
1223 1697
 		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1698
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1699
+		    	$data['noarchive'] = true;
1700
+		    }
1701
+		    if (isset($value['name']) && $value['name'] != '') {
1702
+		    	$data['source_name'] = $value['name'];
1703
+		    }
1226 1704
 		    if ($line['icon'] === 'plane') {
1227 1705
 			$SI->add($data);
1228 1706
 		    //    print_r($data);
@@ -1231,16 +1709,28 @@  discard block
 block discarded – undo
1231 1709
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1710
 			$typec = substr($data['ident'],-3);
1233 1711
 			$data['type'] = '';
1234
-			if ($typec === 'APP') $data['type'] = 'Approach';
1235
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1236
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1237
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1238
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1239
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1240
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1241
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242
-			else $data['type'] = 'Observer';
1243
-			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']);
1712
+			if ($typec === 'APP') {
1713
+				$data['type'] = 'Approach';
1714
+			} elseif ($typec === 'TWR') {
1715
+				$data['type'] = 'Tower';
1716
+			} elseif ($typec === 'OBS') {
1717
+				$data['type'] = 'Observer';
1718
+			} elseif ($typec === 'GND') {
1719
+				$data['type'] = 'Ground';
1720
+			} elseif ($typec === 'DEL') {
1721
+				$data['type'] = 'Delivery';
1722
+			} elseif ($typec === 'DEP') {
1723
+				$data['type'] = 'Departure';
1724
+			} elseif ($typec === 'FSS') {
1725
+				$data['type'] = 'Flight Service Station';
1726
+			} elseif ($typec === 'CTR') {
1727
+				$data['type'] = 'Control Radar or Centre';
1728
+			} else {
1729
+				$data['type'] = 'Observer';
1730
+			}
1731
+			if (isset($ATC)) {
1732
+				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']);
1733
+			}
1244 1734
 		    }
1245 1735
 		    unset($data);
1246 1736
 		}
@@ -1255,7 +1745,9 @@  discard block
 block discarded – undo
1255 1745
 	    )
1256 1746
 	) {
1257 1747
 	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1748
+	    if ($globalDebug) {
1749
+	    	echo 'Get Data...'."\n";
1750
+	    }
1259 1751
 	    $buffer = $Common->getData($value['host']);
1260 1752
 	    $all_data = json_decode($buffer,true);
1261 1753
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1263,10 +1755,16 @@  discard block
 block discarded – undo
1263 1755
 		foreach ($all_data as $line) {
1264 1756
 	    	    $data = array();
1265 1757
 	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1758
+	    	    if (isset($line['pilotid'])) {
1759
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1760
+	    	    }
1267 1761
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1762
+	    	    if (isset($line['pilotname'])) {
1763
+	    	    	$data['pilot_name'] = $line['pilotname'];
1764
+	    	    }
1765
+	    	    if (isset($line['pilotid'])) {
1766
+	    	    	$data['pilot_id'] = $line['pilotid'];
1767
+	    	    }
1270 1768
 	    	    $data['ident'] = $line['flightnum']; // ident
1271 1769
 	    	    $data['altitude'] = $line['alt']; // altitude
1272 1770
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1282,7 +1780,9 @@  discard block
 block discarded – undo
1282 1780
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283 1781
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284 1782
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1783
+	    	    } else {
1784
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1785
+	    	    }
1286 1786
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1287 1787
 	    	    $data['departure_airport_time'] = $line['deptime'];
1288 1788
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1290,29 +1790,47 @@  discard block
 block discarded – undo
1290 1790
     		    if (isset($line['registration'])) {
1291 1791
     			$data['registration'] = $line['registration'];
1292 1792
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1793
+    		    } else {
1794
+    		    	$data['registration'] = $line['aircraft'];
1795
+    		    }
1796
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1797
+		    	$data['noarchive'] = true;
1798
+		    }
1799
+		    if (isset($line['route'])) {
1800
+		    	$data['waypoints'] = $line['route'];
1801
+		    }
1802
+		    // route
1296 1803
 		    if (isset($line['aircraftname'])) {
1297 1804
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1805
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299 1806
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1807
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1808
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1809
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1810
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1811
+	    		} else {
1303 1812
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1813
+	    		    if (isset($aircraft_data[1])) {
1814
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1815
+	    		    } else {
1816
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1817
+	    		    }
1306 1818
 	    		}
1307 1819
 	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1820
+    		    if (isset($line['route'])) {
1821
+    		    	$data['waypoints'] = $line['route'];
1822
+    		    }
1309 1823
     		    $data['id_source'] = $id_source;
1310 1824
 	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1825
+		    if (isset($value['name']) && $value['name'] != '') {
1826
+		    	$data['source_name'] = $value['name'];
1827
+		    }
1312 1828
 		    $SI->add($data);
1313 1829
 		    unset($data);
1314 1830
 		}
1315
-		if ($globalDebug) echo 'No more data...'."\n";
1831
+		if ($globalDebug) {
1832
+			echo 'No more data...'."\n";
1833
+		}
1316 1834
 		unset($buffer);
1317 1835
 		unset($all_data);
1318 1836
 	    }
@@ -1325,7 +1843,9 @@  discard block
 block discarded – undo
1325 1843
 	    )
1326 1844
 	) {
1327 1845
 	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1846
+	    if ($globalDebug) {
1847
+	    	echo 'Get Data...'."\n";
1848
+	    }
1329 1849
 	    $buffer = $Common->getData($value['host']);
1330 1850
 	    $all_data = json_decode($buffer,true);
1331 1851
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1336,10 +1856,16 @@  discard block
 block discarded – undo
1336 1856
 	    	    //$data['id'] = $line['id']; // id not usable
1337 1857
 	    	    $data['id'] = $line['id'];
1338 1858
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1859
+	    	    if (isset($line['user']['username'])) {
1860
+	    	    	$data['pilot_name'] = $line['user']['username'];
1861
+	    	    }
1862
+	    	    if (isset($line['user_id'])) {
1863
+	    	    	$data['pilot_id'] = $line['user_id'];
1864
+	    	    }
1341 1865
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1866
+	    	    if (is_numeric($data['ident'])) {
1867
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1868
+	    	    }
1343 1869
 	    	    $data['altitude'] = $line['altitude']; // altitude
1344 1870
 	    	    $data['speed'] = $line['groundspeed']; // speed
1345 1871
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1352,7 +1878,9 @@  discard block
 block discarded – undo
1352 1878
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353 1879
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354 1880
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1881
+	    	    } else {
1882
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1883
+	    	    }
1356 1884
 	    	    
1357 1885
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358 1886
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1360,17 +1888,26 @@  discard block
 block discarded – undo
1360 1888
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361 1889
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1362 1890
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1891
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1892
+		    	$data['noarchive'] = true;
1893
+		    }
1894
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1895
+		    	$data['waypoints'] = $line['bid']['route'];
1896
+		    }
1897
+		    // route
1365 1898
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1899
 
1367 1900
     		    $data['id_source'] = $id_source;
1368 1901
 	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1902
+		    if (isset($value['name']) && $value['name'] != '') {
1903
+		    	$data['source_name'] = $value['name'];
1904
+		    }
1370 1905
 		    $SI->add($data);
1371 1906
 		    unset($data);
1372 1907
 		}
1373
-		if ($globalDebug) echo 'No more data...'."\n";
1908
+		if ($globalDebug) {
1909
+			echo 'No more data...'."\n";
1910
+		}
1374 1911
 		unset($buffer);
1375 1912
 		unset($all_data);
1376 1913
 	    }
@@ -1383,7 +1920,9 @@  discard block
 block discarded – undo
1383 1920
 	    )
1384 1921
 	) {
1385 1922
 	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1923
+	    if ($globalDebug) {
1924
+	    	echo 'Get Data...'."\n";
1925
+	    }
1387 1926
 	    $buffer = $Common->getData($value['host']);
1388 1927
 	    $all_data = json_decode($buffer,true);
1389 1928
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1412,16 +1951,25 @@  discard block
 block discarded – undo
1412 1951
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413 1952
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414 1953
     		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1954
+		    if (isset($line['route'])) {
1955
+		    	$data['waypoints'] = $line['route'];
1956
+		    }
1957
+		    // route
1416 1958
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1417 1959
     		    $data['id_source'] = $id_source;
1418 1960
 	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1961
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1962
+		    	$data['noarchive'] = true;
1963
+		    }
1964
+		    if (isset($value['name']) && $value['name'] != '') {
1965
+		    	$data['source_name'] = $value['name'];
1966
+		    }
1421 1967
 		    $SI->add($data);
1422 1968
 		    unset($data);
1423 1969
 		}
1424
-		if ($globalDebug) echo 'No more data...'."\n";
1970
+		if ($globalDebug) {
1971
+			echo 'No more data...'."\n";
1972
+		}
1425 1973
 		unset($buffer);
1426 1974
 		unset($all_data);
1427 1975
 	    }
@@ -1434,7 +1982,9 @@  discard block
 block discarded – undo
1434 1982
 	    )
1435 1983
 	) {
1436 1984
 	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1985
+	    if ($globalDebug) {
1986
+	    	echo 'Get Data...'."\n";
1987
+	    }
1438 1988
 	    $buffer = $Common->getData($value['host']);
1439 1989
 	    $all_data = json_decode($buffer,true);
1440 1990
 	    if ($buffer != '') {
@@ -1452,12 +2002,16 @@  discard block
 block discarded – undo
1452 2002
 			$data['id_source'] = $id_source;
1453 2003
 			$data['format_source'] = 'blitzortung';
1454 2004
 			$SI->add($data);
1455
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2005
+			if ($globalDebug) {
2006
+				echo '☈ Lightning added'."\n";
2007
+			}
1456 2008
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 2009
 			unset($data);
1458 2010
 		    }
1459 2011
 		}
1460
-		if ($globalDebug) echo 'No more data...'."\n";
2012
+		if ($globalDebug) {
2013
+			echo 'No more data...'."\n";
2014
+		}
1461 2015
 		unset($buffer);
1462 2016
 	    }
1463 2017
 	    $last_exec[$id]['last'] = time();
@@ -1469,7 +2023,9 @@  discard block
 block discarded – undo
1469 2023
 	    $write = NULL;
1470 2024
 	    $e = NULL;
1471 2025
 	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
2026
+	    if ($e != NULL) {
2027
+	    	var_dump($e);
2028
+	    }
1473 2029
 	    if ($n > 0) {
1474 2030
 		$reset = 0;
1475 2031
 		foreach ($read as $nb => $r) {
@@ -1491,13 +2047,17 @@  discard block
 block discarded – undo
1491 2047
 		    if ($buffer !== FALSE) {
1492 2048
 			if ($format === 'vrstcp') {
1493 2049
 			    $buffer = explode('},{',$buffer);
1494
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2050
+			} else {
2051
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2052
+			}
1495 2053
 		    }
1496 2054
 		    // SBS format is CSV format
1497 2055
 		    if ($buffer !== FALSE && $buffer !== '') {
1498 2056
 			$tt[$format] = 0;
1499 2057
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2058
+			    if ($globalDebug) {
2059
+			    	echo 'ACARS : '.$buffer."\n";
2060
+			    }
1501 2061
 			    $ACARS->add(trim($buffer));
1502 2062
 			    $ACARS->deleteLiveAcarsData();
1503 2063
 			} elseif ($format === 'raw') {
@@ -1506,30 +2066,70 @@  discard block
 block discarded – undo
1506 2066
 			    if (is_array($data)) {
1507 2067
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 2068
 				$data['format_source'] = 'raw';
1509
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2069
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2070
+					$data['source_name'] = $globalSources[$nb]['name'];
2071
+				}
2072
+				if (isset($globalSources[$nb]['sourcestats'])) {
2073
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2074
+				}
2075
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2076
+					$data['noarchive'] = true;
2077
+				}
2078
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2079
+					$SI->add($data);
2080
+				}
1513 2081
 			    }
1514 2082
 			} elseif ($format === 'ais') {
1515 2083
 			    $ais_data = $AIS->parse_line(trim($buffer));
1516 2084
 			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2085
+			    if (isset($ais_data['ident'])) {
2086
+			    	$data['ident'] = $ais_data['ident'];
2087
+			    }
2088
+			    if (isset($ais_data['mmsi'])) {
2089
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2090
+			    }
2091
+			    if (isset($ais_data['speed'])) {
2092
+			    	$data['speed'] = $ais_data['speed'];
2093
+			    }
2094
+			    if (isset($ais_data['heading'])) {
2095
+			    	$data['heading'] = $ais_data['heading'];
2096
+			    }
2097
+			    if (isset($ais_data['latitude'])) {
2098
+			    	$data['latitude'] = $ais_data['latitude'];
2099
+			    }
2100
+			    if (isset($ais_data['longitude'])) {
2101
+			    	$data['longitude'] = $ais_data['longitude'];
2102
+			    }
2103
+			    if (isset($ais_data['status'])) {
2104
+			    	$data['status'] = $ais_data['status'];
2105
+			    }
2106
+			    if (isset($ais_data['statusid'])) {
2107
+			    	$data['status_id'] = $ais_data['statusid'];
2108
+			    }
2109
+			    if (isset($ais_data['type'])) {
2110
+			    	$data['type'] = $ais_data['type'];
2111
+			    }
2112
+			    if (isset($ais_data['imo'])) {
2113
+			    	$data['imo'] = $ais_data['imo'];
2114
+			    }
2115
+			    if (isset($ais_data['callsign'])) {
2116
+			    	$data['callsign'] = $ais_data['callsign'];
2117
+			    }
2118
+			    if (isset($ais_data['destination'])) {
2119
+			    	$data['arrival_code'] = $ais_data['destination'];
2120
+			    }
2121
+			    if (isset($ais_data['eta_ts'])) {
2122
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2123
+			    }
2124
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2125
+			    	$data['noarchive'] = true;
2126
+			    }
2127
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2128
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2129
+			    }
2130
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2131
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2132
+			    }
1533 2133
 
1534 2134
 			    if (isset($ais_data['timestamp'])) {
1535 2135
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1538,7 +2138,9 @@  discard block
 block discarded – undo
1538 2138
 			    }
1539 2139
 			    $data['format_source'] = 'aisnmea';
1540 2140
     			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2141
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2142
+			    	$MI->add($data);
2143
+			    }
1542 2144
 			    unset($data);
1543 2145
                         } elseif ($format === 'flightgearsp') {
1544 2146
                     	    //echo $buffer."\n";
@@ -1556,12 +2158,18 @@  discard block
 block discarded – undo
1556 2158
 				$data['speed'] = round($line[5]*1.94384);
1557 2159
 				$data['datetime'] = date('Y-m-d H:i:s');
1558 2160
 				$data['format_source'] = 'flightgearsp';
1559
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2161
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2162
+					$data['noarchive'] = true;
2163
+				}
2164
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2165
+					$SI->add($data);
2166
+				}
1561 2167
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562 2168
 			    }
1563 2169
                         } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2170
+                    	    if ($globalDebug) {
2171
+                    	    	echo 'ACARS : '.$buffer."\n";
2172
+                    	    }
1565 2173
 			    $ACARS->add(trim($buffer));
1566 2174
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567 2175
 			    $ACARS->deleteLiveAcarsData();
@@ -1582,8 +2190,12 @@  discard block
 block discarded – undo
1582 2190
 				    $aircraft_type = $line[10];
1583 2191
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584 2192
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2193
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2194
+				    	$data['noarchive'] = true;
2195
+				    }
2196
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2197
+				    	$SI->add($data);
2198
+				    }
1587 2199
 				}
1588 2200
 			    }
1589 2201
 			} elseif ($format === 'beast') {
@@ -1593,28 +2205,62 @@  discard block
 block discarded – undo
1593 2205
 			    foreach($buffer as $all_data) {
1594 2206
 				$line = json_decode('{'.$all_data.'}',true);
1595 2207
 				$data = array();
1596
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1597
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1598
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1599
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1600
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1601
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1602
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2208
+				if (isset($line['Icao'])) {
2209
+					$data['hex'] = $line['Icao'];
2210
+				}
2211
+				// hex
2212
+				if (isset($line['Call'])) {
2213
+					$data['ident'] = $line['Call'];
2214
+				}
2215
+				// ident
2216
+				if (isset($line['Alt'])) {
2217
+					$data['altitude'] = $line['Alt'];
2218
+				}
2219
+				// altitude
2220
+				if (isset($line['Spd'])) {
2221
+					$data['speed'] = $line['Spd'];
2222
+				}
2223
+				// speed
2224
+				if (isset($line['Trak'])) {
2225
+					$data['heading'] = $line['Trak'];
2226
+				}
2227
+				// heading
2228
+				if (isset($line['Lat'])) {
2229
+					$data['latitude'] = $line['Lat'];
2230
+				}
2231
+				// lat
2232
+				if (isset($line['Long'])) {
2233
+					$data['longitude'] = $line['Long'];
2234
+				}
2235
+				// long
1603 2236
 				//$data['verticalrate'] = $line['']; // verticale rate
1604
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2237
+				if (isset($line['Sqk'])) {
2238
+					$data['squawk'] = $line['Sqk'];
2239
+				}
2240
+				// squawk
1605 2241
 				$data['emergency'] = ''; // emergency
1606
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2242
+				if (isset($line['Reg'])) {
2243
+					$data['registration'] = $line['Reg'];
2244
+				}
1607 2245
 				/*
1608 2246
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1609 2247
 				else $data['datetime'] = date('Y-m-d H:i:s');
1610 2248
 				*/
1611 2249
 				$data['datetime'] = date('Y-m-d H:i:s');
1612
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2250
+				if (isset($line['Type'])) {
2251
+					$data['aircraft_icao'] = $line['Type'];
2252
+				}
1613 2253
 		    		$data['format_source'] = 'vrstcp';
1614 2254
 				$data['id_source'] = $id_source;
1615
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2255
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2256
+					$data['noarchive'] = true;
2257
+				}
2258
+				if (isset($value['name']) && $value['name'] != '') {
2259
+					$data['source_name'] = $value['name'];
2260
+				}
2261
+				if (isset($data['latitude']) && isset($data['hex'])) {
2262
+					$SI->add($data);
2263
+				}
1618 2264
 				unset($data);
1619 2265
 			    }
1620 2266
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1627,22 +2273,46 @@  discard block
 block discarded – undo
1627 2273
     				$data['hex'] = $lined['hexid'];
1628 2274
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629 2275
     				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2276
+    				if (isset($lined['ident'])) {
2277
+    					$data['ident'] = $lined['ident'];
2278
+    				}
2279
+    				if (isset($lined['lat'])) {
2280
+    					$data['latitude'] = $lined['lat'];
2281
+    				}
2282
+    				if (isset($lined['lon'])) {
2283
+    					$data['longitude'] = $lined['lon'];
2284
+    				}
2285
+    				if (isset($lined['speed'])) {
2286
+    					$data['speed'] = $lined['speed'];
2287
+    				}
2288
+    				if (isset($lined['squawk'])) {
2289
+    					$data['squawk'] = $lined['squawk'];
2290
+    				}
2291
+    				if (isset($lined['alt'])) {
2292
+    					$data['altitude'] = $lined['alt'];
2293
+    				}
2294
+    				if (isset($lined['heading'])) {
2295
+    					$data['heading'] = $lined['heading'];
2296
+    				}
1637 2297
     				$data['id_source'] = $id_source;
1638 2298
     				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2299
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2300
+    					$data['source_name'] = $globalSources[$nb]['name'];
2301
+    				}
2302
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2303
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2304
+    				}
2305
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2306
+					$data['noarchive'] = true;
2307
+				}
2308
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2309
+    					$SI->add($data);
2310
+    				}
1643 2311
     				unset($lined);
1644 2312
     				unset($data);
1645
-    			    } else $error = true;
2313
+    			    } else {
2314
+    			    	$error = true;
2315
+    			    }
1646 2316
 			} elseif ($format === 'aprs' && $use_aprs) {
1647 2317
 			    if ($aprs_connect === 0) {
1648 2318
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1668,63 +2338,121 @@  discard block
 block discarded – undo
1668 2338
 				    $aprs_last_tx = time();
1669 2339
 				    $data = array();
1670 2340
 				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2341
+				    if (isset($line['address'])) {
2342
+				    	$data['hex'] = $line['address'];
2343
+				    }
2344
+				    if (isset($line['mmsi'])) {
2345
+				    	$data['mmsi'] = $line['mmsi'];
2346
+				    }
2347
+				    if (isset($line['imo'])) {
2348
+				    	$data['imo'] = $line['imo'];
2349
+				    }
2350
+				    if (isset($line['squawk'])) {
2351
+				    	$data['squawk'] = $line['squawk'];
2352
+				    }
2353
+				    if (isset($line['arrival_code'])) {
2354
+				    	$data['arrival_code'] = $line['arrival_code'];
2355
+				    }
2356
+				    if (isset($line['arrival_date'])) {
2357
+				    	$data['arrival_date'] = $line['arrival_date'];
2358
+				    }
2359
+				    if (isset($line['typeid'])) {
2360
+				    	$data['type_id'] = $line['typeid'];
2361
+				    }
2362
+				    if (isset($line['statusid'])) {
2363
+				    	$data['status_id'] = $line['statusid'];
2364
+				    }
2365
+				    if (isset($line['timestamp'])) {
2366
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2367
+				    } else {
2368
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2369
+				    }
1681 2370
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2371
+				    if (isset($line['ident'])) {
2372
+				    	$data['ident'] = $line['ident'];
2373
+				    }
1683 2374
 				    $data['latitude'] = $line['latitude'];
1684 2375
 				    $data['longitude'] = $line['longitude'];
1685 2376
 				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2377
+				    if (isset($line['speed'])) {
2378
+				    	$data['speed'] = $line['speed'];
2379
+				    }
1687 2380
 				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2381
+				    if (isset($line['altitude'])) {
2382
+				    	$data['altitude'] = $line['altitude'];
2383
+				    }
2384
+				    if (isset($line['comment'])) {
2385
+				    	$data['comment'] = $line['comment'];
2386
+				    }
2387
+				    if (isset($line['symbol'])) {
2388
+				    	$data['type'] = $line['symbol'];
2389
+				    }
1691 2390
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 2391
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2392
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2393
+				    	$data['heading'] = $line['heading'];
2394
+				    }
1694 2395
 				    //else echo 'No heading...'."\n";
1695 2396
 				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2397
+				    if (isset($line['stealth'])) {
2398
+				    	$data['aircraft_type'] = $line['stealth'];
2399
+				    }
1697 2400
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2401
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2402
+				    	$data['noarchive'] = true;
2403
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2404
+				    	$data['noarchive'] = false;
2405
+				    }
2406
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2407
+				    	$data['noarchive'] = true;
2408
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2409
+				    	$data['noarchive'] = false;
2410
+				    }
1702 2411
     				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
2412
+    				    if (isset($line['format_source'])) {
2413
+    				    	$data['format_source'] = $line['format_source'];
2414
+    				    } else {
2415
+				    	$data['format_source'] = 'aprs';
2416
+				    }
1705 2417
 				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2418
+				    if (isset($line['source_type'])) {
2419
+				    	$data['source_type'] = $line['source_type'];
2420
+				    } else {
2421
+				    	$data['source_type'] = 'flarm';
2422
+				    }
2423
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2424
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2425
+    				    }
1709 2426
 				    $currentdate = date('Y-m-d H:i:s');
1710 2427
 				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2428
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2429
+				    	$data['altitude_relative'] = 'AMSL';
2430
+				    }
1712 2431
 				    // Accept data if time <= system time + 20s
1713 2432
 				    //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'])))) {
1714 2433
 				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 2434
 					$send = $SI->add($data);
1716 2435
 				    } elseif ($data['source_type'] === 'ais') {
1717 2436
 					$data['type'] = '';
1718
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2437
+					if (isset($globalMarine) && $globalMarine) {
2438
+						$send = $MI->add($data);
2439
+					}
1719 2440
 				    } elseif (isset($line['stealth'])) {
1720
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2441
+					if ($line['stealth'] != 0) {
2442
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2443
+					} else {
2444
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2445
+					}
1722 2446
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723 2447
 					    //$line['symbol'] === 'Balloon' ||
1724 2448
 					    $line['symbol'] === 'Glider' || 
1725 2449
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2450
+					    if ($line['symbol'] === 'Ballon') {
2451
+					    	$data['aircraft_icao'] = 'BALL';
2452
+					    }
2453
+					    if ($line['symbol'] === 'Glider') {
2454
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2455
+					    }
1728 2456
 					    $send = $SI->add($data);
1729 2457
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730 2458
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1755,9 +2483,13 @@  discard block
 block discarded – undo
1755 2483
 				    //} 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') {
1756 2484
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') {
1757 2485
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2486
+					if (isset($globalTracker) && $globalTracker) {
2487
+						$send = $TI->add($data);
2488
+					}
1759 2489
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2490
+					if (!isset($data['altitude'])) {
2491
+						$data['altitude'] = 0;
2492
+					}
1761 2493
 					$Source->deleteOldLocationByType('gs');
1762 2494
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1763 2495
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1766,7 +2498,9 @@  discard block
 block discarded – undo
1766 2498
 					}
1767 2499
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 2500
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769
-					if ($globalDebug) echo '# Weather Station added'."\n";
2501
+					if ($globalDebug) {
2502
+						echo '# Weather Station added'."\n";
2503
+					}
1770 2504
 					$Source->deleteOldLocationByType('wx');
1771 2505
 					$weather_data = json_encode($line);
1772 2506
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1776,7 +2510,9 @@  discard block
 block discarded – undo
1776 2510
 					}
1777 2511
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 2512
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2513
+					if ($globalDebug) {
2514
+						echo '☈ Lightning added'."\n";
2515
+					}
1780 2516
 					$Source->deleteOldLocationByType('lightning');
1781 2517
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1782 2518
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1788,8 +2524,7 @@  discard block
 block discarded – undo
1788 2524
 				    	print_r($line);
1789 2525
 				    }
1790 2526
 				    unset($data);
1791
-				}
1792
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2527
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 2528
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1794 2529
 				}
1795 2530
 				/*
@@ -1798,7 +2533,9 @@  discard block
 block discarded – undo
1798 2533
 				}
1799 2534
 				*/
1800 2535
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1801
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2536
+				elseif ($line === true && $globalDebug) {
2537
+					echo '!! Failed : '.$buffer."!!\n";
2538
+				}
1802 2539
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1803 2540
 					$Source->deleteOldLocationByType('lightning');
1804 2541
 					$Source->deleteOldLocationByType('wx');
@@ -1834,27 +2571,47 @@  discard block
 block discarded – undo
1834 2571
     				$data['ground'] = $line[21];
1835 2572
     				$data['emergency'] = $line[19];
1836 2573
     				$data['format_source'] = 'sbs';
1837
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1839
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1840
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2574
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2575
+					$data['source_name'] = $globalSources[$nb]['name'];
2576
+				} elseif ($line[0] == 'MLAT') {
2577
+					$data['source_name'] = 'MLAT';
2578
+				}
2579
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2580
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2581
+    				}
2582
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2583
+					$data['noarchive'] = true;
2584
+				}
1841 2585
     				$data['id_source'] = $id_source;
1842
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1843
-    				else $error = true;
2586
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2587
+    					$send = $SI->add($data);
2588
+    				} else {
2589
+    					$error = true;
2590
+    				}
1844 2591
     				unset($data);
1845
-    			    } else $error = true;
2592
+    			    } else {
2593
+    			    	$error = true;
2594
+    			    }
1846 2595
 			    if ($error) {
1847 2596
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1848
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2597
+					if ($globalDebug) {
2598
+						echo "Not a message. Ignoring... \n";
2599
+					}
1849 2600
 				} else {
1850
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2601
+					if ($globalDebug) {
2602
+						echo "Wrong line format. Ignoring... \n";
2603
+					}
1851 2604
 					if ($globalDebug) {
1852 2605
 						echo $buffer;
1853 2606
 						//print_r($line);
1854 2607
 					}
1855 2608
 					//socket_close($r);
1856
-					if ($globalDebug) echo "Reconnect after an error...\n";
1857
-					if ($format === 'aprs') $aprs_connect = 0;
2609
+					if ($globalDebug) {
2610
+						echo "Reconnect after an error...\n";
2611
+					}
2612
+					if ($format === 'aprs') {
2613
+						$aprs_connect = 0;
2614
+					}
1858 2615
 					$sourceer[$nb] = $globalSources[$nb];
1859 2616
 					connect_all($sourceer);
1860 2617
 					$sourceer = array();
@@ -1862,10 +2619,14 @@  discard block
 block discarded – undo
1862 2619
 			    }
1863 2620
 			}
1864 2621
 			// Sleep for xxx microseconds
1865
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2622
+			if (isset($globalSBSSleep)) {
2623
+				usleep($globalSBSSleep);
2624
+			}
1866 2625
 		    } else {
1867 2626
 			if ($format === 'flightgearmp') {
1868
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2627
+			    	if ($globalDebug) {
2628
+			    		echo "Reconnect FlightGear MP...";
2629
+			    	}
1869 2630
 				//@socket_close($r);
1870 2631
 				sleep($globalMinFetch);
1871 2632
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1874,10 +2635,15 @@  discard block
 block discarded – undo
1874 2635
 				break;
1875 2636
 				
1876 2637
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1877
-			    if (isset($tt[$format])) $tt[$format]++;
1878
-			    else $tt[$format] = 0;
2638
+			    if (isset($tt[$format])) {
2639
+			    	$tt[$format]++;
2640
+			    } else {
2641
+			    	$tt[$format] = 0;
2642
+			    }
1879 2643
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1880
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2644
+				if ($globalDebug) {
2645
+					echo "ERROR : Reconnect ".$format."...";
2646
+				}
1881 2647
 				//@socket_close($r);
1882 2648
 				sleep(2);
1883 2649
 				$aprs_connect = 0;
@@ -1895,11 +2661,17 @@  discard block
 block discarded – undo
1895 2661
 	    } else {
1896 2662
 		$error = socket_strerror(socket_last_error());
1897 2663
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1898
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1899
-			if (isset($globalDebug)) echo "Restarting...\n";
2664
+			if ($globalDebug) {
2665
+				echo "ERROR : socket_select give this error ".$error . "\n";
2666
+			}
2667
+			if (isset($globalDebug)) {
2668
+				echo "Restarting...\n";
2669
+			}
1900 2670
 			// Restart the script if possible
1901 2671
 			if (is_array($sockets)) {
1902
-			    if ($globalDebug) echo "Shutdown all sockets...";
2672
+			    if ($globalDebug) {
2673
+			    	echo "Shutdown all sockets...";
2674
+			    }
1903 2675
 			    
1904 2676
 			    foreach ($sockets as $sock) {
1905 2677
 				@socket_shutdown($sock,2);
@@ -1907,25 +2679,45 @@  discard block
 block discarded – undo
1907 2679
 			    }
1908 2680
 			    
1909 2681
 			}
1910
-			if ($globalDebug) echo "Waiting...";
2682
+			if ($globalDebug) {
2683
+				echo "Waiting...";
2684
+			}
1911 2685
 			sleep(2);
1912 2686
 			$time = time();
1913 2687
 			//connect_all($hosts);
1914 2688
 			$aprs_connect = 0;
1915
-			if ($reset%5 === 0) sleep(20);
1916
-			if ($reset%10 === 0) sleep(100);
1917
-			if ($reset%20 === 0) sleep(200);
1918
-			if ($reset > 100) exit('Too many attempts...');
1919
-			if ($globalDebug) echo "Restart all connections...";
2689
+			if ($reset%5 === 0) {
2690
+				sleep(20);
2691
+			}
2692
+			if ($reset%10 === 0) {
2693
+				sleep(100);
2694
+			}
2695
+			if ($reset%20 === 0) {
2696
+				sleep(200);
2697
+			}
2698
+			if ($reset > 100) {
2699
+				exit('Too many attempts...');
2700
+			}
2701
+			if ($globalDebug) {
2702
+				echo "Restart all connections...";
2703
+			}
1920 2704
 			connect_all($globalSources);
1921 2705
 		}
1922 2706
 	    }
1923 2707
 	}
1924 2708
 	if ($globalDaemon === false) {
1925
-	    if ($globalDebug) echo 'Check all...'."\n";
1926
-	    if (isset($SI)) $SI->checkAll();
1927
-	    if (isset($TI)) $TI->checkAll();
1928
-	    if (isset($MI)) $MI->checkAll();
2709
+	    if ($globalDebug) {
2710
+	    	echo 'Check all...'."\n";
2711
+	    }
2712
+	    if (isset($SI)) {
2713
+	    	$SI->checkAll();
2714
+	    }
2715
+	    if (isset($TI)) {
2716
+	    	$TI->checkAll();
2717
+	    }
2718
+	    if (isset($MI)) {
2719
+	    	$MI->checkAll();
2720
+	    }
1929 2721
 	}
1930 2722
     }
1931 2723
 }
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	}
29 29
 
30 30
 	/**
31
-	* Add schedule data to database
32
-	* @param String $ident aircraft ident
33
-	* @param String $departure_airport_icao departure airport icao
34
-	* @param String $departure_airport_time departure airport time
35
-	* @param String $arrival_airport_icao arrival airport icao
36
-	* @param String $arrival_airport_time arrival airport time
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37 37
 	/ @param String $source source of data
38
-	*/
38
+	 */
39 39
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40 40
 		date_default_timezone_set('UTC');
41 41
 		$date = date("Y-m-d H:i:s",time());
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 		if ($sth->fetchColumn() > 0) {
53 53
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
54
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
54
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56 56
 			} elseif ($arrival_airport_time == '') {
57
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
57
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59 59
 			} elseif ($departure_airport_time == '') {
60
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
60
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62 62
 			} else {
63
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
63
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
66 66
 			}
67 67
 			try {
68 68
 				$sth = $this->db->prepare($query);
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 	*/
150 150
 	public function checkSchedule($ident) {
151 151
 		global $globalDBdriver;
152
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
-	        if ($globalDBdriver == 'mysql') {
152
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
+			if ($globalDBdriver == 'mysql') {
154 154
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
155 155
 		} else {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
157 157
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
158 158
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
159 159
 		}
160
-	        $query_values = array(':ident' => $ident);
160
+			$query_values = array(':ident' => $ident);
161 161
 		 try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute($query_values);
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Get flight info from Air France
174
-	* @param String $callsign The callsign
175
-	* @param String $date date we want flight number info
176
-	* @param String $carrier IATA code
177
-	* @return Flight departure and arrival airports and time
178
-	*/
173
+	 * Get flight info from Air France
174
+	 * @param String $callsign The callsign
175
+	 * @param String $date date we want flight number info
176
+	 * @param String $carrier IATA code
177
+	 * @return Flight departure and arrival airports and time
178
+	 */
179 179
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
180 180
 		$Common = new Common();
181 181
 		$check_date = new Datetime($date);
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Get flight info from EasyJet
215
-	* @param String $callsign The callsign
216
-	* @param String $date date we want flight number info
217
-	* @return Flight departure and arrival airports and time
218
-	*/
214
+	 * Get flight info from EasyJet
215
+	 * @param String $callsign The callsign
216
+	 * @param String $date date we want flight number info
217
+	 * @return Flight departure and arrival airports and time
218
+	 */
219 219
 	private function getEasyJet($callsign, $date = 'NOW') {
220 220
 		global $globalTimezone;
221 221
 		$Common = new Common();
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Get flight info from Ryanair
243
-	* @param String $callsign The callsign
244
-	* @return Flight departure and arrival airports and time
245
-	*/
242
+	 * Get flight info from Ryanair
243
+	 * @param String $callsign The callsign
244
+	 * @return Flight departure and arrival airports and time
245
+	 */
246 246
 	private function getRyanair($callsign) {
247 247
 		$Common = new Common();
248 248
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	/**
268
-	* Get flight info from Swiss
269
-	* @param String $callsign The callsign
270
-	* @return Flight departure and arrival airports and time
271
-	*/
268
+	 * Get flight info from Swiss
269
+	 * @param String $callsign The callsign
270
+	 * @return Flight departure and arrival airports and time
271
+	 */
272 272
 	private function getSwiss($callsign) {
273 273
 		$Common = new Common();
274 274
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 	
299 299
 	/**
300
-	* Get flight info from British Airways API
301
-	* @param String $callsign The callsign
302
-	* @param String $date date we want flight number info
303
-	* @return Flight departure and arrival airports and time
304
-	*/
300
+	 * Get flight info from British Airways API
301
+	 * @param String $callsign The callsign
302
+	 * @param String $date date we want flight number info
303
+	 * @return Flight departure and arrival airports and time
304
+	 */
305 305
 	public function getBritishAirways($callsign, $date = 'NOW') {
306 306
 		global $globalBritishAirwaysKey;
307 307
 		$Common = new Common();
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 
327 327
 	/**
328
-	* Get flight info from Lutfhansa API
329
-	* @param String $callsign The callsign
330
-	* @param String $date date we want flight number info
331
-	* @return Flight departure and arrival airports and time
332
-	*/
328
+	 * Get flight info from Lutfhansa API
329
+	 * @param String $callsign The callsign
330
+	 * @param String $date date we want flight number info
331
+	 * @return Flight departure and arrival airports and time
332
+	 */
333 333
 	public function getLufthansa($callsign, $date = 'NOW') {
334 334
 		global $globalLufthansaKey;
335 335
 		$Common = new Common();
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	/**
362
-	* Get flight info from Transavia API
363
-	* @param String $callsign The callsign
364
-	* @param String $date date we want flight number info
365
-	* @return Flight departure and arrival airports and time
366
-	*/
362
+	 * Get flight info from Transavia API
363
+	 * @param String $callsign The callsign
364
+	 * @param String $date date we want flight number info
365
+	 * @return Flight departure and arrival airports and time
366
+	 */
367 367
 	public function getTransavia($callsign, $date = 'NOW') {
368 368
 		global $globalTransaviaKey;
369 369
 		$Common = new Common();
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	}
390 390
 
391 391
 	/**
392
-	* Get flight info from Tunisair
393
-	* @param String $callsign The callsign
394
-	* @return Flight departure and arrival airports and time
395
-	*/
392
+	 * Get flight info from Tunisair
393
+	 * @param String $callsign The callsign
394
+	 * @return Flight departure and arrival airports and time
395
+	 */
396 396
 	public function getTunisair($callsign) {
397 397
 		$Common = new Common();
398 398
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	/**
412
-	* Get flight info from Vueling
413
-	* @param String $callsign The callsign
414
-	* @return Flight departure and arrival airports and time
415
-	*/
412
+	 * Get flight info from Vueling
413
+	 * @param String $callsign The callsign
414
+	 * @return Flight departure and arrival airports and time
415
+	 */
416 416
 	public function getVueling($callsign,$date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$check_date = new Datetime($date);
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	/**
437
-	* Get flight info from Iberia
438
-	* @param String $callsign The callsign
439
-	* @param String $date date we want flight number info
440
-	* @return Flight departure and arrival airports and time
441
-	*/
437
+	 * Get flight info from Iberia
438
+	 * @param String $callsign The callsign
439
+	 * @param String $date date we want flight number info
440
+	 * @return Flight departure and arrival airports and time
441
+	 */
442 442
 	public function getIberia($callsign, $date = 'NOW') {
443 443
 		$Common = new Common();
444 444
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
 	}
469 469
 
470 470
 	/**
471
-	* Get flight info from Star Alliance
472
-	* @param String $callsign The callsign
473
-	* @param String $date date we want flight number info
474
-	* @return Flight departure and arrival airports and time
475
-	*/
471
+	 * Get flight info from Star Alliance
472
+	 * @param String $callsign The callsign
473
+	 * @param String $date date we want flight number info
474
+	 * @return Flight departure and arrival airports and time
475
+	 */
476 476
 
477 477
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
478 478
 		$Common = new Common();
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 
505 505
 
506 506
 	/**
507
-	* Get flight info from Alitalia
508
-	* @param String $callsign The callsign
509
-	* @param String $date date we want flight number info
510
-	* @return Flight departure and arrival airports and time
511
-	*/
507
+	 * Get flight info from Alitalia
508
+	 * @param String $callsign The callsign
509
+	 * @param String $date date we want flight number info
510
+	 * @return Flight departure and arrival airports and time
511
+	 */
512 512
 	private function getAlitalia($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514 514
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	/**
530
-	* Get flight info from Brussels airlines
531
-	* @param String $callsign The callsign
532
-	* @param String $date date we want flight number info
533
-	* @return Flight departure and arrival airports and time
534
-	*/
530
+	 * Get flight info from Brussels airlines
531
+	 * @param String $callsign The callsign
532
+	 * @param String $date date we want flight number info
533
+	 * @return Flight departure and arrival airports and time
534
+	 */
535 535
 	private function getBrussels($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
537 537
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -541,24 +541,24 @@  discard block
 block discarded – undo
541 541
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542 542
 		$data = $Common->getData($url);
543 543
 		if ($data != '') {
544
-		    //echo $data;
545
-		    $parsed_json = json_decode($data,true);
546
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
544
+			//echo $data;
545
+			$parsed_json = json_decode($data,true);
546
+			if (isset($parsed_json[0]['FromAirportCode'])) {
547 547
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
548 548
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
549 549
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
550 550
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
551 551
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
552
-		    }
552
+			}
553 553
 		}
554 554
 	}
555 555
 
556 556
 	/**
557
-	* Get flight info from FlightRadar24
558
-	* @param String $callsign The callsign
559
-	* @param String $date date we want flight number info
560
-	* @return Flight departure and arrival airports and time
561
-	*/
557
+	 * Get flight info from FlightRadar24
558
+	 * @param String $callsign The callsign
559
+	 * @param String $date date we want flight number info
560
+	 * @return Flight departure and arrival airports and time
561
+	 */
562 562
 /*
563 563
 	public function getFlightRadar24($callsign, $date = 'NOW') {
564 564
 		$Common = new Common();
@@ -587,11 +587,11 @@  discard block
 block discarded – undo
587 587
 	}
588 588
   */
589 589
 	/**
590
-	* Get flight info from Lufthansa
591
-	* @param String $callsign The callsign
592
-	* @param String $date date we want flight number info
593
-	* @return Flight departure and arrival airports and time
594
-	*/
590
+	 * Get flight info from Lufthansa
591
+	 * @param String $callsign The callsign
592
+	 * @param String $date date we want flight number info
593
+	 * @return Flight departure and arrival airports and time
594
+	 */
595 595
 
596 596
 /*	private function getLufthansa($callsign, $date = 'NOW') {
597 597
 		$Common = new Common();
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 	}
620 620
   */
621 621
 	/**
622
-	* Get flight info from flytap
623
-	* @param String $callsign The callsign
624
-	* @return Flight departure and arrival airports and time
625
-	*/
622
+	 * Get flight info from flytap
623
+	 * @param String $callsign The callsign
624
+	 * @return Flight departure and arrival airports and time
625
+	 */
626 626
 	private function getFlyTap($callsign) {
627 627
 		$Common = new Common();
628 628
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -645,10 +645,10 @@  discard block
 block discarded – undo
645 645
 	}
646 646
 
647 647
 	/**
648
-	* Get flight info from flightmapper
649
-	* @param String $callsign The callsign
650
-	* @return Flight departure and arrival airports and time
651
-	*/
648
+	 * Get flight info from flightmapper
649
+	 * @param String $callsign The callsign
650
+	 * @return Flight departure and arrival airports and time
651
+	 */
652 652
 	public function getFlightMapper($callsign) {
653 653
 		$Common = new Common();
654 654
 		$airline_icao = '';
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 				$aarr = '';
677 677
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
678 678
 				if ($n == 7) {
679
-				    $departureTime = $dhour;
680
-				    $arrivalTime = $ahour;
681
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
679
+					$departureTime = $dhour;
680
+					$arrivalTime = $ahour;
681
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
684 684
 				}
685 685
 			}
686 686
 		}
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
 	}
689 689
 
690 690
 	/**
691
-	* Get flight info from flightaware
692
-	* @param String $callsign The callsign
693
-	* @return Flight departure and arrival airports and time
694
-	*/
691
+	 * Get flight info from flightaware
692
+	 * @param String $callsign The callsign
693
+	 * @return Flight departure and arrival airports and time
694
+	 */
695 695
 	public function getFlightAware($callsign) {
696 696
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
697 697
 		date_default_timezone_set('UTC');
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
717 717
 				if (isset($flight['origin'])) {
718 718
 					return array(
719
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
721
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
-					    'Source' => 'website_flightaware');
719
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
+						'DepartureTime' => $flight['filed_departure_time']['time'],
721
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
+						'Source' => 'website_flightaware');
724 724
 				}
725 725
 			}
726 726
 		}
@@ -733,21 +733,21 @@  discard block
 block discarded – undo
733 733
 			$flight = reset($flights['flights']);
734 734
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
735 735
 				return array(
736
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
-				    'Source' => 'website_flightaware');
736
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
+					'Source' => 'website_flightaware');
741 741
 			}
742 742
 		}
743 743
 		return array();
744 744
 	}
745 745
 
746 746
 	/**
747
-	* Get flight info from CostToTravel
748
-	* @param String $callsign The callsign
749
-	* @return Flight departure and arrival airports and time
750
-	*/
747
+	 * Get flight info from CostToTravel
748
+	 * @param String $callsign The callsign
749
+	 * @return Flight departure and arrival airports and time
750
+	 */
751 751
 	public function getCostToTravel($callsign) {
752 752
 		$Common = new Common();
753 753
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Get flight info from Air Canada
774
-	* @param String $callsign The callsign
775
-	* @param String $date date we want flight number info
776
-	* @return Flight departure and arrival airports and time
777
-	*/
773
+	 * Get flight info from Air Canada
774
+	 * @param String $callsign The callsign
775
+	 * @param String $date date we want flight number info
776
+	 * @return Flight departure and arrival airports and time
777
+	 */
778 778
 	private function getAirCanada($callsign,$date = 'NOW') {
779 779
 		$Common = new Common();
780 780
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 	}
800 800
 
801 801
 	/**
802
-	* Get flight info from Vietnam Airlines
803
-	* @param String $callsign The callsign
804
-	* @param String $date date we want flight number info
805
-	* @return Flight departure and arrival airports and time
806
-	*/
802
+	 * Get flight info from Vietnam Airlines
803
+	 * @param String $callsign The callsign
804
+	 * @param String $date date we want flight number info
805
+	 * @return Flight departure and arrival airports and time
806
+	 */
807 807
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
808 808
 		$Common = new Common();
809 809
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -825,12 +825,12 @@  discard block
 block discarded – undo
825 825
 	}
826 826
 
827 827
 	/**
828
-	* Get flight info from Air Berlin
829
-	* @param String $callsign The callsign
830
-	* @param String $date date we want flight number info
831
-	* @param String $carrier airline code
832
-	* @return Flight departure and arrival airports and time
833
-	*/
828
+	 * Get flight info from Air Berlin
829
+	 * @param String $callsign The callsign
830
+	 * @param String $date date we want flight number info
831
+	 * @param String $carrier airline code
832
+	 * @return Flight departure and arrival airports and time
833
+	 */
834 834
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
835 835
 		$Common = new Common();
836 836
 		date_default_timezone_set('UTC');
@@ -859,11 +859,11 @@  discard block
 block discarded – undo
859 859
 			$table = $Common->table2array($data);
860 860
 			$flight = $table;
861 861
 			if (isset($flight[5][4])) {
862
-			    $arrivalTime = $flight[5][4];
863
-			    $arrivalAirport = $flight[5][3];
862
+				$arrivalTime = $flight[5][4];
863
+				$arrivalAirport = $flight[5][3];
864 864
 			} else {
865
-			    $arrivalTime = '';
866
-			    $arrivalAirport = '';
865
+				$arrivalTime = '';
866
+				$arrivalAirport = '';
867 867
 			}
868 868
 		} else return array();
869 869
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	* @param String $arrival_airport_time arrival airport time
37 37
 	/ @param String $source source of data
38 38
 	*/
39
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
39
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
40 40
 		date_default_timezone_set('UTC');
41
-		$date = date("Y-m-d H:i:s",time());
41
+		$date = date("Y-m-d H:i:s", time());
42 42
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
43 43
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
44 44
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -46,69 +46,69 @@  discard block
 block discarded – undo
46 46
 		 try {
47 47
 			$sth = $this->db->prepare($query);
48 48
 			$sth->execute($query_values);
49
-		} catch(PDOException $e) {
49
+		} catch (PDOException $e) {
50 50
 			return "error : ".$e->getMessage();
51 51
 		}
52 52
 		if ($sth->fetchColumn() > 0) {
53 53
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
54 54
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
56 56
 			} elseif ($arrival_airport_time == '') {
57 57
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
59 59
 			} elseif ($departure_airport_time == '') {
60 60
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
62 62
 			} else {
63 63
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64 64
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
65
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
66 66
 			}
67 67
 			try {
68 68
 				$sth = $this->db->prepare($query);
69 69
 				$sth->execute($query_values);
70
-			} catch(PDOException $e) {
70
+			} catch (PDOException $e) {
71 71
 				return "error : ".$e->getMessage();
72 72
 			}
73 73
 			if ($sth->fetchColumn() == 0) {
74 74
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
75 75
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
76 76
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
77
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
77
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
78 78
 				} elseif ($arrival_airport_time == '') {
79 79
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
80
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
80
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
81 81
 				} elseif ($departure_airport_time == '') {
82 82
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
83
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
83
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
84 84
 				} else {
85 85
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
86
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
86
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
87 87
 				}
88 88
 				try {
89 89
 					$sth = $this->db->prepare($query);
90 90
 					$sth->execute($query_values);
91
-				} catch(PDOException $e) {
91
+				} catch (PDOException $e) {
92 92
 					return "error : ".$e->getMessage();
93 93
 				}
94 94
 			} else {
95 95
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
96 96
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
97
-				$query_values = array(':ident' => $ident,':date' => $date);
97
+				$query_values = array(':ident' => $ident, ':date' => $date);
98 98
 				try {
99 99
 					$sth = $this->db->prepare($query);
100 100
 					$sth->execute($query_values);
101
-				} catch(PDOException $e) {
101
+				} catch (PDOException $e) {
102 102
 					return "error : ".$e->getMessage();
103 103
 				}
104 104
 			}
105 105
 		} else {
106 106
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
107
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
107
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
108 108
 			 try {
109 109
 				$sth = $this->db->prepare($query);
110 110
 				$sth->execute($query_values);
111
-			} catch(PDOException $e) {
111
+			} catch (PDOException $e) {
112 112
 				return "error : ".$e->getMessage();
113 113
 			}
114 114
 		}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	*/
122 122
 	public function getSchedule($ident) {
123 123
 		$Translation = new Translation($this->db);
124
-		$operator = $Translation->checkTranslation($ident,false);
124
+		$operator = $Translation->checkTranslation($ident, false);
125 125
 		if ($ident != $operator) {
126 126
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
127
-			$query_values = array(':ident' => $ident,'operator' => $operator);
127
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
128 128
 		} else {
129 129
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
130 130
 			$query_values = array(':ident' => $ident);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		 try {
133 133
 			$sth = $this->db->prepare($query);
134 134
 			$sth->execute($query_values);
135
-		} catch(PDOException $e) {
135
+		} catch (PDOException $e) {
136 136
 			return "error : ".$e->getMessage();
137 137
 		}
138 138
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute($query_values);
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			return "error : ".$e->getMessage();
166 166
 		}
167 167
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	* @param String $carrier IATA code
177 177
 	* @return Flight departure and arrival airports and time
178 178
 	*/
179
-	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
179
+	public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
180 180
 		$Common = new Common();
181 181
 		$check_date = new Datetime($date);
182
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
182
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
183
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
184 184
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 185
 		$json = $Common->getData($url);
186 186
 		var_dump($json);
187 187
 		$parsed_json = json_decode($json);
188
-		if (property_exists($parsed_json,'errors') === false) {
188
+		if (property_exists($parsed_json, 'errors') === false) {
189 189
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
190 190
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
191 191
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
196 196
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
197 197
 
198
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
198
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
199 199
 			$DepartureAirportIata = $originiata[1];
200
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
200
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
201 201
 			$ArrivalAirportIata = $destinationiata[1];
202 202
 
203 203
 			/*
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
207 207
 			*/
208 208
 		
209
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
209
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
210 210
 		} else return array();
211 211
 	}
212 212
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		$Common = new Common();
222 222
 		date_default_timezone_set($globalTimezone);
223 223
 		$check_date = new Datetime($date);
224
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
224
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
225
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
226 226
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 227
 		$json = $Common->getData($url);
228 228
 		$parsed_json = json_decode($json);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
235 235
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 236
 
237
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
237
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
238 238
 		} else return array();
239 239
 	}
240 240
 
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 	*/
246 246
 	private function getRyanair($callsign) {
247 247
 		$Common = new Common();
248
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
248
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
249
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
250 250
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 251
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
253
-		$json = $Common->getData($url,'post',$post,$headers);
252
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
253
+		$json = $Common->getData($url, 'post', $post, $headers);
254 254
 		$parsed_json = json_decode($json);
255 255
 		if (isset($parsed_json->{'flightInfo'})) {
256 256
 			$flights = $parsed_json->{'flightInfo'};
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
260 260
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 261
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
262
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263 263
 			} else return array();
264 264
 		} else return array();
265 265
 	}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	*/
272 272
 	private function getSwiss($callsign) {
273 273
 		$Common = new Common();
274
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
274
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
275
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
276 276
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 277
 		$json = $Common->getData($url);
278 278
 		$parsed_json = json_decode($json);
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
287 287
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
288 288
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
289
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
290
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
289
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
290
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
291 291
 				}
292 292
 			}
293 293
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
294
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
295 295
 			} else return array();
296 296
 		} else return array();
297 297
 	}
@@ -306,21 +306,21 @@  discard block
 block discarded – undo
306 306
 		global $globalBritishAirwaysKey;
307 307
 		$Common = new Common();
308 308
 		$check_date = new Datetime($date);
309
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
309
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
310
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
311 311
 		if ($globalBritishAirwaysKey == '') return array();
312 312
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 313
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314
-		$json = $Common->getData($url,'get','',$headers);
314
+		$json = $Common->getData($url, 'get', '', $headers);
315 315
 		if ($json == '') return array();
316 316
 		$parsed_json = json_decode($json);
317 317
 		$flights = $parsed_json->{'FlightsResponse'};
318 318
 		if (count($flights) > 0) {
319 319
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
320 320
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
321
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
321
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
324 324
 		} else return array();
325 325
 	}
326 326
 
@@ -334,27 +334,27 @@  discard block
 block discarded – undo
334 334
 		global $globalLufthansaKey;
335 335
 		$Common = new Common();
336 336
 		$check_date = new Datetime($date);
337
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
337
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
338
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
339 339
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
340 340
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342
-		$data = $Common->getData($url,'post',$post);
341
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
342
+		$data = $Common->getData($url, 'post', $post);
343 343
 		$parsed_data = json_decode($data);
344 344
 		if (!isset($parsed_data->{'access_token'})) return array();
345 345
 		$token = $parsed_data->{'access_token'};
346 346
 		
347 347
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349
-		$json = $Common->getData($url,'get','',$headers);
348
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
349
+		$json = $Common->getData($url, 'get', '', $headers);
350 350
 		if ($json == '') return array();
351 351
 		$parsed_json = json_decode($json);
352 352
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 353
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
354
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
354
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
355 355
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
356
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
358 358
 		} else return array();
359 359
 	}
360 360
 
@@ -368,23 +368,23 @@  discard block
 block discarded – undo
368 368
 		global $globalTransaviaKey;
369 369
 		$Common = new Common();
370 370
 		$check_date = new Datetime($date);
371
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
371
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
372
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
373 373
 		if ($globalTransaviaKey == '') return array();
374 374
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 375
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 376
 		$headers = array('apikey: '.$globalTransaviaKey);
377
-		$json = $Common->getData($url,'get','',$headers);
377
+		$json = $Common->getData($url, 'get', '', $headers);
378 378
 		//echo 'result : '.$json;
379 379
 		if ($json == '') return array();
380 380
 		$parsed_json = json_decode($json);
381 381
 		
382 382
 		if (isset($parsed_json->{'data'}[0])) {
383 383
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
384
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
384
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
385 385
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
386
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
388 388
 		} else return array();
389 389
 	}
390 390
 
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 	*/
396 396
 	public function getTunisair($callsign) {
397 397
 		$Common = new Common();
398
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
398
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
399
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
400 400
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 401
 		$data = $Common->getData($url);
402 402
 		$table = $Common->table2array($data);
403 403
 		foreach ($table as $flight) {
404
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
405
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
404
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
405
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
406 406
 			}
407 407
 		}
408 408
 		return array();
@@ -413,21 +413,21 @@  discard block
 block discarded – undo
413 413
 	* @param String $callsign The callsign
414 414
 	* @return Flight departure and arrival airports and time
415 415
 	*/
416
-	public function getVueling($callsign,$date = 'NOW') {
416
+	public function getVueling($callsign, $date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$check_date = new Datetime($date);
419
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
421
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
419
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
420
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
421
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
422 422
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 423
 		$data = $Common->getData($url);
424
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
424
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
425 425
 		if ($data != '') {
426
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
427
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
426
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
427
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
428
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
429
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
430
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
431 431
 			else return array();
432 432
 		}
433 433
 		return array();
@@ -441,27 +441,27 @@  discard block
 block discarded – undo
441 441
 	*/
442 442
 	public function getIberia($callsign, $date = 'NOW') {
443 443
 		$Common = new Common();
444
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
444
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
445 445
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
446
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
447 447
 		$url = "https://www.iberia.com/web/flightDetail.do";
448
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449
-		$data = $Common->getData($url,'post',$post);
448
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
449
+		$data = $Common->getData($url, 'post', $post);
450 450
 		if ($data != '') {
451 451
 			$table = $Common->table2array($data);
452 452
 			//print_r($table);
453 453
 			if (count($table) > 0) {
454 454
 				$flight = $table;
455
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
456
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
455
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
456
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
457 457
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
458 458
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
459
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
460
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
459
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
460
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
461 461
 				if ($arrivalTime == 'Hora estimada de llegada') {
462
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
464
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
462
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
463
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
464
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
465 465
 			}
466 466
 		}
467 467
 		return array();
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	* @return Flight departure and arrival airports and time
475 475
 	*/
476 476
 
477
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
477
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
478 478
 		$Common = new Common();
479
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
479
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
480 480
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
481
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
482 482
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 483
 		$data = $Common->getData($url);
484 484
 		if ($data != '') {
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 				$flight = $table;
488 488
 				//print_r($table);
489 489
 				if (isset($flight[25]) && isset($flight[29])) {
490
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
491
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
490
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
491
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
492 492
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
493 493
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
494
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
494
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
495
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
496
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
497 497
 				} else return array();
498 498
 			}
499 499
 			
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 	*/
512 512
 	private function getAlitalia($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
514
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
515 515
 		$check_date = new Datetime($date);
516
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
516
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
518 518
 		$data = $Common->getData($url);
519 519
 		if ($data != '') {
520 520
 			$table = $Common->text2array($data);
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			$ArrivalAirportIata = '';
523 523
 			$departureTime = $table[4];
524 524
 			$arrivalTime = $table[5];
525
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
525
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
526 526
 		}
527 527
 	}
528 528
 
@@ -534,21 +534,21 @@  discard block
 block discarded – undo
534 534
 	*/
535 535
 	private function getBrussels($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
537
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
537
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
538 538
 		$check_date = new Datetime($date);
539
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
539
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 540
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
541
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
542 542
 		$data = $Common->getData($url);
543 543
 		if ($data != '') {
544 544
 		    //echo $data;
545
-		    $parsed_json = json_decode($data,true);
545
+		    $parsed_json = json_decode($data, true);
546 546
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
547 547
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
548 548
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
549
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
550
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
551
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
549
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
550
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
551
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
552 552
 		    }
553 553
 		}
554 554
 	}
@@ -625,21 +625,21 @@  discard block
 block discarded – undo
625 625
 	*/
626 626
 	private function getFlyTap($callsign) {
627 627
 		$Common = new Common();
628
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
628
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
629
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 630
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
632
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633
-		$data = $Common->getData($url,'post',$post);
631
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
632
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
633
+		$data = $Common->getData($url, 'post', $post);
634 634
 		if ($data != '') {
635 635
 			$table = $Common->table2array($data);
636
-			$departureTime = trim(substr($table[15][0],0,5));
637
-			$arrivalTime = trim(substr($table[35][0],0,5));
638
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
639
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
636
+			$departureTime = trim(substr($table[15][0], 0, 5));
637
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
638
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
639
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
640 640
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
641 641
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
642
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
642
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
643 643
 		}
644 644
 		return array();
645 645
 	}
@@ -661,10 +661,10 @@  discard block
 block discarded – undo
661 661
 			} 
662 662
 		}
663 663
 		if ($airline_icao == '') return array();
664
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
664
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
665
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 666
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
667
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
668 668
 		$data = $Common->getData($url);
669 669
 		if ($data != '') {
670 670
 			$table = $Common->table2array($data);
@@ -674,13 +674,13 @@  discard block
 block discarded – undo
674 674
 				$darr = '';
675 675
 				$ahour = '';
676 676
 				$aarr = '';
677
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
677
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
678 678
 				if ($n == 7) {
679 679
 				    $departureTime = $dhour;
680 680
 				    $arrivalTime = $ahour;
681
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
681
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
682
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
683
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
684 684
 				}
685 685
 			}
686 686
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
713 713
 			$data = $Common->getData($url);
714 714
 			if ($data != '') {
715
-				$result = json_decode($data,true);
715
+				$result = json_decode($data, true);
716 716
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
717 717
 				if (isset($flight['origin'])) {
718 718
 					return array(
@@ -725,18 +725,18 @@  discard block
 block discarded – undo
725 725
 			}
726 726
 		}
727 727
 		
728
-		$url= "http://flightaware.com/live/flight/".$callsign;
728
+		$url = "http://flightaware.com/live/flight/".$callsign;
729 729
 		$data = $Common->getData($url);
730 730
 		if ($data != '') {
731
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
732
-			$flights = json_decode($result[1],true);
731
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
732
+			$flights = json_decode($result[1], true);
733 733
 			$flight = reset($flights['flights']);
734 734
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
735 735
 				return array(
736 736
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738 738
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740 740
 				    'Source' => 'website_flightaware');
741 741
 			}
742 742
 		}
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
 	*/
751 751
 	public function getCostToTravel($callsign) {
752 752
 		$Common = new Common();
753
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
753
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
754 754
 		//$check_date = new Datetime($date);
755 755
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
756 756
 		$data = $Common->getData($url);
757 757
 		if ($data != '') {
758 758
 			$table = $Common->table2array($data);
759 759
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
760
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
761 761
 				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
762
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
763 763
 				else $arrivalTime = '';
764
-				$DepartureAirportIata = substr($table[13][1],0,3);
765
-				$ArrivalAirportIata = substr($table[15][1],0,3);
766
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
764
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
765
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
766
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
767 767
 			}
768 768
 		}
769 769
 		return array();
@@ -775,14 +775,14 @@  discard block
 block discarded – undo
775 775
 	* @param String $date date we want flight number info
776 776
 	* @return Flight departure and arrival airports and time
777 777
 	*/
778
-	private function getAirCanada($callsign,$date = 'NOW') {
778
+	private function getAirCanada($callsign, $date = 'NOW') {
779 779
 		$Common = new Common();
780 780
 		if (class_exists("DomDocument") === FALSE) return array();
781 781
 		date_default_timezone_set('UTC');
782 782
 		$check_date = new Datetime($date);
783
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
783
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
784
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
786 786
 		$data = $Common->getData($url);
787 787
 		$dom = new DomDocument();
788 788
 		$dom->loadXML($data);
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 791
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 792
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
793
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
793
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
794 794
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
795 795
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
796
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
798 798
 		} else return array();
799 799
 	}
800 800
 
@@ -806,21 +806,21 @@  discard block
 block discarded – undo
806 806
 	*/
807 807
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
808 808
 		$Common = new Common();
809
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
809
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
810 810
 		$check_date = new Datetime($date);
811
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
811
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
813 813
 		$data = $Common->getData($url);
814 814
 		if ($data != '') {
815 815
 			$table = $Common->table2array($data);
816 816
 			$flight = $table;
817
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
818
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
817
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
818
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
819 819
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
820 820
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
821 821
 			$departureTime = $flight[5][1];
822 822
 			$arrivalTime = $flight[23][1];
823
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
823
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
824 824
 		}
825 825
 	}
826 826
 
@@ -831,16 +831,16 @@  discard block
 block discarded – undo
831 831
 	* @param String $carrier airline code
832 832
 	* @return Flight departure and arrival airports and time
833 833
 	*/
834
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
834
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
835 835
 		$Common = new Common();
836 836
 		date_default_timezone_set('UTC');
837 837
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
838
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
838
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
839 839
 		$check_date = new Datetime($date);
840
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
842
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843
-		$data = $Common->getData($url,'post',$post);
840
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
841
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
842
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
843
+		$data = $Common->getData($url, 'post', $post);
844 844
 		//echo $data;
845 845
 		$DepartureAirportIata = '';
846 846
 		$ArrivalAirportIata = '';
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854 854
 			else $departureAirport = '';
855 855
 		} else return array();
856
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857
-		$data = $Common->getData($url,'post',$post);
856
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
857
+		$data = $Common->getData($url, 'post', $post);
858 858
 		if ($data != '') {
859 859
 			$table = $Common->table2array($data);
860 860
 			$flight = $table;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			}
883 883
 		}
884 884
 		if (isset($DepartureAirportIata)) {
885
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
885
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
886 886
 		} else return array();
887 887
 	}
888 888
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 * @param String $date Date
893 893
 	 * @return Array Schedules info
894 894
 	*/
895
-	public function fetchSchedule($ident,$date = 'NOW') {
895
+	public function fetchSchedule($ident, $date = 'NOW') {
896 896
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 897
 		//$Common = new Common();
898 898
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 				// Brussels Airlines
963 963
 				case "BEL":
964 964
 				case "SN":
965
-					return $this->getBrussels($ident,$date);
965
+					return $this->getBrussels($ident, $date);
966 966
 /*
967 967
 				// Copa Airlines
968 968
 				case "CMP":
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 				case "DS":
1062 1062
 				case "EZY":
1063 1063
 				case "EZS":
1064
-					return $this->getEasyJet($ident,$date);
1064
+					return $this->getEasyJet($ident, $date);
1065 1065
 				// Ryanair
1066 1066
 				case "FR":
1067 1067
 				case "RYR":
@@ -1113,19 +1113,19 @@  discard block
 block discarded – undo
1113 1113
 					return $this->getIberia($ident);
1114 1114
 				// Vietnam Airlines
1115 1115
 				case "HVN":
1116
-					return $this->getVietnamAirlines($ident,$date);
1116
+					return $this->getVietnamAirlines($ident, $date);
1117 1117
 				// Air Berlin
1118 1118
 				case "AB":
1119 1119
 				case "BER":
1120
-					return $this->getAirBerlin($ident,$date,'AB');
1120
+					return $this->getAirBerlin($ident, $date, 'AB');
1121 1121
 				// NIKI
1122 1122
 				case "HG":
1123 1123
 				case "NLY":
1124
-					return $this->getAirBerlin($ident,$date,'HG');
1124
+					return $this->getAirBerlin($ident, $date, 'HG');
1125 1125
 				// BelAir
1126 1126
 				case "4T":
1127 1127
 				case "BHP":
1128
-					return $this->getAirBerlin($ident,$date,'4T');
1128
+					return $this->getAirBerlin($ident, $date, '4T');
1129 1129
 				default:
1130 1130
 					if (strlen($airline_icao) == 3) {
1131 1131
 						$Spotter = new Spotter($this->db);
@@ -1134,9 +1134,9 @@  discard block
 block discarded – undo
1134 1134
 					}
1135 1135
 					// Randomly use a generic function to get hours
1136 1136
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1137
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware');
1138 1138
 						if (count($globalSchedulesSources) > 0) {
1139
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1139
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1140 1140
 							$source = $globalSchedulesSources[$rand];
1141 1141
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142 1142
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
 	/**
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 		$sth->closeCursor();
140 142
 		if (count($row) > 0) {
141 143
 			return $row;
142
-		} else return array();
144
+		} else {
145
+			return array();
146
+		}
143 147
 	}
144 148
 
145 149
 	/*
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
 		$Common = new Common();
181 185
 		$check_date = new Datetime($date);
182 186
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
187
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
188
+			return array();
189
+		}
184 190
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 191
 		$json = $Common->getData($url);
186 192
 		var_dump($json);
@@ -207,7 +213,9 @@  discard block
 block discarded – undo
207 213
 			*/
208 214
 		
209 215
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
210
-		} else return array();
216
+		} else {
217
+			return array();
218
+		}
211 219
 	}
212 220
 
213 221
 	/**
@@ -222,7 +230,9 @@  discard block
 block discarded – undo
222 230
 		date_default_timezone_set($globalTimezone);
223 231
 		$check_date = new Datetime($date);
224 232
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
233
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
234
+			return array();
235
+		}
226 236
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 237
 		$json = $Common->getData($url);
228 238
 		$parsed_json = json_decode($json);
@@ -235,7 +245,9 @@  discard block
 block discarded – undo
235 245
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 246
 
237 247
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
238
-		} else return array();
248
+		} else {
249
+			return array();
250
+		}
239 251
 	}
240 252
 
241 253
 	/**
@@ -246,7 +258,9 @@  discard block
 block discarded – undo
246 258
 	private function getRyanair($callsign) {
247 259
 		$Common = new Common();
248 260
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
261
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
262
+			return array();
263
+		}
250 264
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 265
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252 266
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -260,8 +274,12 @@  discard block
 block discarded – undo
260 274
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 275
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262 276
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263
-			} else return array();
264
-		} else return array();
277
+			} else {
278
+				return array();
279
+			}
280
+		} else {
281
+			return array();
282
+		}
265 283
 	}
266 284
 
267 285
 	/**
@@ -272,7 +290,9 @@  discard block
 block discarded – undo
272 290
 	private function getSwiss($callsign) {
273 291
 		$Common = new Common();
274 292
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
293
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
294
+			return array();
295
+		}
276 296
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 297
 		$json = $Common->getData($url);
278 298
 		$parsed_json = json_decode($json);
@@ -292,8 +312,12 @@  discard block
 block discarded – undo
292 312
 			}
293 313
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294 314
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
295
-			} else return array();
296
-		} else return array();
315
+			} else {
316
+				return array();
317
+			}
318
+		} else {
319
+			return array();
320
+		}
297 321
 	}
298 322
 	
299 323
 	/**
@@ -307,12 +331,18 @@  discard block
 block discarded – undo
307 331
 		$Common = new Common();
308 332
 		$check_date = new Datetime($date);
309 333
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
-		if ($globalBritishAirwaysKey == '') return array();
334
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
335
+			return array();
336
+		}
337
+		if ($globalBritishAirwaysKey == '') {
338
+			return array();
339
+		}
312 340
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 341
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314 342
 		$json = $Common->getData($url,'get','',$headers);
315
-		if ($json == '') return array();
343
+		if ($json == '') {
344
+			return array();
345
+		}
316 346
 		$parsed_json = json_decode($json);
317 347
 		$flights = $parsed_json->{'FlightsResponse'};
318 348
 		if (count($flights) > 0) {
@@ -321,7 +351,9 @@  discard block
 block discarded – undo
321 351
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322 352
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323 353
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
324
-		} else return array();
354
+		} else {
355
+			return array();
356
+		}
325 357
 	}
326 358
 
327 359
 	/**
@@ -335,19 +367,27 @@  discard block
 block discarded – undo
335 367
 		$Common = new Common();
336 368
 		$check_date = new Datetime($date);
337 369
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
370
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
371
+			return array();
372
+		}
373
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
374
+			return array();
375
+		}
340 376
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341 377
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342 378
 		$data = $Common->getData($url,'post',$post);
343 379
 		$parsed_data = json_decode($data);
344
-		if (!isset($parsed_data->{'access_token'})) return array();
380
+		if (!isset($parsed_data->{'access_token'})) {
381
+			return array();
382
+		}
345 383
 		$token = $parsed_data->{'access_token'};
346 384
 		
347 385
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348 386
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349 387
 		$json = $Common->getData($url,'get','',$headers);
350
-		if ($json == '') return array();
388
+		if ($json == '') {
389
+			return array();
390
+		}
351 391
 		$parsed_json = json_decode($json);
352 392
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 393
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -355,7 +395,9 @@  discard block
 block discarded – undo
355 395
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356 396
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 397
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
-		} else return array();
398
+		} else {
399
+			return array();
400
+		}
359 401
 	}
360 402
 
361 403
 	/**
@@ -369,14 +411,20 @@  discard block
 block discarded – undo
369 411
 		$Common = new Common();
370 412
 		$check_date = new Datetime($date);
371 413
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
-		if ($globalTransaviaKey == '') return array();
414
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
415
+			return array();
416
+		}
417
+		if ($globalTransaviaKey == '') {
418
+			return array();
419
+		}
374 420
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 421
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 422
 		$headers = array('apikey: '.$globalTransaviaKey);
377 423
 		$json = $Common->getData($url,'get','',$headers);
378 424
 		//echo 'result : '.$json;
379
-		if ($json == '') return array();
425
+		if ($json == '') {
426
+			return array();
427
+		}
380 428
 		$parsed_json = json_decode($json);
381 429
 		
382 430
 		if (isset($parsed_json->{'data'}[0])) {
@@ -385,7 +433,9 @@  discard block
 block discarded – undo
385 433
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386 434
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387 435
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
-		} else return array();
436
+		} else {
437
+			return array();
438
+		}
389 439
 	}
390 440
 
391 441
 	/**
@@ -396,7 +446,9 @@  discard block
 block discarded – undo
396 446
 	public function getTunisair($callsign) {
397 447
 		$Common = new Common();
398 448
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
450
+			return array();
451
+		}
400 452
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 453
 		$data = $Common->getData($url);
402 454
 		$table = $Common->table2array($data);
@@ -417,7 +469,9 @@  discard block
 block discarded – undo
417 469
 		$Common = new Common();
418 470
 		$check_date = new Datetime($date);
419 471
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
472
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
473
+			return array();
474
+		}
421 475
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422 476
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 477
 		$data = $Common->getData($url);
@@ -427,8 +481,11 @@  discard block
 block discarded – undo
427 481
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428 482
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429 483
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
431
-			else return array();
484
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
485
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
486
+			} else {
487
+				return array();
488
+			}
432 489
 		}
433 490
 		return array();
434 491
 	}
@@ -443,7 +500,9 @@  discard block
 block discarded – undo
443 500
 		$Common = new Common();
444 501
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
445 502
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
503
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
504
+			return array();
505
+		}
447 506
 		$url = "https://www.iberia.com/web/flightDetail.do";
448 507
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449 508
 		$data = $Common->getData($url,'post',$post);
@@ -460,7 +519,9 @@  discard block
 block discarded – undo
460 519
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
461 520
 				if ($arrivalTime == 'Hora estimada de llegada') {
462 521
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
522
+				} else {
523
+					$arrivalTime = substr($arrivalTime,0,5);
524
+				}
464 525
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465 526
 			}
466 527
 		}
@@ -478,7 +539,9 @@  discard block
 block discarded – undo
478 539
 		$Common = new Common();
479 540
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
480 541
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
543
+			return array();
544
+		}
482 545
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 546
 		$data = $Common->getData($url);
484 547
 		if ($data != '') {
@@ -494,7 +557,9 @@  discard block
 block discarded – undo
494 557
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495 558
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496 559
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
497
-				} else return array();
560
+				} else {
561
+					return array();
562
+				}
498 563
 			}
499 564
 			
500 565
 
@@ -514,7 +579,9 @@  discard block
 block discarded – undo
514 579
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
515 580
 		$check_date = new Datetime($date);
516 581
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
582
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
583
+			return array();
584
+		}
518 585
 		$data = $Common->getData($url);
519 586
 		if ($data != '') {
520 587
 			$table = $Common->text2array($data);
@@ -538,7 +605,9 @@  discard block
 block discarded – undo
538 605
 		$check_date = new Datetime($date);
539 606
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 607
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
608
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
609
+			return array();
610
+		}
542 611
 		$data = $Common->getData($url);
543 612
 		if ($data != '') {
544 613
 		    //echo $data;
@@ -628,7 +697,9 @@  discard block
 block discarded – undo
628 697
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629 698
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 699
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
700
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
701
+			return array();
702
+		}
632 703
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633 704
 		$data = $Common->getData($url,'post',$post);
634 705
 		if ($data != '') {
@@ -660,11 +731,15 @@  discard block
 block discarded – undo
660 731
 				$airline_icao = substr($callsign, 0, 3);
661 732
 			} 
662 733
 		}
663
-		if ($airline_icao == '') return array();
734
+		if ($airline_icao == '') {
735
+			return array();
736
+		}
664 737
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665 738
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 739
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
740
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
741
+			return array();
742
+		}
668 743
 		$data = $Common->getData($url);
669 744
 		if ($data != '') {
670 745
 			$table = $Common->table2array($data);
@@ -757,10 +832,16 @@  discard block
 block discarded – undo
757 832
 		if ($data != '') {
758 833
 			$table = $Common->table2array($data);
759 834
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
761
-				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
763
-				else $arrivalTime = '';
835
+				if (is_numeric(substr($table[11][1],0,1))) {
836
+					$departureTime = substr($table[11][1],0,5);
837
+				} else {
838
+					$departureTime = '';
839
+				}
840
+				if (is_numeric(substr($table[17][1],0,1))) {
841
+					$arrivalTime = substr($table[17][1],0,5);
842
+				} else {
843
+					$arrivalTime = '';
844
+				}
764 845
 				$DepartureAirportIata = substr($table[13][1],0,3);
765 846
 				$ArrivalAirportIata = substr($table[15][1],0,3);
766 847
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -777,16 +858,22 @@  discard block
 block discarded – undo
777 858
 	*/
778 859
 	private function getAirCanada($callsign,$date = 'NOW') {
779 860
 		$Common = new Common();
780
-		if (class_exists("DomDocument") === FALSE) return array();
861
+		if (class_exists("DomDocument") === FALSE) {
862
+			return array();
863
+		}
781 864
 		date_default_timezone_set('UTC');
782 865
 		$check_date = new Datetime($date);
783 866
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784 867
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
868
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
869
+			return array();
870
+		}
786 871
 		$data = $Common->getData($url);
787 872
 		$dom = new DomDocument();
788 873
 		$dom->loadXML($data);
789
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
874
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
875
+			return array();
876
+		}
790 877
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 878
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 879
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -795,7 +882,9 @@  discard block
 block discarded – undo
795 882
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796 883
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797 884
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
798
-		} else return array();
885
+		} else {
886
+			return array();
887
+		}
799 888
 	}
800 889
 
801 890
 	/**
@@ -809,7 +898,9 @@  discard block
 block discarded – undo
809 898
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
810 899
 		$check_date = new Datetime($date);
811 900
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
901
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
902
+			return array();
903
+		}
813 904
 		$data = $Common->getData($url);
814 905
 		if ($data != '') {
815 906
 			$table = $Common->table2array($data);
@@ -838,7 +929,9 @@  discard block
 block discarded – undo
838 929
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
839 930
 		$check_date = new Datetime($date);
840 931
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
932
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
933
+			return array();
934
+		}
842 935
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843 936
 		$data = $Common->getData($url,'post',$post);
844 937
 		//echo $data;
@@ -848,11 +941,19 @@  discard block
 block discarded – undo
848 941
 		if ($data != '') {
849 942
 			$table = $Common->table2array($data);
850 943
 			$flight = $table;
851
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
852
-			else $departureTime = '';
853
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854
-			else $departureAirport = '';
855
-		} else return array();
944
+			if (isset($flight[5][4])) {
945
+				$departureTime = $flight[5][4];
946
+			} else {
947
+				$departureTime = '';
948
+			}
949
+			if (isset($flight[5][2])) {
950
+				$departureAirport = $flight[5][2];
951
+			} else {
952
+				$departureAirport = '';
953
+			}
954
+		} else {
955
+			return array();
956
+		}
856 957
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857 958
 		$data = $Common->getData($url,'post',$post);
858 959
 		if ($data != '') {
@@ -865,10 +966,14 @@  discard block
 block discarded – undo
865 966
 			    $arrivalTime = '';
866 967
 			    $arrivalAirport = '';
867 968
 			}
868
-		} else return array();
969
+		} else {
970
+			return array();
971
+		}
869 972
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
870 973
 		$json = $Common->getData($url);
871
-		if ($json == '') return array();
974
+		if ($json == '') {
975
+			return array();
976
+		}
872 977
 		$parsed_json = json_decode($json);
873 978
 		$airports = $parsed_json->{'suggestList'};
874 979
 		if (count($airports) > 0) {
@@ -883,7 +988,9 @@  discard block
 block discarded – undo
883 988
 		}
884 989
 		if (isset($DepartureAirportIata)) {
885 990
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
886
-		} else return array();
991
+		} else {
992
+			return array();
993
+		}
887 994
 	}
888 995
 
889 996
 	/*
@@ -895,7 +1002,9 @@  discard block
 block discarded – undo
895 1002
 	public function fetchSchedule($ident,$date = 'NOW') {
896 1003
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 1004
 		//$Common = new Common();
898
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1005
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1006
+			return array();
1007
+		}
899 1008
 		$airline_icao = '';
900 1009
 		if (!is_numeric(substr($ident, 0, 3)))
901 1010
 		{
@@ -1130,18 +1239,27 @@  discard block
 block discarded – undo
1130 1239
 					if (strlen($airline_icao) == 3) {
1131 1240
 						$Spotter = new Spotter($this->db);
1132 1241
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1133
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1242
+						if (isset($airline_info[0]['iata'])) {
1243
+							$airline_icao = $airline_info[0]['iata'];
1244
+						}
1134 1245
 					}
1135 1246
 					// Randomly use a generic function to get hours
1136 1247
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1248
+						if (!isset($globalSchedulesSources)) {
1249
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1250
+						}
1138 1251
 						if (count($globalSchedulesSources) > 0) {
1139 1252
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1140 1253
 							$source = $globalSchedulesSources[$rand];
1141
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1254
+							if ($source == 'flightmapper') {
1255
+								return $this->getFlightMapper($ident);
1256
+							} elseif ($source == 'costtotravel') {
1257
+								return $this->getCostToTravel($ident);
1258
+							}
1143 1259
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1144
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1260
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1261
+								return $this->getFlightAware($ident);
1262
+							}
1145 1263
 						}
1146 1264
 					}
1147 1265
 			}
Please login to merge, or discard this patch.