Completed
Push — master ( 9752bc...3a4b32 )
by Yannick
09:31
created
require/class.TrackerImport.php 1 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']."!!!";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,73 +197,73 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
221
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
222
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
221
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
222
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
223 223
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
224 224
 		    }
225 225
 		}
226 226
 		if (isset($line['last_update']) && $line['last_update'] != '') {
227 227
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
228
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
229 229
 		}
230 230
 		if (isset($line['format_source']) && $line['format_source'] != '') {
231
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
231
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
232 232
 		}
233 233
 		if (isset($line['source_name']) && $line['source_name'] != '') {
234
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
234
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
235 235
 		}
236 236
 		if (isset($line['comment']) && $line['comment'] != '') {
237
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
237
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
238 238
 		    //$dataFound = true;
239 239
 		}
240 240
 		if (isset($line['type']) && $line['type'] != '') {
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
241
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
242 242
 		    //$dataFound = true;
243 243
 		}
244 244
 
245 245
 		if (isset($line['altitude']) && $line['altitude'] != '') {
246 246
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
247
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
248
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
249
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
247
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
248
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100)));
249
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
250 250
 			//$dataFound = true;
251 251
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
252 252
   		}
253 253
 
254 254
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
255
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
255
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
256 256
 		}
257 257
 		
258 258
 		if (isset($line['heading']) && $line['heading'] != '') {
259
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
261
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
259
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
261
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
262 262
 		    //$dataFound = true;
263 263
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
264
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
266
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
264
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
266
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
267 267
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
268 268
   		}
269 269
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -271,54 +271,54 @@  discard block
 block discarded – undo
271 271
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
272 272
 		    $this->all_tracked[$id]['lastupdate'] = time();
273 273
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
274
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
274
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275 275
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
276 276
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
277 277
 				$timeelapsed = microtime(true);
278 278
 				$TrackerLive = new TrackerLive($this->db);
279 279
 				if (isset($line['id'])) {
280 280
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
281
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
282 282
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
283 283
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
284
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
285 285
 				} else $recent_ident = '';
286
-				$TrackerLive->db=null;
286
+				$TrackerLive->db = null;
287 287
 
288 288
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
289 289
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
290 290
 			    } else {
291 291
 				$recent_ident = '';
292
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
292
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
293 293
 			    }
294 294
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
295
-			    if($recent_ident == "")
295
+			    if ($recent_ident == "")
296 296
 			    {
297 297
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
298 298
 				//adds the spotter data for the archive
299 299
 				    $highlight = '';
300
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
300
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
301 301
 				    $timeelapsed = microtime(true);
302 302
 				    $Tracker = new Tracker($this->db);
303
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
303
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
304 304
 				    $Tracker->db = null;
305 305
 				    if ($globalDebug && isset($result)) echo $result."\n";
306
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
306
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
307 307
 				    
308 308
 				    
309 309
 				    // Add source stat in DB
310 310
 				    $Stats = new Stats($this->db);
311 311
 				    if (!empty($this->stats)) {
312 312
 					if ($globalDebug) echo 'Add source stats : ';
313
-				        foreach($this->stats as $date => $data) {
314
-					    foreach($data as $source => $sourced) {
313
+				        foreach ($this->stats as $date => $data) {
314
+					    foreach ($data as $source => $sourced) {
315 315
 					        //print_r($sourced);
316
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
317
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
316
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
317
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
318 318
 				    		if (isset($sourced['msg'])) {
319 319
 				    		    if (time() - $sourced['msg']['date'] > 10) {
320 320
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
321
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
321
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
322 322
 			    			        unset($this->stats[$date][$source]['msg']);
323 323
 			    			    }
324 324
 			    			}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
342 342
 				    $TrackerLive = new TrackerLive($this->db);
343 343
 				    $TrackerLive->deleteLiveTrackerData();
344
-				    $TrackerLive->db=null;
344
+				    $TrackerLive->db = null;
345 345
 				    if ($globalDebug) echo " Done\n";
346 346
 				    $this->last_delete = time();
347 347
 				}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 				$this->all_tracked[$id]['addedTracker'] = 1;
351 351
 				if (isset($globalDaemon) && !$globalDaemon) {
352 352
 					$Tracker = new Tracker($this->db);
353
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
353
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
354 354
 					$Tracker->db = null;
355 355
 				}
356 356
 				
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
 		    $ignoreImport = false;
365 365
 
366 366
 		    if (!$ignoreImport) {
367
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
367
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
368 368
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
369 369
 				$timeelapsed = microtime(true);
370 370
 				$TrackerLive = new TrackerLive($this->db);
371
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
371
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
372 372
 				$TrackerLive->db = null;
373 373
 				$this->all_tracked[$id]['putinarchive'] = false;
374
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
375 375
 
376 376
 				// Put statistics in $this->stats variable
377 377
 				
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 							$latitude = $globalCenterLatitude;
389 389
 							$longitude = $globalCenterLongitude;
390 390
 						}
391
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
391
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
392 392
 					} else {
393 393
 						$latitude = $this->source_location[$source]['latitude'];
394 394
 						$longitude = $this->source_location[$source]['longitude'];
395 395
 					}
396
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
396
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
397 397
 					//$stats_heading = $stats_heading%22.5;
398 398
 					$stats_heading = round($stats_heading/22.5);
399
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
399
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
400 400
 					$current_date = date('Y-m-d');
401 401
 					if ($stats_heading == 16) $stats_heading = 0;
402 402
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
403
-						for ($i=0;$i<=15;$i++) {
403
+						for ($i = 0; $i <= 15; $i++) {
404 404
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
405 405
 						}
406 406
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
416 416
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
417 417
 						    end($this->stats[$current_date][$source]['hist']);
418
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
418
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
419 419
 						} else $mini = 0;
420
-						for ($i=$mini;$i<=$distance;$i+=10) {
420
+						for ($i = $mini; $i <= $distance; $i += 10) {
421 421
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
422 422
 						}
423 423
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				$this->all_tracked[$id]['lastupdate'] = time();
430 430
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431 431
 				if ($globalDebug) echo $result."\n";
432
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
432
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
433 433
 			//$this->del();
434 434
 			
435 435
 			
Please login to merge, or discard this patch.
statistics.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 if (!isset($filter_name)) $filter_name = '';
22
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
22
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
23 23
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24 24
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25 25
 }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	$title = _("Statistics");
35 35
 }
36 36
 
37
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
38
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
39 39
 
40 40
 require_once('header.php');
41 41
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			date_default_timezone_set('UTC');
63 63
 			$lastupdate = strtotime($last_update[0]['value']);
64 64
 			if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
65
-			print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
65
+			print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
66 66
 		}
67 67
 	}
68 68
 ?>
@@ -74,30 +74,30 @@  discard block
 block discarded – undo
74 74
 <?php
75 75
 	if ($type == 'aircraft') {
76 76
 ?>
77
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
78
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
79
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
80
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
78
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
79
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
80
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
81 81
 	<?php
82
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
82
+	    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
83 83
 	?>
84
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
85
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
84
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
85
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
86 86
         <?php
87 87
     	    } else {
88 88
     	?>
89
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
90
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
90
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91 91
     	<?php
92 92
     	    }
93 93
     	?>
94
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
95
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
94
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
95
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
96 96
         <?php
97 97
     		if ($airline_icao == '') {
98 98
     	?>
99
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
100
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
99
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
100
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
101 101
 	<?php
102 102
 		}
103 103
 	?>
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
106 106
 			if ($airline_icao == '' || $airline_icao == 'all') {
107 107
 	?>
108
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
109
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
108
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
109
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
110 110
 	<?php
111 111
 			}
112 112
 		}
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
 <?php
115 115
 	} elseif ($type == 'marine') {
116 116
 ?>
117
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarine(array(),$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
118
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
119
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
120
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
117
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarine(array(), $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
118
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
119
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
120
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
121 121
 <?php
122 122
 	} elseif ($type == 'tracker') {
123 123
 ?>
124
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker(array(),$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
125
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
126
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
127
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
124
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker(array(), $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
125
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
126
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
127
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
128 128
 <?php
129 129
 	}
130 130
 ?>
131 131
     </p>
132
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
132
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
133 133
     <div class="specific-stats">
134 134
 <?php
135 135
 	if ($type == 'aircraft') {
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
             <div class="col-md-6">
139 139
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
140 140
                  <?php
141
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
141
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
142 142
 		    if (count($aircraft_array) == 0) print _("No data available");
143 143
 		    else {
144 144
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
145 145
                     $aircraft_data = '';
146
-                    foreach($aircraft_array as $aircraft_item)
146
+                    foreach ($aircraft_array as $aircraft_item)
147 147
                     {
148 148
                         if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
149 149
                         else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
             	    ?>
174 174
                 </div>
175 175
             </div>
176
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
176
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
177 177
 <?php
178 178
 //    echo $airline_icao;
179 179
 		if ($airline_icao == '' || $airline_icao == 'all') {
180
-			$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
180
+			$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
181 181
 			if (count($airline_array) > 0) {
182 182
 				print '<div class="col-md-6">';
183 183
 				print '<h2>'._("Top 10 Most Common Airline").'</h2>';
184 184
 				print '<div id="chart2" class="chart" width="100%"></div><script>';
185 185
 				$airline_data = '';
186
-				foreach($airline_array as $airline_item)
186
+				foreach ($airline_array as $airline_item)
187 187
 				{
188 188
 					$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
189 189
 				}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 ?>
211 211
         </div>
212
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
212
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
213 213
 <?php
214 214
 		}
215 215
 ?>
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
             <div class="col-md-6">
224 224
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
225 225
                  <?php
226
-                    $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
226
+                    $marine_array = $Marine->countAllMarineTypes(true, 0, '', array(), $year, $month);
227 227
 		    if (count($marine_array) == 0) print _("No data available");
228 228
 		    else {
229 229
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
230 230
                     $marine_data = '';
231
-                    foreach($marine_array as $marine_item)
231
+                    foreach ($marine_array as $marine_item)
232 232
                     {
233 233
                         $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
234 234
                     }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             	    ?>
260 260
                 </div>
261 261
             </div>
262
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
262
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
263 263
 <!--	</div>-->
264 264
 <?php
265 265
 	}
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
             <div class="col-md-6">
272 272
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
273 273
                  <?php
274
-                  $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
274
+                  $tracker_array = $Tracker->countAllTrackerTypes(true, 0, '', array(), $year, $month);
275 275
 		    if (count($tracker_array) == 0) print _("No data available");
276 276
 		    else {
277 277
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
278 278
                     $tracker_data = '';
279
-                    foreach($tracker_array as $tracker_item)
279
+                    foreach ($tracker_array as $tracker_item)
280 280
                     {
281 281
                         $tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
282 282
                     }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             	    ?>
308 308
                 </div>
309 309
             </div>
310
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
310
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
311 311
 <!--	</div>-->
312 312
 <?php
313 313
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 ?>
318 318
         <div class="row column">
319 319
 <?php
320
-		$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
321
-		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
320
+		$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
321
+		if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
322 322
 			if (empty($flightover_array)) {
323 323
 				print '<div class="col-md-12">';
324 324
 			} else {
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 ?>
328 328
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
329 329
 <?php
330
-			$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
330
+			$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
331 331
 			if (count($pilot_array) == 0) print _("No data available");
332 332
 			else {
333 333
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
334 334
 				$pilot_data = '';
335
-				foreach($pilot_array as $pilot_item)
335
+				foreach ($pilot_array as $pilot_item)
336 336
 				{
337 337
 					$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
338 338
 				}
@@ -354,19 +354,19 @@  discard block
 block discarded – undo
354 354
 ?>
355 355
             </div>
356 356
         
357
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
357
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
358 358
 <?php
359 359
 		} else {
360 360
 ?>
361 361
             <div class="col-md-6">
362 362
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
363 363
 <?php
364
-			$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
364
+			$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
365 365
 			if (count($owner_array) == 0) print _("No data available");
366 366
 			else {
367 367
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
368 368
 				$owner_data = '';
369
-				foreach($owner_array as $owner_item)
369
+				foreach ($owner_array as $owner_item)
370 370
 				{
371 371
 					$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
372 372
 				}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                 </div>
387 387
             </div>
388 388
         
389
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
389
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
390 390
 <?php
391 391
 		}
392 392
 		if (!empty($flightover_array)) {
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 				print '<div id="chart10" class="chart" width="100%"></div><script>';
401 401
 				print 'var series = [';
402 402
 				$flightover_data = '';
403
-				foreach($flightover_array as $flightover_item)
403
+				foreach ($flightover_array as $flightover_item)
404 404
 				{
405 405
 					$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
406 406
 				}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		}
447 447
 ?>
448 448
         </div>
449
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
449
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
450 450
 
451 451
     	
452 452
         </div>
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
467 467
 			print 'var series = [';
468 468
 			$flightover_data = '';
469
-			foreach($flightover_array as $flightover_item)
469
+			foreach ($flightover_array as $flightover_item)
470 470
 			{
471 471
 				$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
472 472
 			}
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
527 527
 			print 'var series = [';
528 528
 			$flightover_data = '';
529
-			foreach($flightover_array as $flightover_item)
529
+			foreach ($flightover_array as $flightover_item)
530 530
 			{
531 531
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
532 532
 			}
@@ -579,14 +579,14 @@  discard block
 block discarded – undo
579 579
         <div class="row column">
580 580
             <div class="col-md-6">
581 581
 <?php
582
-		$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
582
+		$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
583 583
 		if (count($airport_airport_array) > 0) {
584 584
 			print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
585 585
 			print '<div id="chart3" class="chart" width="100%"></div><script>';
586 586
 			print "\n";
587 587
 			print 'var series = [';
588 588
 			$airport_data = '';
589
-			foreach($airport_airport_array as $airport_item)
589
+			foreach ($airport_airport_array as $airport_item)
590 590
 			{
591 591
 				$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
592 592
 			}
@@ -637,18 +637,18 @@  discard block
 block discarded – undo
637 637
 		}
638 638
 ?>
639 639
             </div>
640
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
640
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
641 641
 
642 642
             <div class="col-md-6">
643 643
 <?php
644
-		$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
644
+		$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
645 645
 		if (count($airport_airport_array2) > 0) {
646 646
 			print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
647 647
 			print '<div id="chart4" class="chart" width="100%"></div><script>';
648 648
 			print "\n";
649 649
 			print 'var series = [';
650 650
 			$airport_data = '';
651
-			foreach($airport_airport_array2 as $airport_item)
651
+			foreach ($airport_airport_array2 as $airport_item)
652 652
 			{
653 653
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
654 654
 			}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 ?>
701 701
             </div>
702 702
         </div>
703
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
703
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
704 704
 <?php 
705 705
 	}
706 706
 ?>
@@ -714,19 +714,19 @@  discard block
 block discarded – undo
714 714
             <div class="col-md-6">
715 715
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
716 716
 <?php
717
-			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
717
+			$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
718 718
 			if (count($year_array) == 0) print _("No data available");
719 719
 			else {
720 720
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
721 721
 				$year_data = '';
722 722
 				$year_cnt = '';
723
-				foreach($year_array as $year_item)
723
+				foreach ($year_array as $year_item)
724 724
 				{
725 725
 					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
726 726
 					$year_cnt .= $year_item['date_count'].',';
727 727
 				}
728 728
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
729
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
729
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
730 730
 				print 'c3.generate({
731 731
 				    bindto: "#chart8",
732 732
 				    data: { x: "x",
@@ -739,23 +739,23 @@  discard block
 block discarded – undo
739 739
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
741 741
             </div>
742
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
742
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
743 743
             <div class="col-md-6">
744 744
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
745 745
 <?php
746
-			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
746
+			$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
747 747
 			if (count($month_array) == 0) print _("No data available");
748 748
 			else {
749 749
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
750 750
 				$month_data = '';
751 751
 				$month_cnt = '';
752
-				foreach($month_array as $month_item)
752
+				foreach ($month_array as $month_item)
753 753
 				{
754 754
 					$month_data .= '"'.$month_item['date_name'].'",';
755 755
 					$month_cnt .= $month_item['date_count'].',';
756 756
 				}
757 757
 				$month_data = "['x',".substr($month_data, 0, -1)."]";
758
-				$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
758
+				$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
759 759
 				print 'c3.generate({
760 760
 				    bindto: "#chart9",
761 761
 				    data: { x: "x",
@@ -768,24 +768,24 @@  discard block
 block discarded – undo
768 768
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
769 769
                 </div>
770 770
             </div>
771
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
771
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
772 772
 
773 773
             <div class="col-md-6">
774 774
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
775 775
 <?php
776
-			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
776
+			$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
777 777
 			if (empty($date_array)) print _("No data available");
778 778
 			else {
779 779
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
780 780
 				$date_data = '';
781 781
 				$date_cnt = '';
782
-				foreach($date_array as $date_item)
782
+				foreach ($date_array as $date_item)
783 783
 				{
784 784
 					$date_data .= '"'.$date_item['date_name'].'",';
785 785
 					$date_cnt .= $date_item['date_count'].',';
786 786
 				}
787 787
 				$date_data = "['x',".substr($date_data, 0, -1)."]";
788
-				$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
788
+				$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
789 789
 				print 'c3.generate({
790 790
 				    bindto: "#chart5",
791 791
 				    data: { x: "x",
@@ -798,23 +798,23 @@  discard block
 block discarded – undo
798 798
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
799 799
                 </div>
800 800
             </div>
801
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
801
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
802 802
             <div class="col-md-6">
803 803
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
804 804
 <?php
805
-			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
805
+			$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
806 806
 			if (empty($hour_array)) print _("No data available");
807 807
 			else {
808 808
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
809 809
 				$hour_data = '';
810 810
 				$hour_cnt = '';
811
-				foreach($hour_array as $hour_item)
811
+				foreach ($hour_array as $hour_item)
812 812
 				{
813 813
 					$hour_data .= '"'.$hour_item['hour_name'].':00",';
814 814
 					$hour_cnt .= $hour_item['hour_count'].',';
815 815
 				}
816 816
 				$hour_data = "[".substr($hour_data, 0, -1)."]";
817
-				$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
817
+				$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
818 818
 				print 'c3.generate({
819 819
 				    bindto: "#chart6",
820 820
 				    data: {
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
828 828
                 </div>
829 829
             </div>
830
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
830
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
831 831
         </div>
832 832
 <?php
833 833
 		}
@@ -845,19 +845,19 @@  discard block
 block discarded – undo
845 845
             <div class="col-md-6">
846 846
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
847 847
 <?php
848
-			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
848
+			$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
849 849
 			if (count($year_array) == 0) print _("No data available");
850 850
 			else {
851 851
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
852 852
 				$year_data = '';
853 853
 				$year_cnt = '';
854
-				foreach($year_array as $year_item)
854
+				foreach ($year_array as $year_item)
855 855
 				{
856 856
 					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
857 857
 					$year_cnt .= $year_item['date_count'].',';
858 858
 				}
859 859
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
860
-				$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
860
+				$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
861 861
 				print 'c3.generate({
862 862
 				    bindto: "#chart8",
863 863
 				    data: { x: "x",
@@ -871,23 +871,23 @@  discard block
 block discarded – undo
871 871
                 </div>
872 872
             </div>
873 873
             
874
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
874
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
875 875
             <div class="col-md-6">
876 876
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
877 877
 <?php
878
-			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
878
+			$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
879 879
 			if (count($month_array) == 0) print _("No data available");
880 880
 			else {
881 881
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
882 882
 				$month_data = '';
883 883
 				$month_cnt = '';
884
-				foreach($month_array as $month_item)
884
+				foreach ($month_array as $month_item)
885 885
 				{
886 886
 					$month_data .= '"'.$month_item['date_name'].'",';
887 887
 					$month_cnt .= $month_item['date_count'].',';
888 888
 				}
889 889
 				$month_data = "['x',".substr($month_data, 0, -1)."]";
890
-				$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
890
+				$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
891 891
 				print 'c3.generate({
892 892
 				    bindto: "#chart9",
893 893
 				    data: { x: "x",
@@ -900,24 +900,24 @@  discard block
 block discarded – undo
900 900
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
901 901
                 </div>
902 902
             </div>
903
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
903
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
904 904
 
905 905
             <div class="col-md-6">
906 906
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
907 907
 <?php
908
-			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
908
+			$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
909 909
 			if (empty($date_array)) print _("No data available");
910 910
 			else {
911 911
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
912 912
 				$date_data = '';
913 913
 				$date_cnt = '';
914
-				foreach($date_array as $date_item)
914
+				foreach ($date_array as $date_item)
915 915
 				{
916 916
 					$date_data .= '"'.$date_item['date_name'].'",';
917 917
 					$date_cnt .= $date_item['date_count'].',';
918 918
 				}
919 919
 				$date_data = "['x',".substr($date_data, 0, -1)."]";
920
-				$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
920
+				$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
921 921
 				print 'c3.generate({
922 922
 				    bindto: "#chart5",
923 923
 				    data: { x: "x",
@@ -930,23 +930,23 @@  discard block
 block discarded – undo
930 930
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
931 931
                 </div>
932 932
             </div>
933
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
933
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
934 934
             <div class="col-md-6">
935 935
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
936 936
 <?php
937
-			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
937
+			$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
938 938
 			if (empty($hour_array)) print _("No data available");
939 939
 			else {
940 940
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
941 941
 				$hour_data = '';
942 942
 				$hour_cnt = '';
943
-				foreach($hour_array as $hour_item)
943
+				foreach ($hour_array as $hour_item)
944 944
 				{
945 945
 					$hour_data .= '"'.$hour_item['hour_name'].':00",';
946 946
 					$hour_cnt .= $hour_item['hour_count'].',';
947 947
 				}
948 948
 				$hour_data = "[".substr($hour_data, 0, -1)."]";
949
-				$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
949
+				$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
950 950
 				print 'c3.generate({
951 951
 				    bindto: "#chart6",
952 952
 				    data: {
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
960 960
                 </div>
961 961
             </div>
962
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
962
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
963 963
         </div>
964 964
 <?php
965 965
 		}
@@ -983,13 +983,13 @@  discard block
 block discarded – undo
983 983
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
984 984
 				$year_data = '';
985 985
 				$year_cnt = '';
986
-				foreach($year_array as $year_item)
986
+				foreach ($year_array as $year_item)
987 987
 				{
988 988
 					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
989 989
 					$year_cnt .= $year_item['date_count'].',';
990 990
 				}
991 991
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
992
-				$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
992
+				$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
993 993
 				print 'c3.generate({
994 994
 				    bindto: "#chart8",
995 995
 				    data: { x: "x",
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                 </div>
1004 1004
             </div>
1005 1005
             
1006
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1006
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1007 1007
             <div class="col-md-6">
1008 1008
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1009 1009
 <?php
@@ -1013,13 +1013,13 @@  discard block
 block discarded – undo
1013 1013
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
1014 1014
 				$month_data = '';
1015 1015
 				$month_cnt = '';
1016
-				foreach($month_array as $month_item)
1016
+				foreach ($month_array as $month_item)
1017 1017
 				{
1018 1018
 					$month_data .= '"'.$month_item['date_name'].'",';
1019 1019
 					$month_cnt .= $month_item['date_count'].',';
1020 1020
 				}
1021 1021
 				$month_data = "['x',".substr($month_data, 0, -1)."]";
1022
-				$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1022
+				$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1023 1023
 				print 'c3.generate({
1024 1024
 				    bindto: "#chart9",
1025 1025
 				    data: { x: "x",
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1033 1033
                 </div>
1034 1034
             </div>
1035
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1035
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1036 1036
 
1037 1037
             <div class="col-md-6">
1038 1038
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1043,13 +1043,13 @@  discard block
 block discarded – undo
1043 1043
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
1044 1044
 				$date_data = '';
1045 1045
 				$date_cnt = '';
1046
-				foreach($date_array as $date_item)
1046
+				foreach ($date_array as $date_item)
1047 1047
 				{
1048 1048
 					$date_data .= '"'.$date_item['date_name'].'",';
1049 1049
 					$date_cnt .= $date_item['date_count'].',';
1050 1050
 				}
1051 1051
 				$date_data = "['x',".substr($date_data, 0, -1)."]";
1052
-				$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1052
+				$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1053 1053
 				print 'c3.generate({
1054 1054
 				    bindto: "#chart5",
1055 1055
 				    data: { x: "x",
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1063 1063
                 </div>
1064 1064
             </div>
1065
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1065
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1066 1066
             <div class="col-md-6">
1067 1067
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1068 1068
 <?php
1069
-			$hour_array = $Tracker->countAllHours('hour',true);
1069
+			$hour_array = $Tracker->countAllHours('hour', true);
1070 1070
 			if (empty($hour_array)) print _("No data available");
1071 1071
 			else {
1072 1072
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
1073 1073
 				$hour_data = '';
1074 1074
 				$hour_cnt = '';
1075
-				foreach($hour_array as $hour_item)
1075
+				foreach ($hour_array as $hour_item)
1076 1076
 				{
1077 1077
 					$hour_data .= '"'.$hour_item['hour_name'].':00",';
1078 1078
 					$hour_cnt .= $hour_item['hour_count'].',';
1079 1079
 				}
1080 1080
 				$hour_data = "[".substr($hour_data, 0, -1)."]";
1081
-				$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1081
+				$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1082 1082
 				print 'c3.generate({
1083 1083
 				    bindto: "#chart6",
1084 1084
 				    data: {
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1092 1092
                 </div>
1093 1093
             </div>
1094
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1094
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1095 1095
         </div>
1096 1096
 <?php
1097 1097
 		}
@@ -1115,13 +1115,13 @@  discard block
 block discarded – undo
1115 1115
 				print '<div id="chart32" class="chart" width="100%"></div><script>';
1116 1116
 				$year_data = '';
1117 1117
 				$year_cnt = '';
1118
-				foreach($year_array as $year_item)
1118
+				foreach ($year_array as $year_item)
1119 1119
 				{
1120 1120
 					$year_data .= '"'.$year_item['year'].'-01-01",';
1121 1121
 					$year_cnt .= $year_item['count'].',';
1122 1122
 				}
1123 1123
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
1124
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1124
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1125 1125
 				print 'c3.generate({
1126 1126
 				    bindto: "#chart32",
1127 1127
 				    data: { x: "x",
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1135 1135
                 </div>
1136 1136
             </div>
1137
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1137
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1138 1138
 
1139 1139
         <div class="row column">
1140 1140
             <div class="col-md-6">
@@ -1146,13 +1146,13 @@  discard block
 block discarded – undo
1146 1146
 				print '<div id="chart33" class="chart" width="100%"></div><script>';
1147 1147
 				$year_data = '';
1148 1148
 				$year_cnt = '';
1149
-				foreach($year_array as $year_item)
1149
+				foreach ($year_array as $year_item)
1150 1150
 				{
1151 1151
 					$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1152 1152
 					$year_cnt .= $year_item['count'].',';
1153 1153
 				}
1154 1154
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
1155
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1155
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1156 1156
 				print 'c3.generate({
1157 1157
 				    bindto: "#chart33",
1158 1158
 				    data: { x: "x",
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1166 1166
                 </div>
1167 1167
             </div>
1168
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1168
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1169 1169
 <br/>
1170 1170
 <?php
1171 1171
 		}
@@ -1181,19 +1181,19 @@  discard block
 block discarded – undo
1181 1181
 			//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1182 1182
 			if ($year == '' && $month == '') {
1183 1183
 				if ($type == 'aircraft') {
1184
-					$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1184
+					$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1185 1185
 				} elseif ($type == 'marine') {
1186
-					$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1186
+					$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1187 1187
 				} elseif ($type == 'tracker') {
1188
-					$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1188
+					$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1189 1189
 				}
1190 1190
 			} else {
1191 1191
 				if ($type == 'aircraft') {
1192
-					$polar = $Stats->getStatsSource('polar',$year,$month);
1192
+					$polar = $Stats->getStatsSource('polar', $year, $month);
1193 1193
 				} elseif ($type == 'marine') {
1194
-					$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1194
+					$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1195 1195
 				} elseif ($type == 'tracker') {
1196
-					$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1196
+					$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1197 1197
 				}
1198 1198
 			}
1199 1199
 			if (!empty($polar)) {
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 					unset($polar_data);
1203 1203
 					$Spotter = new Spotter();
1204 1204
 					$data = json_decode($eachpolar['source_data']);
1205
-					foreach($data as $value => $key) {
1205
+					foreach ($data as $value => $key) {
1206 1206
 						$direction = $Spotter->parseDirection(($value*22.5));
1207 1207
 						$distance = $key;
1208 1208
 						$unit = 'km';
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 ?>
1223 1223
             <div class="col-md-6">
1224 1224
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1225
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1225
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1226 1226
         	<script>
1227 1227
         	    (function() {
1228 1228
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		      color: color,
1247 1247
 		      unit: '<?php echo $unit; ?>'
1248 1248
 		    };
1249
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1249
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1250 1250
 		    })();
1251 1251
 		</script>
1252 1252
             </div>
@@ -1261,19 +1261,19 @@  discard block
 block discarded – undo
1261 1261
 			//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1262 1262
 			if ($year == '' && $month == '') {
1263 1263
 				if ($type == 'aircraft') {
1264
-					$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1264
+					$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1265 1265
 				} elseif ($type == 'marine') {
1266
-					$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1266
+					$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1267 1267
 				} elseif ($type == 'tracker') {
1268
-					$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1268
+					$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1269 1269
 				}
1270 1270
 			} else {
1271 1271
 				if ($type == 'aircraft') {
1272
-					$msg = $Stats->getStatsSource('msg',$year,$month);
1272
+					$msg = $Stats->getStatsSource('msg', $year, $month);
1273 1273
 				} elseif ($type == 'marine') {
1274
-					$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1274
+					$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1275 1275
 				} elseif ($type == 'tracker') {
1276
-					$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1276
+					$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1277 1277
 				}
1278 1278
 			}
1279 1279
 			if (!empty($msg)) {
@@ -1281,13 +1281,13 @@  discard block
 block discarded – undo
1281 1281
 				foreach ($msg as $eachmsg) {
1282 1282
 					//$eachmsg = $msg[0];
1283 1283
 					$data = $eachmsg['source_data'];
1284
-					if ($data > 500) $max = (round(($data+100)/100))*100;
1284
+					if ($data > 500) $max = (round(($data + 100)/100))*100;
1285 1285
 					else $max = 500;
1286 1286
 ?>
1287
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1287
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1288 1288
         	<script>
1289 1289
 		      var g = new JustGage({
1290
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1290
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1291 1291
 			    value: <?php echo $data; ?>,
1292 1292
 			    min: 0,
1293 1293
 			    max: <?php print $max; ?>,
@@ -1309,19 +1309,19 @@  discard block
 block discarded – undo
1309 1309
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1310 1310
 			if ($year == '' && $month == '') {
1311 1311
 				if ($type == 'aircraft') {
1312
-					$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1312
+					$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1313 1313
 				} elseif ($type == 'marine') {
1314
-					$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1314
+					$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1315 1315
 				} elseif ($type == 'tracker') {
1316
-					$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1316
+					$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1317 1317
 				}
1318 1318
 			} else {
1319 1319
 				if ($type == 'aircraft') {
1320
-					$hist = $Stats->getStatsSource('hist',$year,$month);
1320
+					$hist = $Stats->getStatsSource('hist', $year, $month);
1321 1321
 				} elseif ($type == 'marine') {
1322
-					$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1322
+					$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1323 1323
 				} elseif ($type == 'tracker') {
1324
-					$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1324
+					$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1325 1325
 				}
1326 1326
 			}
1327 1327
 			foreach ($hist as $hists) {
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 				$source = $hists['source_name'];
1332 1332
 				$hist_array = json_decode($hists['source_data']);
1333 1333
 				$unit = 'km';
1334
-				foreach($hist_array as $distance => $nb)
1334
+				foreach ($hist_array as $distance => $nb)
1335 1335
 				{
1336 1336
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1337 1337
 						$distance = round($distance*0.539957);
@@ -1352,18 +1352,18 @@  discard block
 block discarded – undo
1352 1352
 				$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1353 1353
 ?>
1354 1354
             <div class="col-md-6">
1355
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1355
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1356 1356
 <?php
1357
-				print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1357
+				print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1358 1358
 				print 'c3.generate({
1359
-				    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1359
+				    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1360 1360
 				    data: { x: "x",
1361 1361
 				    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1362 1362
 				    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1363 1363
 				print '</script>';
1364 1364
 ?>
1365 1365
     	    </div>
1366
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1366
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1367 1367
 <?php
1368 1368
 			}
1369 1369
 ?>
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
         }
20 20
               
21
-	public function addLastStatsUpdate($type,$stats_date) {
21
+	public function addLastStatsUpdate($type, $stats_date) {
22 22
                 $query = "DELETE FROM config WHERE name = :type;
23 23
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
25 25
                  try {
26 26
                         $sth = $this->db->prepare($query);
27 27
                         $sth->execute($query_values);
28
-                } catch(PDOException $e) {
28
+                } catch (PDOException $e) {
29 29
                         return "error : ".$e->getMessage();
30 30
                 }
31 31
         }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                  try {
36 36
                         $sth = $this->db->prepare($query);
37 37
                         $sth->execute(array(':type' => $type));
38
-                } catch(PDOException $e) {
38
+                } catch (PDOException $e) {
39 39
                         echo "error : ".$e->getMessage();
40 40
                 }
41 41
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                  try {
56 56
                         $sth = $this->db->prepare($query);
57 57
                         $sth->execute(array(':filter_name' => $filter_name));
58
-                } catch(PDOException $e) {
58
+                } catch (PDOException $e) {
59 59
                         return "error : ".$e->getMessage();
60 60
                 }
61 61
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                  try {
69 69
                         $sth = $this->db->prepare($query);
70 70
                         $sth->execute();
71
-                } catch(PDOException $e) {
71
+                } catch (PDOException $e) {
72 72
                         return "error : ".$e->getMessage();
73 73
                 }
74 74
                 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                  try {
77 77
                         $sth = $this->db->prepare($query);
78 78
                         $sth->execute(array(':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
         }
@@ -86,69 +86,69 @@  discard block
 block discarded – undo
86 86
                  try {
87 87
                         $sth = $this->db->prepare($query);
88 88
                         $sth->execute(array(':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         echo "error : ".$e->getMessage();
91 91
                 }
92 92
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93 93
                 return $all;
94 94
         }
95
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
96 96
 		if ($filter_name == '') $filter_name = $this->filter_name;
97 97
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98 98
                  try {
99 99
                         $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
100
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
101
+                } catch (PDOException $e) {
102 102
                         echo "error : ".$e->getMessage();
103 103
                 }
104 104
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
                 return $all;
106 106
         }
107
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
108 108
 		if ($filter_name == '') $filter_name = $this->filter_name;
109 109
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
-                } catch(PDOException $e) {
112
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117 117
                 return $all;
118 118
         }
119
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
120 120
 		if ($filter_name == '') $filter_name = $this->filter_name;
121 121
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
122 122
                  try {
123 123
                         $sth = $this->db->prepare($query);
124
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
-                } catch(PDOException $e) {
124
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
125
+                } catch (PDOException $e) {
126 126
                         echo "error : ".$e->getMessage();
127 127
                 }
128 128
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
129 129
                 return $all;
130 130
         }
131 131
 
132
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135 135
                  try {
136 136
                         $sth = $this->db->prepare($query);
137
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-                } catch(PDOException $e) {
137
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+                } catch (PDOException $e) {
139 139
                         echo "error : ".$e->getMessage();
140 140
                 }
141 141
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
                 return $all;
143 143
         }
144 144
 
145
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148 148
                  try {
149 149
                         $sth = $this->db->prepare($query);
150
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-                } catch(PDOException $e) {
150
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+                } catch (PDOException $e) {
152 152
                         echo "error : ".$e->getMessage();
153 153
                 }
154 154
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
 
159
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
159
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
160 160
 		global $globalStatsFilters;
161 161
 		if ($filter_name == '') $filter_name = $this->filter_name;
162 162
 		if ($year == '' && $month == '') {
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
165 165
 			try {
166 166
 				$sth = $this->db->prepare($query);
167
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
-			} catch(PDOException $e) {
167
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
168
+			} catch (PDOException $e) {
169 169
 				echo "error : ".$e->getMessage();
170 170
 			}
171 171
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
 		} else $all = array();
173 173
                 if (empty($all)) {
174
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174
+            	    $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
175 175
             	    if ($filter_name != '') {
176
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
177 177
             	    }
178 178
             	    $Spotter = new Spotter($this->db);
179 179
             	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
180
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
181 181
                 }
182 182
                 return $all;
183 183
 	}
184
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
185 185
 		global $globalStatsFilters;
186 186
 		if ($filter_name == '') $filter_name = $this->filter_name;
187 187
 		if ($year == '' && $month == '') {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			try {
191 191
 				$sth = $this->db->prepare($query);
192 192
 				$sth->execute(array(':filter_name' => $filter_name));
193
-			} catch(PDOException $e) {
193
+			} catch (PDOException $e) {
194 194
 				echo "error : ".$e->getMessage();
195 195
 			}
196 196
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
                 if (empty($all)) {
199 199
             		$Spotter = new Spotter($this->db);
200 200
             		$filters = array();
201
-            		$filters = array('year' => $year,'month' => $month);
201
+            		$filters = array('year' => $year, 'month' => $month);
202 202
             		if ($filter_name != '') {
203
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
203
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
204 204
 			}
205 205
             		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
206
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
207 207
                 }
208 208
                 return $all;
209 209
 	}
210
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
211 211
 		global $globalStatsFilters;
212 212
 		if ($filter_name == '') $filter_name = $this->filter_name;
213 213
 		if ($year == '' && $month == '') {
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
216 216
 			try {
217 217
 				$sth = $this->db->prepare($query);
218
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
219
-			} catch(PDOException $e) {
218
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
219
+			} catch (PDOException $e) {
220 220
 				echo "error : ".$e->getMessage();
221 221
 			}
222 222
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
223 223
 		} else $all = array();
224 224
 		if (empty($all)) {
225
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
225
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
226 226
 			if ($filter_name != '') {
227
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
227
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
228 228
 			}
229 229
 			$Spotter = new Spotter($this->db);
230 230
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		return $all;
234 234
 	}
235 235
 
236
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
236
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
237 237
 		global $globalStatsFilters;
238 238
 		if ($filter_name == '') $filter_name = $this->filter_name;
239 239
 		if ($year == '' && $month == '') {
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
242 242
 			try {
243 243
 				$sth = $this->db->prepare($query);
244
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
245
-			} catch(PDOException $e) {
244
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
245
+			} catch (PDOException $e) {
246 246
 				echo "error : ".$e->getMessage();
247 247
 			}
248 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249 249
 		} else $all = array();
250 250
                 if (empty($all)) {
251
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
252 252
 			if ($filter_name != '') {
253
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
257
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
257
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
258 258
                 }
259 259
                 return $all;
260 260
 	}
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
266 266
                  try {
267 267
                         $sth = $this->db->prepare($query);
268
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-                } catch(PDOException $e) {
268
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
269
+                } catch (PDOException $e) {
270 270
                         echo "error : ".$e->getMessage();
271 271
                 }
272 272
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
273 273
                 if (empty($all)) {
274
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
274
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
275 275
 			if ($filter_name != '') {
276
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
277 277
 			}
278 278
 			$Spotter = new Spotter($this->db);
279 279
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 return $all;
283 283
 	}
284 284
 
285
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
285
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
286 286
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
287 287
 		if ($filter_name == '') $filter_name = $this->filter_name;
288 288
 		if ($year == '' && $month == '') {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			if (isset($forsource)) {
292 292
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
293 293
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
294
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
294
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
295 295
 			} else {
296 296
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
297 297
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			try {
301 301
 				$sth = $this->db->prepare($query);
302 302
 				$sth->execute($query_values);
303
-			} catch(PDOException $e) {
303
+			} catch (PDOException $e) {
304 304
 				echo "error : ".$e->getMessage();
305 305
 			}
306 306
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
                 if (empty($all)) {
309 309
 	                $Spotter = new Spotter($this->db);
310 310
             		$filters = array();
311
-			$filters = array('year' => $year,'month' => $month);
311
+			$filters = array('year' => $year, 'month' => $month);
312 312
             		if ($filter_name != '') {
313
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
316
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
316
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
317 317
                 }
318 318
                 return $all;
319 319
 	}
320
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
321 321
 		global $globalStatsFilters;
322 322
 		if ($filter_name == '') $filter_name = $this->filter_name;
323 323
 		if ($year == '' && $month == '') {
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
326 326
 			try {
327 327
 				$sth = $this->db->prepare($query);
328
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
329
-			} catch(PDOException $e) {
328
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
329
+			} catch (PDOException $e) {
330 330
 				echo "error : ".$e->getMessage();
331 331
 			}
332 332
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 		} else $all = array();
334 334
                 if (empty($all)) {
335
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
336 336
 			if ($filter_name != '') {
337
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
337
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
338 338
 			}
339 339
 	                $Spotter = new Spotter($this->db);
340 340
     		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
341
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
342 342
                 }
343 343
                 return $all;
344 344
 	}
345
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
346 346
 		global $globalStatsFilters;
347 347
 		if ($filter_name == '') $filter_name = $this->filter_name;
348 348
 		if ($year == '' && $month == '') {
@@ -350,24 +350,24 @@  discard block
 block discarded – undo
350 350
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
351 351
 			 try {
352 352
 				$sth = $this->db->prepare($query);
353
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
354
-			} catch(PDOException $e) {
353
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
354
+			} catch (PDOException $e) {
355 355
 				echo "error : ".$e->getMessage();
356 356
 			}
357 357
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
358 358
 		} else $all = array();
359 359
 		if (empty($all)) {
360
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			if ($filter_name != '') {
362
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
362
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
363 363
 			}
364 364
 			$Spotter = new Spotter($this->db);
365 365
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
366
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
366
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
367 367
 		}
368 368
 		return $all;
369 369
 	}
370
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
370
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
371 371
 		$Connection = new Connection();
372 372
 		if ($filter_name == '') $filter_name = $this->filter_name;
373 373
 		if ($Connection->tableExists('countries')) {
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
377 377
 				 try {
378 378
 					$sth = $this->db->prepare($query);
379
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
380
-				} catch(PDOException $e) {
379
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
380
+				} catch (PDOException $e) {
381 381
 					echo "error : ".$e->getMessage();
382 382
 				}
383 383
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			return array();
394 394
 		}
395 395
 	}
396
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
396
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
397 397
 		global $globalStatsFilters;
398 398
 		if ($filter_name == '') $filter_name = $this->filter_name;
399 399
 		if ($year == '' && $month == '') {
@@ -401,25 +401,25 @@  discard block
 block discarded – undo
401 401
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
402 402
 			try {
403 403
 				$sth = $this->db->prepare($query);
404
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
405
-			} catch(PDOException $e) {
404
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
405
+			} catch (PDOException $e) {
406 406
 				echo "error : ".$e->getMessage();
407 407
 			}
408 408
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409 409
 		} else $all = array();
410 410
 		if (empty($all)) {
411
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
411
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
412 412
 			if ($filter_name != '') {
413
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
413
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			$Spotter = new Spotter($this->db);
416 416
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
417
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
417
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
418 418
 		}
419 419
 		return $all;
420 420
 	}
421 421
 
422
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
422
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
423 423
 		global $globalStatsFilters;
424 424
 		if ($filter_name == '') $filter_name = $this->filter_name;
425 425
 		if ($year == '' && $month == '') {
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
428 428
 			try {
429 429
 				$sth = $this->db->prepare($query);
430
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
431
-			} catch(PDOException $e) {
430
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
431
+			} catch (PDOException $e) {
432 432
 				echo "error : ".$e->getMessage();
433 433
 			}
434 434
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435 435
 		} else $all = array();
436 436
                 if (empty($all)) {
437
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
438 438
 			if ($filter_name != '') {
439
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
439
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
440 440
 			}
441 441
             		$Spotter = new Spotter($this->db);
442 442
             		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
443
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450 450
 		if ($year == '' && $month == '') {
@@ -452,22 +452,22 @@  discard block
 block discarded – undo
452 452
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
453 453
 			try {
454 454
 				$sth = $this->db->prepare($query);
455
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
456
-			} catch(PDOException $e) {
455
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
456
+			} catch (PDOException $e) {
457 457
 				echo "error : ".$e->getMessage();
458 458
 			}
459 459
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460 460
 		} else $all = array();
461 461
                 if (empty($all)) {
462
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
463 463
             		if ($filter_name != '') {
464
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
464
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
465 465
 			}
466 466
             		$Spotter = new Spotter($this->db);
467 467
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
468 468
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
469
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
469
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
470
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
471 471
         		$all = array();
472 472
         		foreach ($pall as $value) {
473 473
         			$icao = $value['airport_departure_icao'];
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
         		foreach ($all as $key => $row) {
485 485
         			$count[$key] = $row['airport_departure_icao_count'];
486 486
         		}
487
-        		array_multisort($count,SORT_DESC,$all);
487
+        		array_multisort($count, SORT_DESC, $all);
488 488
                 }
489 489
                 return $all;
490 490
 	}
491
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
492 492
 		global $globalStatsFilters;
493 493
 		if ($filter_name == '') $filter_name = $this->filter_name;
494 494
 		if ($year == '' && $month == '') {
@@ -496,22 +496,22 @@  discard block
 block discarded – undo
496 496
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
497 497
 			try {
498 498
 				$sth = $this->db->prepare($query);
499
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
500
-			} catch(PDOException $e) {
499
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
500
+			} catch (PDOException $e) {
501 501
 				echo "error : ".$e->getMessage();
502 502
 			}
503 503
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
504 504
 		} else $all = array();
505 505
 		if (empty($all)) {
506
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
507 507
 			if ($filter_name != '') {
508
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
508
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
509 509
 			}
510 510
 			$Spotter = new Spotter($this->db);
511 511
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
512 512
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
513
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
514
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
513
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
514
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
515 515
         		$all = array();
516 516
         		foreach ($pall as $value) {
517 517
         			$icao = $value['airport_arrival_icao'];
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
         		foreach ($all as $key => $row) {
529 529
         			$count[$key] = $row['airport_arrival_icao_count'];
530 530
         		}
531
-        		array_multisort($count,SORT_DESC,$all);
531
+        		array_multisort($count, SORT_DESC, $all);
532 532
                 }
533 533
  
534 534
                 return $all;
535 535
 	}
536
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
537 537
 		global $globalDBdriver, $globalStatsFilters;
538 538
 		if ($filter_name == '') $filter_name = $this->filter_name;
539 539
 		if ($globalDBdriver == 'mysql') {
@@ -543,18 +543,18 @@  discard block
 block discarded – undo
543 543
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
544 544
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
545 545
 		}
546
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
547 547
                  try {
548 548
                         $sth = $this->db->prepare($query);
549 549
                         $sth->execute($query_data);
550
-                } catch(PDOException $e) {
550
+                } catch (PDOException $e) {
551 551
                         echo "error : ".$e->getMessage();
552 552
                 }
553 553
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 554
                 if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
557
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
558 558
 			}
559 559
             		$Spotter = new Spotter($this->db);
560 560
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -563,29 +563,29 @@  discard block
 block discarded – undo
563 563
                 return $all;
564 564
 	}
565 565
 	
566
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
566
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
567 567
 		global $globalStatsFilters;
568 568
 		if ($filter_name == '') $filter_name = $this->filter_name;
569 569
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
570
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
571 571
                  try {
572 572
                         $sth = $this->db->prepare($query);
573 573
                         $sth->execute($query_data);
574
-                } catch(PDOException $e) {
574
+                } catch (PDOException $e) {
575 575
                         echo "error : ".$e->getMessage();
576 576
                 }
577 577
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578 578
                 if (empty($all)) {
579 579
 			$filters = array('airlines' => array($stats_airline));
580 580
 			if ($filter_name != '') {
581
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
581
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
582 582
 			}
583 583
             		$Spotter = new Spotter($this->db);
584 584
             		$all = $Spotter->countAllDatesLastMonth($filters);
585 585
                 }
586 586
                 return $all;
587 587
 	}
588
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
589 589
 		global $globalDBdriver, $globalStatsFilters;
590 590
 		if ($filter_name == '') $filter_name = $this->filter_name;
591 591
 		if ($globalDBdriver == 'mysql') {
@@ -593,40 +593,40 @@  discard block
 block discarded – undo
593 593
 		} else {
594 594
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
595 595
 		}
596
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
596
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
597 597
                  try {
598 598
                         $sth = $this->db->prepare($query);
599 599
                         $sth->execute($query_data);
600
-                } catch(PDOException $e) {
600
+                } catch (PDOException $e) {
601 601
                         echo "error : ".$e->getMessage();
602 602
                 }
603 603
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
604 604
                 if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
607
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
608 608
 			}
609 609
             		$Spotter = new Spotter($this->db);
610 610
             		$all = $Spotter->countAllDatesLast7Days($filters);
611 611
                 }
612 612
                 return $all;
613 613
 	}
614
-	public function countAllDates($stats_airline = '',$filter_name = '') {
614
+	public function countAllDates($stats_airline = '', $filter_name = '') {
615 615
 		global $globalStatsFilters;
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
617 617
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
618
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
619 619
                  try {
620 620
                         $sth = $this->db->prepare($query);
621 621
                         $sth->execute($query_data);
622
-                } catch(PDOException $e) {
622
+                } catch (PDOException $e) {
623 623
                         echo "error : ".$e->getMessage();
624 624
                 }
625 625
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
626 626
                 if (empty($all)) {
627 627
 			$filters = array('airlines' => array($stats_airline));
628 628
 			if ($filter_name != '') {
629
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
630 630
 			}
631 631
             		$Spotter = new Spotter($this->db);
632 632
             		$all = $Spotter->countAllDates($filters);
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
                  try {
642 642
                         $sth = $this->db->prepare($query);
643 643
                         $sth->execute($query_data);
644
-                } catch(PDOException $e) {
644
+                } catch (PDOException $e) {
645 645
                         echo "error : ".$e->getMessage();
646 646
                 }
647 647
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
648 648
                 if (empty($all)) {
649 649
             		$filters = array();
650 650
             		if ($filter_name != '') {
651
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
651
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
652 652
 			}
653 653
             		$Spotter = new Spotter($this->db);
654 654
             		$all = $Spotter->countAllDatesByAirlines($filters);
655 655
                 }
656 656
                 return $all;
657 657
 	}
658
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
658
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
659 659
 		global $globalStatsFilters, $globalDBdriver;
660 660
 		if ($filter_name == '') $filter_name = $this->filter_name;
661 661
 		if ($globalDBdriver == 'mysql') {
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                  try {
667 667
                         $sth = $this->db->prepare($query);
668 668
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         echo "error : ".$e->getMessage();
671 671
                 }
672 672
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 if (empty($all)) {
675 675
 			$filters = array('airlines' => array($stats_airline));
676 676
 			if ($filter_name != '') {
677
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
677
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
678 678
 			}
679 679
             		$Spotter = new Spotter($this->db);
680 680
             		$all = $Spotter->countAllMonths($filters);
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
                  try {
693 693
                         $sth = $this->db->prepare($query);
694 694
                         $sth->execute();
695
-                } catch(PDOException $e) {
695
+                } catch (PDOException $e) {
696 696
                         echo "error : ".$e->getMessage();
697 697
                 }
698 698
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                  try {
714 714
                         $sth = $this->db->prepare($query);
715 715
                         $sth->execute();
716
-                } catch(PDOException $e) {
716
+                } catch (PDOException $e) {
717 717
                         echo "error : ".$e->getMessage();
718 718
                 }
719 719
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -731,21 +731,21 @@  discard block
 block discarded – undo
731 731
                  try {
732 732
                         $sth = $this->db->prepare($query);
733 733
                         $sth->execute(array(':filter_name' => $filter_name));
734
-                } catch(PDOException $e) {
734
+                } catch (PDOException $e) {
735 735
                         echo "error : ".$e->getMessage();
736 736
                 }
737 737
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
738 738
                 if (empty($all)) {
739 739
             		$filters = array();
740 740
             		if ($filter_name != '') {
741
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
741
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
742 742
 			}
743 743
             		$Spotter = new Spotter($this->db);
744 744
             		$all = $Spotter->countAllMilitaryMonths($filters);
745 745
                 }
746 746
                 return $all;
747 747
 	}
748
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
748
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
749 749
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
750 750
 		if ($filter_name == '') $filter_name = $this->filter_name;
751 751
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -762,30 +762,30 @@  discard block
 block discarded – undo
762 762
                  try {
763 763
                         $sth = $this->db->prepare($query);
764 764
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
-                } catch(PDOException $e) {
765
+                } catch (PDOException $e) {
766 766
                         echo "error : ".$e->getMessage();
767 767
                 }
768 768
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
769 769
                 if (empty($all)) {
770 770
 			$filters = array('airlines' => array($stats_airline));
771 771
 			if ($filter_name != '') {
772
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
772
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
773 773
 			}
774 774
             		$Spotter = new Spotter($this->db);
775
-            		$all = $Spotter->countAllHours($orderby,$filters);
775
+            		$all = $Spotter->countAllHours($orderby, $filters);
776 776
                 }
777 777
                 return $all;
778 778
 	}
779 779
 	
780
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
780
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
781 781
 		global $globalStatsFilters;
782 782
 		if ($filter_name == '') $filter_name = $this->filter_name;
783 783
 		if ($year == '') $year = date('Y');
784
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
784
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
785 785
 		if (empty($all)) {
786
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
786
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
787 787
 			if ($filter_name != '') {
788
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
788
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
789 789
 			}
790 790
 			$Spotter = new Spotter($this->db);
791 791
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -793,16 +793,16 @@  discard block
 block discarded – undo
793 793
 		}
794 794
 		return $all;
795 795
 	}
796
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
796
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
797 797
 		global $globalStatsFilters;
798 798
 		if ($filter_name == '') $filter_name = $this->filter_name;
799 799
 		if ($year == '') $year = date('Y');
800
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
800
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
801 801
 		if (empty($all)) {
802 802
 		        $filters = array();
803
-			$filters = array('year' => $year,'month' => $month);
803
+			$filters = array('year' => $year, 'month' => $month);
804 804
             		if ($filter_name != '') {
805
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
805
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
806 806
 			}
807 807
 			$Spotter = new Spotter($this->db);
808 808
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
 		}
811 811
 		return $all;
812 812
 	}
813
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
813
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
814 814
 		global $globalStatsFilters;
815 815
 		if ($filter_name == '') $filter_name = $this->filter_name;
816 816
 		if ($year == '') $year = date('Y');
817
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
817
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
818 818
 		if (empty($all)) {
819
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
819
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
820 820
 			if ($filter_name != '') {
821
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
821
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
822 822
 			}
823 823
 			$Spotter = new Spotter($this->db);
824 824
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
 		}
827 827
 		return $all;
828 828
 	}
829
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
829
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
830 830
 		global $globalStatsFilters;
831 831
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 832
 		if ($year == '' && $month == '') {
833 833
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
834 834
 			try {
835 835
 				$sth = $this->db->prepare($query);
836
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
837
-			} catch(PDOException $e) {
836
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
837
+			} catch (PDOException $e) {
838 838
 				echo "error : ".$e->getMessage();
839 839
 			}
840 840
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
841 841
 			$all = $result[0]['nb'];
842
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
842
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
843 843
 		if (empty($all)) {
844
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
844
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
845 845
 			if ($filter_name != '') {
846
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
846
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
847 847
 			}
848 848
 			$Spotter = new Spotter($this->db);
849 849
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 		return $all;
853 853
 	}
854
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
854
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
855 855
 		global $globalStatsFilters;
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		if ($year == '' && $month == '') {
@@ -859,17 +859,17 @@  discard block
 block discarded – undo
859 859
 			try {
860 860
 				$sth = $this->db->prepare($query);
861 861
 				$sth->execute(array(':filter_name' => $filter_name));
862
-			} catch(PDOException $e) {
862
+			} catch (PDOException $e) {
863 863
 				echo "error : ".$e->getMessage();
864 864
 			}
865 865
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
866 866
 			$all = $result[0]['nb_airline'];
867
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
867
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
868 868
 		if (empty($all)) {
869 869
             		$filters = array();
870
-			$filters = array('year' => $year,'month' => $month);
870
+			$filters = array('year' => $year, 'month' => $month);
871 871
             		if ($filter_name != '') {
872
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
872
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
873 873
 			}
874 874
 			$Spotter = new Spotter($this->db);
875 875
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		}
878 878
 		return $all;
879 879
 	}
880
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
880
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
881 881
 		global $globalStatsFilters;
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 883
 		if ($year == '' && $month == '') {
@@ -886,18 +886,18 @@  discard block
 block discarded – undo
886 886
 			try {
887 887
 				$sth = $this->db->prepare($query);
888 888
 				$sth->execute($query_values);
889
-			} catch(PDOException $e) {
889
+			} catch (PDOException $e) {
890 890
 				echo "error : ".$e->getMessage();
891 891
 			}
892 892
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 			$all = $result[0]['nb'];
894 894
 		} else {
895
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
895
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
896 896
 		}
897 897
 		if (empty($all)) {
898
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
898
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		}
906 906
 		return $all;
907 907
 	}
908
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
908
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
909 909
 		global $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		//if ($year == '') $year = date('Y');
@@ -915,18 +915,18 @@  discard block
 block discarded – undo
915 915
 			try {
916 916
 				$sth = $this->db->prepare($query);
917 917
 				$sth->execute($query_values);
918
-			} catch(PDOException $e) {
918
+			} catch (PDOException $e) {
919 919
 				echo "error : ".$e->getMessage();
920 920
 			}
921 921
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
922 922
 			$all = $result[0]['nb'];
923 923
 		} else {
924
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
924
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
925 925
 		}
926 926
 		if (empty($all)) {
927
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
927
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Spotter = new Spotter($this->db);
932 932
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -935,67 +935,67 @@  discard block
 block discarded – undo
935 935
 		return $all;
936 936
 	}
937 937
 
938
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
938
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
941
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
941
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942 942
                  try {
943 943
                         $sth = $this->db->prepare($query);
944 944
                         $sth->execute($query_values);
945
-                } catch(PDOException $e) {
945
+                } catch (PDOException $e) {
946 946
                         echo "error : ".$e->getMessage();
947 947
                 }
948 948
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
949 949
                 return $all;
950 950
 	}
951
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
951
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
952 952
 		if ($filter_name == '') $filter_name = $this->filter_name;
953 953
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
954
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955 955
                  try {
956 956
                         $sth = $this->db->prepare($query);
957 957
                         $sth->execute($query_values);
958
-                } catch(PDOException $e) {
958
+                } catch (PDOException $e) {
959 959
                         echo "error : ".$e->getMessage();
960 960
                 }
961 961
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962 962
                 return $all;
963 963
         }
964
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
964
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
965 965
 		if ($filter_name == '') $filter_name = $this->filter_name;
966 966
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
967
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
968 968
                  try {
969 969
                         $sth = $this->db->prepare($query);
970 970
                         $sth->execute($query_values);
971
-                } catch(PDOException $e) {
971
+                } catch (PDOException $e) {
972 972
                         echo "error : ".$e->getMessage();
973 973
                 }
974 974
         }
975
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
975
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
     		global $globalArchiveMonths, $globalDBdriver;
978 978
     		if ($globalDBdriver == 'mysql') {
979 979
     			if ($month == '') {
980 980
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
981
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
981
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
982 982
 			} else {
983 983
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
984
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
984
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
985 985
 			}
986 986
 		} else {
987 987
 			if ($month == '') {
988 988
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
989
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
989
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
990 990
 			} else {
991 991
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
992
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
992
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
993 993
 			}
994 994
                 }
995 995
                  try {
996 996
                         $sth = $this->db->prepare($query);
997 997
                         $sth->execute($query_values);
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         echo "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                  try {
1014 1014
                         $sth = $this->db->prepare($query);
1015 1015
                         $sth->execute($query_values);
1016
-                } catch(PDOException $e) {
1016
+                } catch (PDOException $e) {
1017 1017
                         echo "error : ".$e->getMessage();
1018 1018
                 }
1019 1019
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                  try {
1031 1031
                         $sth = $this->db->prepare($query);
1032 1032
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1033
-                } catch(PDOException $e) {
1033
+                } catch (PDOException $e) {
1034 1034
                         echo "error : ".$e->getMessage();
1035 1035
                 }
1036 1036
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
                  try {
1048 1048
                         $sth = $this->db->prepare($query);
1049 1049
                         $sth->execute(array(':filter_name' => $filter_name));
1050
-                } catch(PDOException $e) {
1050
+                } catch (PDOException $e) {
1051 1051
                         echo "error : ".$e->getMessage();
1052 1052
                 }
1053 1053
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1064,20 +1064,20 @@  discard block
 block discarded – undo
1064 1064
                  try {
1065 1065
                         $sth = $this->db->prepare($query);
1066 1066
                         $sth->execute(array(':filter_name' => $filter_name));
1067
-                } catch(PDOException $e) {
1067
+                } catch (PDOException $e) {
1068 1068
                         echo "error : ".$e->getMessage();
1069 1069
                 }
1070 1070
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1071 1071
                 return $all[0]['total'];
1072 1072
         }
1073
-	public function getStatsOwner($owner_name,$filter_name = '') {
1073
+	public function getStatsOwner($owner_name, $filter_name = '') {
1074 1074
     		global $globalArchiveMonths, $globalDBdriver;
1075 1075
 		if ($filter_name == '') $filter_name = $this->filter_name;
1076 1076
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1077 1077
                  try {
1078 1078
                         $sth = $this->db->prepare($query);
1079
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1080
-                } catch(PDOException $e) {
1079
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1080
+                } catch (PDOException $e) {
1081 1081
                         echo "error : ".$e->getMessage();
1082 1082
                 }
1083 1083
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1095,20 +1095,20 @@  discard block
 block discarded – undo
1095 1095
                  try {
1096 1096
                         $sth = $this->db->prepare($query);
1097 1097
                         $sth->execute(array(':filter_name' => $filter_name));
1098
-                } catch(PDOException $e) {
1098
+                } catch (PDOException $e) {
1099 1099
                         echo "error : ".$e->getMessage();
1100 1100
                 }
1101 1101
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1102 1102
                 return $all[0]['total'];
1103 1103
         }
1104
-	public function getStatsPilot($pilot,$filter_name = '') {
1104
+	public function getStatsPilot($pilot, $filter_name = '') {
1105 1105
     		global $globalArchiveMonths, $globalDBdriver;
1106 1106
 		if ($filter_name == '') $filter_name = $this->filter_name;
1107 1107
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1108 1108
                  try {
1109 1109
                         $sth = $this->db->prepare($query);
1110
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1111
-                } catch(PDOException $e) {
1110
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1111
+                } catch (PDOException $e) {
1112 1112
                         echo "error : ".$e->getMessage();
1113 1113
                 }
1114 1114
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
                 else return 0;
1117 1117
         }
1118 1118
 
1119
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1119
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1120 1120
 		global $globalDBdriver;
1121 1121
 		if ($filter_name == '') $filter_name = $this->filter_name;
1122 1122
 		if ($globalDBdriver == 'mysql') {
@@ -1124,15 +1124,15 @@  discard block
 block discarded – undo
1124 1124
                 } else {
1125 1125
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1126 1126
 		}
1127
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1127
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1128 1128
                  try {
1129 1129
                         $sth = $this->db->prepare($query);
1130 1130
                         $sth->execute($query_values);
1131
-                } catch(PDOException $e) {
1131
+                } catch (PDOException $e) {
1132 1132
                         return "error : ".$e->getMessage();
1133 1133
                 }
1134 1134
         }
1135
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1135
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1136 1136
 		global $globalDBdriver;
1137 1137
 		if ($filter_name == '') $filter_name = $this->filter_name;
1138 1138
 		if ($globalDBdriver == 'mysql') {
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1142 1142
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1143 1143
                 }
1144
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1144
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1145 1145
                  try {
1146 1146
                         $sth = $this->db->prepare($query);
1147 1147
                         $sth->execute($query_values);
1148
-                } catch(PDOException $e) {
1148
+                } catch (PDOException $e) {
1149 1149
                         return "error : ".$e->getMessage();
1150 1150
                 }
1151 1151
         }
@@ -1169,75 +1169,75 @@  discard block
 block discarded – undo
1169 1169
         }
1170 1170
         */
1171 1171
 
1172
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1172
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1173 1173
 		global $globalDBdriver;
1174 1174
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1175 1175
 		$query_values = array();
1176 1176
 		if ($globalDBdriver == 'mysql') {
1177 1177
 			if ($year != '') {
1178 1178
 				$query .= ' AND YEAR(stats_date) = :year';
1179
-				$query_values = array_merge($query_values,array(':year' => $year));
1179
+				$query_values = array_merge($query_values, array(':year' => $year));
1180 1180
 			}
1181 1181
 			if ($month != '') {
1182 1182
 				$query .= ' AND MONTH(stats_date) = :month';
1183
-				$query_values = array_merge($query_values,array(':month' => $month));
1183
+				$query_values = array_merge($query_values, array(':month' => $month));
1184 1184
 			}
1185 1185
 			if ($day != '') {
1186 1186
 				$query .= ' AND DAY(stats_date) = :day';
1187
-				$query_values = array_merge($query_values,array(':day' => $day));
1187
+				$query_values = array_merge($query_values, array(':day' => $day));
1188 1188
 			}
1189 1189
 		} else {
1190 1190
 			if ($year != '') {
1191 1191
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1192
-				$query_values = array_merge($query_values,array(':year' => $year));
1192
+				$query_values = array_merge($query_values, array(':year' => $year));
1193 1193
 			}
1194 1194
 			if ($month != '') {
1195 1195
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1196
-				$query_values = array_merge($query_values,array(':month' => $month));
1196
+				$query_values = array_merge($query_values, array(':month' => $month));
1197 1197
 			}
1198 1198
 			if ($day != '') {
1199 1199
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1200
-				$query_values = array_merge($query_values,array(':day' => $day));
1200
+				$query_values = array_merge($query_values, array(':day' => $day));
1201 1201
 			}
1202 1202
 		}
1203 1203
 		$query .= " ORDER BY source_name";
1204
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1204
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1205 1205
 		try {
1206 1206
 			$sth = $this->db->prepare($query);
1207 1207
 			$sth->execute($query_values);
1208
-		} catch(PDOException $e) {
1208
+		} catch (PDOException $e) {
1209 1209
 			echo "error : ".$e->getMessage();
1210 1210
 		}
1211 1211
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1212 1212
 		return $all;
1213 1213
 	}
1214 1214
 
1215
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1215
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
1218 1218
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1219 1219
 		} else {
1220 1220
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1221 1221
                 }
1222
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1222
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1223 1223
                  try {
1224 1224
                         $sth = $this->db->prepare($query);
1225 1225
                         $sth->execute($query_values);
1226
-                } catch(PDOException $e) {
1226
+                } catch (PDOException $e) {
1227 1227
                         return "error : ".$e->getMessage();
1228 1228
                 }
1229 1229
         }
1230
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1230
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1231 1231
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1232
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1232
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1233 1233
                  try {
1234 1234
                         $sth = $this->db->prepare($query);
1235 1235
                         $sth->execute($query_values);
1236
-                } catch(PDOException $e) {
1236
+                } catch (PDOException $e) {
1237 1237
                         return "error : ".$e->getMessage();
1238 1238
                 }
1239 1239
         }
1240
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1240
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1241 1241
 		global $globalDBdriver;
1242 1242
 		if ($globalDBdriver == 'mysql') {
1243 1243
 			if ($reset) {
@@ -1252,15 +1252,15 @@  discard block
 block discarded – undo
1252 1252
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1253 1253
 			}
1254 1254
 		}
1255
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1255
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1256 1256
                  try {
1257 1257
                         $sth = $this->db->prepare($query);
1258 1258
                         $sth->execute($query_values);
1259
-                } catch(PDOException $e) {
1259
+                } catch (PDOException $e) {
1260 1260
                         return "error : ".$e->getMessage();
1261 1261
                 }
1262 1262
         }
1263
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1263
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1264 1264
 		global $globalDBdriver;
1265 1265
 		if ($globalDBdriver == 'mysql') {
1266 1266
 			if ($reset) {
@@ -1275,15 +1275,15 @@  discard block
 block discarded – undo
1275 1275
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1276 1276
 			}
1277 1277
 		}
1278
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1278
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1279 1279
                  try {
1280 1280
                         $sth = $this->db->prepare($query);
1281 1281
                         $sth->execute($query_values);
1282
-                } catch(PDOException $e) {
1282
+                } catch (PDOException $e) {
1283 1283
                         return "error : ".$e->getMessage();
1284 1284
                 }
1285 1285
         }
1286
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1286
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1287 1287
 		global $globalDBdriver;
1288 1288
 		if ($globalDBdriver == 'mysql') {
1289 1289
 			if ($reset) {
@@ -1298,15 +1298,15 @@  discard block
 block discarded – undo
1298 1298
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1299 1299
 			}
1300 1300
 		}
1301
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1301
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1302 1302
                  try {
1303 1303
                         $sth = $this->db->prepare($query);
1304 1304
                         $sth->execute($query_values);
1305
-                } catch(PDOException $e) {
1305
+                } catch (PDOException $e) {
1306 1306
                         return "error : ".$e->getMessage();
1307 1307
                 }
1308 1308
         }
1309
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1309
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1310 1310
 		global $globalDBdriver;
1311 1311
 		if ($globalDBdriver == 'mysql') {
1312 1312
 			if ($reset) {
@@ -1321,15 +1321,15 @@  discard block
 block discarded – undo
1321 1321
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1322 1322
 			}
1323 1323
 		}
1324
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1324
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1325 1325
                  try {
1326 1326
                         $sth = $this->db->prepare($query);
1327 1327
                         $sth->execute($query_values);
1328
-                } catch(PDOException $e) {
1328
+                } catch (PDOException $e) {
1329 1329
                         return "error : ".$e->getMessage();
1330 1330
                 }
1331 1331
         }
1332
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1332
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($globalDBdriver == 'mysql') {
1335 1335
 			if ($reset) {
@@ -1344,15 +1344,15 @@  discard block
 block discarded – undo
1344 1344
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1345 1345
 			}
1346 1346
 		}
1347
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1347
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1348 1348
                  try {
1349 1349
                         $sth = $this->db->prepare($query);
1350 1350
                         $sth->execute($query_values);
1351
-                } catch(PDOException $e) {
1351
+                } catch (PDOException $e) {
1352 1352
                         return "error : ".$e->getMessage();
1353 1353
                 }
1354 1354
         }
1355
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1355
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1356 1356
 		global $globalDBdriver;
1357 1357
 		if ($globalDBdriver == 'mysql') {
1358 1358
 			if ($reset) {
@@ -1367,15 +1367,15 @@  discard block
 block discarded – undo
1367 1367
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1368 1368
 			}
1369 1369
 		}
1370
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1370
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1371 1371
                  try {
1372 1372
                         $sth = $this->db->prepare($query);
1373 1373
                         $sth->execute($query_values);
1374
-                } catch(PDOException $e) {
1374
+                } catch (PDOException $e) {
1375 1375
                         return "error : ".$e->getMessage();
1376 1376
                 }
1377 1377
         }
1378
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1378
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1379 1379
 		global $globalDBdriver;
1380 1380
 		if ($globalDBdriver == 'mysql') {
1381 1381
 			if ($reset) {
@@ -1390,15 +1390,15 @@  discard block
 block discarded – undo
1390 1390
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1391 1391
 			}
1392 1392
 		}
1393
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1393
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1394 1394
                  try {
1395 1395
                         $sth = $this->db->prepare($query);
1396 1396
                         $sth->execute($query_values);
1397
-                } catch(PDOException $e) {
1397
+                } catch (PDOException $e) {
1398 1398
                         return "error : ".$e->getMessage();
1399 1399
                 }
1400 1400
         }
1401
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1401
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1402 1402
 		global $globalDBdriver;
1403 1403
 		if ($airport_icao != '') {
1404 1404
 			if ($globalDBdriver == 'mysql') {
@@ -1414,16 +1414,16 @@  discard block
 block discarded – undo
1414 1414
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1415 1415
 				}
1416 1416
 			}
1417
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1417
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1418 1418
 			try {
1419 1419
 				$sth = $this->db->prepare($query);
1420 1420
 				$sth->execute($query_values);
1421
-			} catch(PDOException $e) {
1421
+			} catch (PDOException $e) {
1422 1422
 				return "error : ".$e->getMessage();
1423 1423
 			}
1424 1424
                 }
1425 1425
         }
1426
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1426
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1427 1427
 		global $globalDBdriver;
1428 1428
 		if ($airport_icao != '') {
1429 1429
 			if ($globalDBdriver == 'mysql') {
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 			} else {
1432 1432
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1433 1433
 			}
1434
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1434
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1435 1435
 			 try {
1436 1436
 				$sth = $this->db->prepare($query);
1437 1437
 				$sth->execute($query_values);
1438
-			} catch(PDOException $e) {
1438
+			} catch (PDOException $e) {
1439 1439
 				return "error : ".$e->getMessage();
1440 1440
 			}
1441 1441
                 }
1442 1442
         }
1443
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1443
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1444 1444
 		global $globalDBdriver;
1445 1445
 		if ($airport_icao != '') {
1446 1446
 			if ($globalDBdriver == 'mysql') {
@@ -1456,16 +1456,16 @@  discard block
 block discarded – undo
1456 1456
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1457 1457
 				}
1458 1458
 			}
1459
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1459
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1460 1460
 			 try {
1461 1461
                     		$sth = $this->db->prepare($query);
1462 1462
 	                        $sth->execute($query_values);
1463
-    		        } catch(PDOException $e) {
1463
+    		        } catch (PDOException $e) {
1464 1464
             		        return "error : ".$e->getMessage();
1465 1465
 	                }
1466 1466
 	        }
1467 1467
         }
1468
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1468
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1469 1469
 		global $globalDBdriver;
1470 1470
 		if ($airport_icao != '') {
1471 1471
 			if ($globalDBdriver == 'mysql') {
@@ -1473,11 +1473,11 @@  discard block
 block discarded – undo
1473 1473
 			} else {
1474 1474
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1475 1475
 			}
1476
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1476
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1477 1477
 			try {
1478 1478
 				$sth = $this->db->prepare($query);
1479 1479
 				$sth->execute($query_values);
1480
-			} catch(PDOException $e) {
1480
+			} catch (PDOException $e) {
1481 1481
 				return "error : ".$e->getMessage();
1482 1482
 			}
1483 1483
                 }
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
                  try {
1490 1490
                         $sth = $this->db->prepare($query);
1491 1491
                         $sth->execute($query_values);
1492
-                } catch(PDOException $e) {
1492
+                } catch (PDOException $e) {
1493 1493
                         return "error : ".$e->getMessage();
1494 1494
                 }
1495 1495
         }
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
                  try {
1500 1500
                         $sth = $this->db->prepare($query);
1501 1501
                         $sth->execute($query_values);
1502
-                } catch(PDOException $e) {
1502
+                } catch (PDOException $e) {
1503 1503
                         return "error : ".$e->getMessage();
1504 1504
                 }
1505 1505
         }
@@ -1509,13 +1509,13 @@  discard block
 block discarded – undo
1509 1509
                  try {
1510 1510
                         $sth = $this->db->prepare($query);
1511 1511
                         $sth->execute($query_values);
1512
-                } catch(PDOException $e) {
1512
+                } catch (PDOException $e) {
1513 1513
                         return "error : ".$e->getMessage();
1514 1514
                 }
1515 1515
         }
1516 1516
         
1517 1517
         public function addOldStats() {
1518
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1518
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1519 1519
     		$Common = new Common();
1520 1520
     		$Connection = new Connection();
1521 1521
     		date_default_timezone_set('UTC');
@@ -1533,41 +1533,41 @@  discard block
 block discarded – undo
1533 1533
 			$Spotter = new Spotter($this->db);
1534 1534
 
1535 1535
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1536
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1536
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1537 1537
 			foreach ($alldata as $number) {
1538
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1538
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1539 1539
 			}
1540 1540
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1541
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1541
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1542 1542
 			foreach ($alldata as $number) {
1543
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1543
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1544 1544
 			}
1545 1545
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1546
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1546
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1547 1547
 			foreach ($alldata as $number) {
1548
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1548
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1549 1549
 			}
1550 1550
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1551
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1551
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1552 1552
 			foreach ($alldata as $number) {
1553
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1553
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1554 1554
 			}
1555 1555
 			if ($globalDebug) echo 'Count all owners...'."\n";
1556
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1556
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1557 1557
 			foreach ($alldata as $number) {
1558
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1558
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1559 1559
 			}
1560 1560
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1561
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1561
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1562 1562
 			foreach ($alldata as $number) {
1563 1563
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
1564
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1564
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1565 1565
 			}
1566 1566
 			
1567 1567
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1568
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1568
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1569 1569
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1570
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1570
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1571 1571
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1572 1572
 	        	$alldata = array();
1573 1573
 	        	
@@ -1585,14 +1585,14 @@  discard block
 block discarded – undo
1585 1585
     			foreach ($alldata as $key => $row) {
1586 1586
     				$count[$key] = $row['airport_departure_icao_count'];
1587 1587
         		}
1588
-			array_multisort($count,SORT_DESC,$alldata);
1588
+			array_multisort($count, SORT_DESC, $alldata);
1589 1589
 			foreach ($alldata as $number) {
1590
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1590
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1591 1591
 			}
1592 1592
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1593
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1593
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1594 1594
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1595
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1595
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1596 1596
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1597 1597
 	        	$alldata = array();
1598 1598
     			foreach ($pall as $value) {
@@ -1609,18 +1609,18 @@  discard block
 block discarded – undo
1609 1609
         		foreach ($alldata as $key => $row) {
1610 1610
         			$count[$key] = $row['airport_arrival_icao_count'];
1611 1611
 	        	}
1612
-    			array_multisort($count,SORT_DESC,$alldata);
1612
+    			array_multisort($count, SORT_DESC, $alldata);
1613 1613
                         foreach ($alldata as $number) {
1614
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1614
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1615 1615
 			}
1616 1616
 			if ($Connection->tableExists('countries')) {
1617 1617
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1618 1618
 				//$SpotterArchive = new SpotterArchive();
1619 1619
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1620 1620
 				$Spotter = new Spotter($this->db);
1621
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
1621
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
1622 1622
 				foreach ($alldata as $number) {
1623
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1623
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1624 1624
 				}
1625 1625
 			}
1626 1626
 			
@@ -1629,12 +1629,12 @@  discard block
 block discarded – undo
1629 1629
 			$this->deleteStatsByType('fatalities_byyear');
1630 1630
 			$alldata = $Accident->countFatalitiesByYear();
1631 1631
 			foreach ($alldata as $number) {
1632
-				$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
1632
+				$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
1633 1633
 			}
1634 1634
 			$this->deleteStatsByType('fatalities_bymonth');
1635 1635
 			$alldata = $Accident->countFatalitiesLast12Months();
1636 1636
 			foreach ($alldata as $number) {
1637
-				$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
1637
+				$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
1638 1638
 			}
1639 1639
 
1640 1640
 
@@ -1647,37 +1647,37 @@  discard block
 block discarded – undo
1647 1647
 			$lastyear = false;
1648 1648
 			foreach ($alldata as $number) {
1649 1649
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1650
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1650
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1651 1651
 			}
1652 1652
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1653 1653
 			$alldata = $Spotter->countAllMilitaryMonths();
1654 1654
 			foreach ($alldata as $number) {
1655
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1655
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1656 1656
 			}
1657 1657
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1658 1658
 			$alldata = $Spotter->countAllMonthsOwners();
1659 1659
 			foreach ($alldata as $number) {
1660
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1660
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1661 1661
 			}
1662 1662
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1663 1663
 			$alldata = $Spotter->countAllMonthsPilots();
1664 1664
 			foreach ($alldata as $number) {
1665
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1665
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1666 1666
 			}
1667 1667
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1668 1668
 			$alldata = $Spotter->countAllMonthsAirlines();
1669 1669
 			foreach ($alldata as $number) {
1670
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1670
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1671 1671
 			}
1672 1672
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1673 1673
 			$alldata = $Spotter->countAllMonthsAircrafts();
1674 1674
 			foreach ($alldata as $number) {
1675
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1675
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1676 1676
 			}
1677 1677
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1678 1678
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1679 1679
 			foreach ($alldata as $number) {
1680
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1680
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1681 1681
 			}
1682 1682
 			if ($globalDebug) echo 'Airports data...'."\n";
1683 1683
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
     			}
1723 1723
     			$alldata = $pall;
1724 1724
 			foreach ($alldata as $number) {
1725
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1725
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1726 1726
 			}
1727 1727
 			echo '...Arrival'."\n";
1728 1728
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
     			}
1765 1765
     			$alldata = $pall;
1766 1766
 			foreach ($alldata as $number) {
1767
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1767
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1768 1768
 			}
1769 1769
 
1770 1770
 			echo 'Flights data...'."\n";
@@ -1772,28 +1772,28 @@  discard block
 block discarded – undo
1772 1772
 			echo '-> countAllDatesLastMonth...'."\n";
1773 1773
 			$alldata = $Spotter->countAllDatesLastMonth();
1774 1774
 			foreach ($alldata as $number) {
1775
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1775
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1776 1776
 			}
1777 1777
 			echo '-> countAllDates...'."\n";
1778 1778
 			$previousdata = $this->countAllDates();
1779 1779
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1780 1780
 			$this->deleteStatFlight('date');
1781
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1781
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1782 1782
 			$values = array();
1783 1783
 			foreach ($alldata as $cnt) {
1784 1784
 				$values[] = $cnt['date_count'];
1785 1785
 			}
1786
-			array_multisort($values,SORT_DESC,$alldata);
1787
-			array_splice($alldata,11);
1786
+			array_multisort($values, SORT_DESC, $alldata);
1787
+			array_splice($alldata, 11);
1788 1788
 			foreach ($alldata as $number) {
1789
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1789
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1790 1790
 			}
1791 1791
 			
1792 1792
 			$this->deleteStatFlight('hour');
1793 1793
 			echo '-> countAllHours...'."\n";
1794 1794
 			$alldata = $Spotter->countAllHours('hour');
1795 1795
 			foreach ($alldata as $number) {
1796
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1796
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1797 1797
 			}
1798 1798
 
1799 1799
 
@@ -1804,42 +1804,42 @@  discard block
 block discarded – undo
1804 1804
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1805 1805
 				$SpotterArchive = new SpotterArchive();
1806 1806
 				//$Spotter = new Spotter($this->db);
1807
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1807
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1808 1808
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1809 1809
 				foreach ($alldata as $number) {
1810
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1810
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1811 1811
 				}
1812 1812
 			}
1813 1813
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1814 1814
 			$Spotter = new Spotter($this->db);
1815
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1815
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1816 1816
 			foreach ($alldata as $number) {
1817
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1817
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1818 1818
 			}
1819 1819
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1820
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1820
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1821 1821
 			foreach ($alldata as $number) {
1822
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1822
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1823 1823
 			}
1824 1824
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1825
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1825
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1826 1826
 			foreach ($alldata as $number) {
1827
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1827
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1828 1828
 			}
1829 1829
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1830
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1830
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1831 1831
 			foreach ($alldata as $number) {
1832
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1832
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1833 1833
 			}
1834 1834
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1835
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1835
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1836 1836
 			foreach ($alldata as $number) {
1837
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1837
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1838 1838
 			}
1839 1839
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1840
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1840
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1841 1841
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1842
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1842
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1843 1843
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1844 1844
 	        	//$alldata = array();
1845 1845
     			foreach ($dall as $value) {
@@ -1859,12 +1859,12 @@  discard block
 block discarded – undo
1859 1859
     			}
1860 1860
     			$alldata = $pall;
1861 1861
 			foreach ($alldata as $number) {
1862
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1862
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
1863 1863
 			}
1864 1864
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1865
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1865
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1866 1866
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1867
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1867
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1868 1868
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1869 1869
 	        	//$alldata = array();
1870 1870
     			foreach ($dall as $value) {
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
     			}
1885 1885
     			$alldata = $pall;
1886 1886
                         foreach ($alldata as $number) {
1887
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1887
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
1888 1888
 			}
1889 1889
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1890 1890
 			$Spotter = new Spotter($this->db);
@@ -1892,27 +1892,27 @@  discard block
 block discarded – undo
1892 1892
 			$lastyear = false;
1893 1893
 			foreach ($alldata as $number) {
1894 1894
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1895
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1895
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1896 1896
 			}
1897 1897
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1898 1898
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1899 1899
 			foreach ($alldata as $number) {
1900
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1900
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1901 1901
 			}
1902 1902
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1903 1903
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1904 1904
 			foreach ($alldata as $number) {
1905
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1905
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1906 1906
 			}
1907 1907
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1908 1908
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1909 1909
 			foreach ($alldata as $number) {
1910
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1910
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1911 1911
 			}
1912 1912
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1913 1913
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1914 1914
 			foreach ($alldata as $number) {
1915
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1915
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1916 1916
 			}
1917 1917
 			if ($globalDebug) echo '...Departure'."\n";
1918 1918
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
     			}
1936 1936
     			$alldata = $pall;
1937 1937
 			foreach ($alldata as $number) {
1938
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1938
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
1939 1939
 			}
1940 1940
 			if ($globalDebug) echo '...Arrival'."\n";
1941 1941
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1958,32 +1958,32 @@  discard block
 block discarded – undo
1958 1958
     			}
1959 1959
     			$alldata = $pall;
1960 1960
 			foreach ($alldata as $number) {
1961
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1961
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
1962 1962
 			}
1963 1963
 
1964 1964
 			if ($globalDebug) echo 'Flights data...'."\n";
1965 1965
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1966 1966
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1967 1967
 			foreach ($alldata as $number) {
1968
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1968
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1969 1969
 			}
1970 1970
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1971 1971
 			//$previousdata = $this->countAllDatesByAirlines();
1972
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1972
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1973 1973
 			$values = array();
1974 1974
 			foreach ($alldata as $cnt) {
1975 1975
 				$values[] = $cnt['date_count'];
1976 1976
 			}
1977
-			array_multisort($values,SORT_DESC,$alldata);
1978
-			array_splice($alldata,11);
1977
+			array_multisort($values, SORT_DESC, $alldata);
1978
+			array_splice($alldata, 11);
1979 1979
 			foreach ($alldata as $number) {
1980
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1980
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1981 1981
 			}
1982 1982
 			
1983 1983
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1984 1984
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1985 1985
 			foreach ($alldata as $number) {
1986
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1986
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1987 1987
 			}
1988 1988
 			
1989 1989
 
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
 						$last_update_day = date('Y').'-01-01 00:00:00';
2008 2008
 					}
2009 2009
 				}
2010
-				if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2010
+				if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2011 2011
 					$last_update_day = date('Y').'-01-01 00:00:00';
2012 2012
 					$reset = true;
2013 2013
 				}
@@ -2016,32 +2016,32 @@  discard block
 block discarded – undo
2016 2016
 				// Count by filter
2017 2017
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2018 2018
 				$Spotter = new Spotter($this->db);
2019
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2019
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2020 2020
 				foreach ($alldata as $number) {
2021
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2021
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2022 2022
 				}
2023
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2023
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2024 2024
 				foreach ($alldata as $number) {
2025
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2025
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2026 2026
 				}
2027
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2027
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2028 2028
 				foreach ($alldata as $number) {
2029
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2029
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2030 2030
 				}
2031
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2031
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2032 2032
 				foreach ($alldata as $number) {
2033
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2033
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2034 2034
 				}
2035
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2035
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2036 2036
 				foreach ($alldata as $number) {
2037
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2037
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2038 2038
 				}
2039
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2039
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2040 2040
 				foreach ($alldata as $number) {
2041
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2041
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2042 2042
 				}
2043
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2044
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2043
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2044
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2045 2045
 		        	$alldata = array();
2046 2046
 	    			foreach ($pall as $value) {
2047 2047
 		        		$icao = $value['airport_departure_icao'];
@@ -2057,12 +2057,12 @@  discard block
 block discarded – undo
2057 2057
     				foreach ($alldata as $key => $row) {
2058 2058
     					$count[$key] = $row['airport_departure_icao_count'];
2059 2059
     				}
2060
-				array_multisort($count,SORT_DESC,$alldata);
2060
+				array_multisort($count, SORT_DESC, $alldata);
2061 2061
 				foreach ($alldata as $number) {
2062
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2062
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
2063 2063
 				}
2064
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2065
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2064
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2065
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2066 2066
 				$alldata = array();
2067 2067
     				foreach ($pall as $value) {
2068 2068
 		        		$icao = $value['airport_arrival_icao'];
@@ -2078,40 +2078,40 @@  discard block
 block discarded – undo
2078 2078
         			foreach ($alldata as $key => $row) {
2079 2079
     					$count[$key] = $row['airport_arrival_icao_count'];
2080 2080
 		        	}
2081
-        			array_multisort($count,SORT_DESC,$alldata);
2081
+        			array_multisort($count, SORT_DESC, $alldata);
2082 2082
 				foreach ($alldata as $number) {
2083
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2083
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2084 2084
 				}
2085 2085
 				$Spotter = new Spotter($this->db);
2086 2086
 				$alldata = $Spotter->countAllMonths($filter);
2087 2087
 				$lastyear = false;
2088 2088
 				foreach ($alldata as $number) {
2089 2089
 					if ($number['year_name'] != date('Y')) $lastyear = true;
2090
-					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2090
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2091 2091
 				}
2092 2092
 				$alldata = $Spotter->countAllMonthsOwners($filter);
2093 2093
 				foreach ($alldata as $number) {
2094
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2094
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2095 2095
 				}
2096 2096
 				$alldata = $Spotter->countAllMonthsPilots($filter);
2097 2097
 				foreach ($alldata as $number) {
2098
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2098
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2099 2099
 				}
2100 2100
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
2101 2101
 				foreach ($alldata as $number) {
2102
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2102
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2103 2103
 				}
2104 2104
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
2105 2105
 				foreach ($alldata as $number) {
2106
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2106
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2107 2107
 				}
2108 2108
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2109 2109
 				foreach ($alldata as $number) {
2110
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2110
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2111 2111
 				}
2112 2112
 				echo '...Departure'."\n";
2113
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2114
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2113
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2114
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2115 2115
 				foreach ($dall as $value) {
2116 2116
     					$icao = $value['departure_airport_icao'];
2117 2117
     					$ddate = $value['date'];
@@ -2129,11 +2129,11 @@  discard block
 block discarded – undo
2129 2129
     				}
2130 2130
 	    			$alldata = $pall;
2131 2131
 				foreach ($alldata as $number) {
2132
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2132
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
2133 2133
 				}
2134 2134
 				echo '...Arrival'."\n";
2135
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2136
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2135
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2136
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2137 2137
 				foreach ($dall as $value) {
2138 2138
 					$icao = $value['arrival_airport_icao'];
2139 2139
 					$ddate = $value['date'];
@@ -2151,40 +2151,40 @@  discard block
 block discarded – undo
2151 2151
     				}
2152 2152
     				$alldata = $pall;
2153 2153
 				foreach ($alldata as $number) {
2154
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2154
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
2155 2155
 				}
2156 2156
     
2157 2157
 				echo 'Flights data...'."\n";
2158 2158
 				echo '-> countAllDatesLastMonth...'."\n";
2159 2159
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2160 2160
 				foreach ($alldata as $number) {
2161
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2161
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2162 2162
 				}
2163 2163
 				echo '-> countAllDates...'."\n";
2164
-				$previousdata = $this->countAllDates('',$filter_name);
2165
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2164
+				$previousdata = $this->countAllDates('', $filter_name);
2165
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2166 2166
 				$values = array();
2167 2167
 				foreach ($alldata as $cnt) {
2168 2168
 					$values[] = $cnt['date_count'];
2169 2169
 				}
2170
-				array_multisort($values,SORT_DESC,$alldata);
2171
-				array_splice($alldata,11);
2170
+				array_multisort($values, SORT_DESC, $alldata);
2171
+				array_splice($alldata, 11);
2172 2172
 				foreach ($alldata as $number) {
2173
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2173
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2174 2174
 				}
2175 2175
 				
2176 2176
 				echo '-> countAllHours...'."\n";
2177
-				$alldata = $Spotter->countAllHours('hour',$filter);
2177
+				$alldata = $Spotter->countAllHours('hour', $filter);
2178 2178
 				foreach ($alldata as $number) {
2179
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2179
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2180 2180
 				}
2181 2181
 				echo 'Insert last stats update date...'."\n";
2182 2182
 				date_default_timezone_set('UTC');
2183
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2183
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2184 2184
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2185
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2185
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2186 2186
 						$this->deleteOldStats($filter_name);
2187
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2187
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2188 2188
 					}
2189 2189
 				}
2190 2190
 
@@ -2197,16 +2197,16 @@  discard block
 block discarded – undo
2197 2197
 				// SUM all previous month to put as year
2198 2198
 				$previous_year = date('Y');
2199 2199
 				$previous_year--;
2200
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2201
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2202
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2203
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2200
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2201
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2202
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2203
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2204 2204
 				$allairlines = $this->getAllAirlineNames();
2205 2205
 				foreach ($allairlines as $data) {
2206
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2207
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2208
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2209
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2206
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2207
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2208
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2209
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2210 2210
 				}
2211 2211
 				
2212 2212
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2215,7 +2215,7 @@  discard block
 block discarded – undo
2215 2215
 						try {
2216 2216
 							$sth = $this->db->prepare($query);
2217 2217
 							$sth->execute();
2218
-						} catch(PDOException $e) {
2218
+						} catch (PDOException $e) {
2219 2219
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2220 2220
 						}
2221 2221
 					}
@@ -2224,15 +2224,15 @@  discard block
 block discarded – undo
2224 2224
 					try {
2225 2225
 						$sth = $this->db->prepare($query);
2226 2226
 						$sth->execute();
2227
-					} catch(PDOException $e) {
2227
+					} catch (PDOException $e) {
2228 2228
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2229 2229
 					}
2230 2230
 				}
2231 2231
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2232 2232
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2233
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2233
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2234 2234
 						$this->deleteOldStats();
2235
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2235
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2236 2236
 						$lastyearupdate = true;
2237 2237
 					}
2238 2238
 				}
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 					try {
2255 2255
 						$sth = $this->db->prepare($query);
2256 2256
 						$sth->execute();
2257
-					} catch(PDOException $e) {
2257
+					} catch (PDOException $e) {
2258 2258
 						return "error : ".$e->getMessage();
2259 2259
 					}
2260 2260
 				}
@@ -2268,14 +2268,14 @@  discard block
 block discarded – undo
2268 2268
 				try {
2269 2269
 					$sth = $this->db->prepare($query);
2270 2270
 					$sth->execute();
2271
-				} catch(PDOException $e) {
2271
+				} catch (PDOException $e) {
2272 2272
 					return "error : ".$e->getMessage();
2273 2273
 				}
2274 2274
 			}
2275 2275
 			if (!isset($lastyearupdate)) {
2276 2276
 				echo 'Insert last stats update date...'."\n";
2277 2277
 				date_default_timezone_set('UTC');
2278
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2278
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2279 2279
 			}
2280 2280
 			if ($globalStatsResetYear) {
2281 2281
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 40;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalDBdriver, $globalNoDB;
11 11
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 			if ($user === null && $pass === null) {
17 17
 			    $this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+			    $this->createDBConnection(null, $user, $pass);
20 20
 			}
21 21
 		    } else {
22 22
 			$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			//$Connection = new Connection();
155 155
 			$results = $this->db->query($query);
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return false;
158 158
 		}
159
-		if($results->rowCount()>0) {
159
+		if ($results->rowCount() > 0) {
160 160
 		    return true; 
161 161
 		}
162 162
 		else return false;
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 			     return false;
178 178
 			}
179 179
 			
180
-		} catch(PDOException $e) {
181
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
180
+		} catch (PDOException $e) {
181
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182 182
             			throw $e;
183 183
 	                }
184 184
 	                //echo 'error ! '.$e->getMessage();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	/*
191 191
 	* Check if index exist
192 192
 	*/
193
-	public function indexExists($table,$index)
193
+	public function indexExists($table, $index)
194 194
 	{
195 195
 		global $globalDBdriver, $globalDBname;
196 196
 		if ($globalDBdriver == 'mysql') {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 		try {
202 202
 			//$Connection = new Connection();
203 203
 			$results = $this->db->query($query);
204
-		} catch(PDOException $e) {
204
+		} catch (PDOException $e) {
205 205
 			return false;
206 206
 		}
207 207
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
208
-		if($nb[0]['nb'] > 0) {
208
+		if ($nb[0]['nb'] > 0) {
209 209
 			return true; 
210 210
 		}
211 211
 		else return false;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$query = "SELECT * FROM ".$table." LIMIT 0";
221 221
 		try {
222 222
 			$results = $this->db->query($query);
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			return "error : ".$e->getMessage()."\n";
225 225
 		}
226 226
 		$columns = array();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		return $columns;
233 233
 	}
234 234
 
235
-	public function getColumnType($table,$column) {
235
+	public function getColumnType($table, $column) {
236 236
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
237 237
 		$tomet = $select->getColumnMeta(0);
238 238
 		return $tomet['native_type'];
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	* Check if a column name exist in a table
243 243
 	* @return Boolean column exist or not
244 244
 	*/
245
-	public function checkColumnName($table,$name)
245
+	public function checkColumnName($table, $name)
246 246
 	{
247 247
 		global $globalDBdriver, $globalDBname;
248 248
 		if ($globalDBdriver == 'mysql') {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 			try {
254 254
 				$sth = $this->db()->prepare($query);
255
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
256
-			} catch(PDOException $e) {
255
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
256
+			} catch (PDOException $e) {
257 257
 				echo "error : ".$e->getMessage()."\n";
258 258
 			}
259 259
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute();
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					return "error : ".$e->getMessage()."\n";
297 297
 				}
298 298
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
 		global $globalDBdriver;
1578 1578
 		$Connection = new Connection();
1579 1579
 		$error = '';
1580
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1580
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1581 1581
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584 1584
 				$sth->execute();
1585
-			} catch(PDOException $e) {
1585
+			} catch (PDOException $e) {
1586 1586
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1587 1587
 			}
1588 1588
 		}
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		try {
1649 1649
 			$sth = $Connection->db->prepare($query);
1650 1650
 			$sth->execute();
1651
-		} catch(PDOException $e) {
1651
+		} catch (PDOException $e) {
1652 1652
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1653 1653
 		}
1654 1654
 		return $error;
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 			try {
1697 1697
 				$sth = $Connection->db->prepare($query);
1698 1698
 				$sth->execute();
1699
-			} catch(PDOException $e) {
1699
+			} catch (PDOException $e) {
1700 1700
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1701 1701
 			}
1702 1702
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1705,18 +1705,18 @@  discard block
 block discarded – undo
1705 1705
 				try {
1706 1706
 					$sth = $Connection->db->prepare($query);
1707 1707
 					$sth->execute();
1708
-				} catch(PDOException $e) {
1708
+				} catch (PDOException $e) {
1709 1709
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1710 1710
 				}
1711 1711
 			}
1712 1712
 		}
1713
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1713
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1714 1714
 			// Add index key
1715 1715
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1716 1716
 			try {
1717 1717
 				$sth = $Connection->db->prepare($query);
1718 1718
 				$sth->execute();
1719
-			} catch(PDOException $e) {
1719
+			} catch (PDOException $e) {
1720 1720
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1721 1721
 			}
1722 1722
                 }
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 		try {
1725 1725
 			$sth = $Connection->db->prepare($query);
1726 1726
 			$sth->execute();
1727
-		} catch(PDOException $e) {
1727
+		} catch (PDOException $e) {
1728 1728
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1729 1729
 		}
1730 1730
 		return $error;
@@ -1735,148 +1735,148 @@  discard block
 block discarded – undo
1735 1735
 		$Connection = new Connection();
1736 1736
 		$error = '';
1737 1737
 		if ($globalDBdriver == 'mysql') {
1738
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1738
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1739 1739
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1740 1740
 				try {
1741 1741
 					$sth = $Connection->db->prepare($query);
1742 1742
 					$sth->execute();
1743
-				} catch(PDOException $e) {
1743
+				} catch (PDOException $e) {
1744 1744
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1745 1745
 				}
1746 1746
 			}
1747
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1747
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1748 1748
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1749 1749
 				try {
1750 1750
 					$sth = $Connection->db->prepare($query);
1751 1751
 					$sth->execute();
1752
-				} catch(PDOException $e) {
1752
+				} catch (PDOException $e) {
1753 1753
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1754 1754
 				}
1755 1755
 			}
1756
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1756
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1757 1757
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1758 1758
 				try {
1759 1759
 					$sth = $Connection->db->prepare($query);
1760 1760
 					$sth->execute();
1761
-				} catch(PDOException $e) {
1761
+				} catch (PDOException $e) {
1762 1762
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1763 1763
 				}
1764 1764
 			}
1765
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1765
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1766 1766
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1767 1767
 				try {
1768 1768
 					$sth = $Connection->db->prepare($query);
1769 1769
 					$sth->execute();
1770
-				} catch(PDOException $e) {
1770
+				} catch (PDOException $e) {
1771 1771
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1772 1772
 				}
1773 1773
 			}
1774
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1774
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1775 1775
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1776 1776
 				try {
1777 1777
 					$sth = $Connection->db->prepare($query);
1778 1778
 					$sth->execute();
1779
-				} catch(PDOException $e) {
1779
+				} catch (PDOException $e) {
1780 1780
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1781 1781
 				}
1782 1782
 			}
1783
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1783
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1784 1784
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1785 1785
 				try {
1786 1786
 					$sth = $Connection->db->prepare($query);
1787 1787
 					$sth->execute();
1788
-				} catch(PDOException $e) {
1788
+				} catch (PDOException $e) {
1789 1789
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1790 1790
 				}
1791 1791
 			}
1792
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1792
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1793 1793
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1794 1794
 				try {
1795 1795
 					$sth = $Connection->db->prepare($query);
1796 1796
 					$sth->execute();
1797
-				} catch(PDOException $e) {
1797
+				} catch (PDOException $e) {
1798 1798
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1799 1799
 				}
1800 1800
 			}
1801
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1801
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1802 1802
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1803 1803
 				try {
1804 1804
 					$sth = $Connection->db->prepare($query);
1805 1805
 					$sth->execute();
1806
-				} catch(PDOException $e) {
1806
+				} catch (PDOException $e) {
1807 1807
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1808 1808
 				}
1809 1809
 			}
1810 1810
 		} else {
1811
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1811
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1812 1812
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1813 1813
 				try {
1814 1814
 					$sth = $Connection->db->prepare($query);
1815 1815
 					$sth->execute();
1816
-				} catch(PDOException $e) {
1816
+				} catch (PDOException $e) {
1817 1817
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1818 1818
 				}
1819 1819
 			}
1820
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1820
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1821 1821
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1822 1822
 				try {
1823 1823
 					$sth = $Connection->db->prepare($query);
1824 1824
 					$sth->execute();
1825
-				} catch(PDOException $e) {
1825
+				} catch (PDOException $e) {
1826 1826
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1827 1827
 				}
1828 1828
 			}
1829
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1829
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1830 1830
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1831 1831
 				try {
1832 1832
 					$sth = $Connection->db->prepare($query);
1833 1833
 					$sth->execute();
1834
-				} catch(PDOException $e) {
1834
+				} catch (PDOException $e) {
1835 1835
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1836 1836
 				}
1837 1837
 			}
1838
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1838
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1839 1839
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1840 1840
 				try {
1841 1841
 					$sth = $Connection->db->prepare($query);
1842 1842
 					$sth->execute();
1843
-				} catch(PDOException $e) {
1843
+				} catch (PDOException $e) {
1844 1844
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1845 1845
 				}
1846 1846
 			}
1847
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1847
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1848 1848
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1849 1849
 				try {
1850 1850
 					$sth = $Connection->db->prepare($query);
1851 1851
 					$sth->execute();
1852
-				} catch(PDOException $e) {
1852
+				} catch (PDOException $e) {
1853 1853
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1854 1854
 				}
1855 1855
 			}
1856
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1856
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1857 1857
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1858 1858
 				try {
1859 1859
 					$sth = $Connection->db->prepare($query);
1860 1860
 					$sth->execute();
1861
-				} catch(PDOException $e) {
1861
+				} catch (PDOException $e) {
1862 1862
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1863 1863
 				}
1864 1864
 			}
1865
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1865
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1866 1866
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1867 1867
 				try {
1868 1868
 					$sth = $Connection->db->prepare($query);
1869 1869
 					$sth->execute();
1870
-				} catch(PDOException $e) {
1870
+				} catch (PDOException $e) {
1871 1871
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1872 1872
 				}
1873 1873
 			}
1874
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1874
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1875 1875
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1876 1876
 				try {
1877 1877
 					$sth = $Connection->db->prepare($query);
1878 1878
 					$sth->execute();
1879
-				} catch(PDOException $e) {
1879
+				} catch (PDOException $e) {
1880 1880
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1881 1881
 				}
1882 1882
 			}
@@ -1885,7 +1885,7 @@  discard block
 block discarded – undo
1885 1885
 		try {
1886 1886
 			$sth = $Connection->db->prepare($query);
1887 1887
 			$sth->execute();
1888
-		} catch(PDOException $e) {
1888
+		} catch (PDOException $e) {
1889 1889
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1890 1890
 		}
1891 1891
 		return $error;
@@ -1900,14 +1900,14 @@  discard block
 block discarded – undo
1900 1900
 			try {
1901 1901
 				$sth = $Connection->db->prepare($query);
1902 1902
 				$sth->execute();
1903
-			} catch(PDOException $e) {
1903
+			} catch (PDOException $e) {
1904 1904
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1905 1905
 			}
1906 1906
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1907 1907
 			try {
1908 1908
 				$sth = $Connection->db->prepare($query);
1909 1909
 				$sth->execute();
1910
-			} catch(PDOException $e) {
1910
+			} catch (PDOException $e) {
1911 1911
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1912 1912
 			}
1913 1913
 		} else {
@@ -1915,14 +1915,14 @@  discard block
 block discarded – undo
1915 1915
 			try {
1916 1916
 				$sth = $Connection->db->prepare($query);
1917 1917
 				$sth->execute();
1918
-			} catch(PDOException $e) {
1918
+			} catch (PDOException $e) {
1919 1919
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1920 1920
 			}
1921 1921
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1922 1922
 			try {
1923 1923
 				$sth = $Connection->db->prepare($query);
1924 1924
 				$sth->execute();
1925
-			} catch(PDOException $e) {
1925
+			} catch (PDOException $e) {
1926 1926
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1927 1927
 			}
1928 1928
 		}
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 		try {
1931 1931
 			$sth = $Connection->db->prepare($query);
1932 1932
 			$sth->execute();
1933
-		} catch(PDOException $e) {
1933
+		} catch (PDOException $e) {
1934 1934
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1935 1935
 		}
1936 1936
 		return $error;
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 		    try {
1953 1953
             		$sth = $Connection->db->prepare($query);
1954 1954
 		        $sth->execute();
1955
-		    } catch(PDOException $e) {
1955
+		    } catch (PDOException $e) {
1956 1956
 			return "error : ".$e->getMessage()."\n";
1957 1957
     		    }
1958 1958
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         	    exit(0);
152 152
         	}
153 153
     	    */
154
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
155 155
         	//$formats[$id] = 'planeupdatefaa';
156 156
         	$globalSources[$id]['format'] = 'planeupdatefaa';
157 157
         	//$last_exec['planeupdatefaa'] = 0;
@@ -160,26 +160,26 @@  discard block
 block discarded – undo
160 160
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 161
         	    exit(0);
162 162
         	}
163
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
164 164
         	//$formats[$id] = 'phpvmacars';
165 165
         	$globalSources[$id]['format'] = 'phpvmacars';
166 166
         	//$last_exec['phpvmacars'] = 0;
167 167
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
169 169
         	//$formats[$id] = 'phpvmacars';
170 170
         	$globalSources[$id]['format'] = 'vam';
171 171
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
-            } else if (preg_match('/whazzup/i',$host)) {
172
+            } else if (preg_match('/whazzup/i', $host)) {
173 173
         	//$formats[$id] = 'whazzup';
174 174
         	$globalSources[$id]['format'] = 'whazzup';
175 175
         	//$last_exec['whazzup'] = 0;
176 176
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
-            } else if (preg_match('/recentpireps/i',$host)) {
177
+            } else if (preg_match('/recentpireps/i', $host)) {
178 178
         	//$formats[$id] = 'pirepsjson';
179 179
         	$globalSources[$id]['format'] = 'pirepsjson';
180 180
         	//$last_exec['pirepsjson'] = 0;
181 181
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
183 183
         	//$formats[$id] = 'fr24json';
184 184
         	$globalSources[$id]['format'] = 'fr24json';
185 185
         	//$last_exec['fr24json'] = 0;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 189
         	    exit(0);
190 190
         	}
191
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
191
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
192 192
         	//$formats[$id] = 'fr24json';
193 193
         	$globalSources[$id]['format'] = 'myshiptracking';
194 194
         	//$last_exec['fr24json'] = 0;
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
         	    exit(0);
199 199
         	}
200 200
             //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
201
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 202
         	//$formats[$id] = 'tsv';
203 203
         	$globalSources[$id]['format'] = 'tsv';
204 204
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205 205
             }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
206
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
207 207
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
208
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
209 209
     		    if ($idf !== false) {
210 210
     			$httpfeeds[$id] = $idf;
211 211
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212 212
     		    }
213 213
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214 214
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
215
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
216
+	    $hostport = explode(':', $host);
217 217
 	    if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
@@ -223,19 +223,19 @@  discard block
 block discarded – undo
223 223
 	    }
224 224
 	    $Common = new Common();
225 225
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
226
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
227 227
     	    } else {
228
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
228
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
229 229
 	    }
230 230
 	    if ($s) {
231 231
     	        $sockets[$id] = $s;
232 232
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
233
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
234 234
 			//$formats[$id] = 'aprs';
235 235
 			$globalSources[$id]['format'] = 'aprs';
236 236
 			//$aprs_connect = 0;
237 237
 			//$use_aprs = true;
238
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
238
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
239 239
 			$globalSources[$id]['format'] = 'vrstcp';
240 240
     		    } elseif ($port == '10001') {
241 241
         		//$formats[$id] = 'tsv';
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
275 275
 else $timeout = 20;
276 276
 $errno = '';
277
-$errstr='';
277
+$errstr = '';
278 278
 
279 279
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
280 280
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 //connect_all($globalSources);
283 283
 
284 284
 if (isset($globalProxy) && $globalProxy) {
285
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
285
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
286 286
 } else {
287 287
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
288 288
 }
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 
310 310
 if ($use_aprs) {
311 311
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
312
-	$APRS=new APRS();
312
+	$APRS = new APRS();
313 313
 	$aprs_connect = 0;
314 314
 	$aprs_keep = 120;
315 315
 	$aprs_last_tx = time();
316 316
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
317
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
317
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
318 318
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
319
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
319
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
320 320
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
321
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
321
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
322 322
 	if ($aprs_full) $aprs_filter = '';
323 323
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
324 324
 	else $aprs_pass = '-1';
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 sleep(1);
333 333
 if ($globalDebug) echo "SCAN MODE \n\n";
334 334
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
335
-$endtime = time()+$globalCronEnd;
335
+$endtime = time() + $globalCronEnd;
336 336
 $i = 1;
337 337
 $tt = array();
338 338
 // Delete all ATC
339 339
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
340
-	$ATC=new ATC($Connection->db);
340
+	$ATC = new ATC($Connection->db);
341 341
 }
342 342
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
343 343
 	$ATC->deleteAll();
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 347
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
348
+    if (!$globalDaemon) $i = $endtime - time();
349 349
     // Delete old ATC
350 350
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	}
361 361
 	if ($max != $globalMinFetch) {
362 362
 	    if ($globalDebug) echo 'Sleeping...'."\n";
363
-	    sleep($globalMinFetch-$max+2);
363
+	    sleep($globalMinFetch - $max + 2);
364 364
 	}
365 365
     }
366 366
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	    //$buffer = $Common->getData($hosts[$id]);
374 374
 	    $buffer = $Common->getData($value['host']);
375 375
 	    if ($buffer != '') $reset = 0;
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    foreach ($buffer as $line) {
379 379
     		if ($line != '' && count($line) > 7) {
380 380
     		    $line = explode(',', $line);
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
     	    $last_exec[$id]['last'] = time();
403 403
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
404 404
 	    date_default_timezone_set('CET');
405
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
405
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
406 406
 	    date_default_timezone_set('UTC');
407 407
 	    if ($buffer != '') $reset = 0;
408
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
-	    $buffer = explode('\n',$buffer);
408
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
409
+	    $buffer = explode('\n', $buffer);
410 410
 	    foreach ($buffer as $line) {
411 411
 		if ($line != '') {
412 412
 		    echo "'".$line."'\n";
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425 425
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426 426
 		    if (isset($ais_data['timestamp'])) {
427
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
427
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
428 428
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
429 429
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430 430
 			    $add = true;
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 	    $w = $e = null;
448 448
 	    
449 449
 	    if (isset($arr[$id])) {
450
-		$nn = stream_select($arr,$w,$e,$timeout);
450
+		$nn = stream_select($arr, $w, $e, $timeout);
451 451
 		if ($nn > 0) {
452 452
 		    foreach ($httpfeeds as $feed) {
453
-			$buffer = stream_get_line($feed,2000,"\n");
454
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455
-			$buffer = explode('\n',$buffer);
453
+			$buffer = stream_get_line($feed, 2000, "\n");
454
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
455
+			$buffer = explode('\n', $buffer);
456 456
 			foreach ($buffer as $line) {
457 457
 			    if ($line != '') {
458 458
 				$ais_data = $AIS->parse_line(trim($line));
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
471 471
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
472 472
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
473
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
474 474
 				if (isset($ais_data['timestamp'])) {
475
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
475
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
476 476
 				} else {
477 477
 				    $data['datetime'] = date('Y-m-d H:i:s');
478 478
 				}
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 	    }
500 500
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
501
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
501
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
502 502
 	    if ($buffer != '') {
503 503
 		//echo $buffer;
504
-		$all_data = json_decode($buffer,true);
504
+		$all_data = json_decode($buffer, true);
505 505
 		//print_r($all_data);
506 506
 		if (isset($all_data[0]['DATA'])) {
507 507
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
517 517
 			$data['imo'] = $line['IMO'];
518 518
 			//$data['arrival_code'] = $ais_data['destination'];
519
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
519
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
520 520
 			$data['format_source'] = 'myshiptracking';
521 521
 			$data['id_source'] = $id_source;
522 522
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
 	    }
530 530
     	    $last_exec[$id]['last'] = time();
531 531
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
532
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
532
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
533 533
 	    if ($buffer != '') {
534
-		$all_data = json_decode($buffer,true);
534
+		$all_data = json_decode($buffer, true);
535 535
 		if (isset($all_data[0]['mmsi'])) {
536 536
 		    foreach ($all_data as $line) {
537 537
 			if ($line != '') {
@@ -559,27 +559,27 @@  discard block
 block discarded – undo
559 559
     	    $last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
561 561
 	    echo 'download...';
562
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
562
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
563 563
 	    echo 'done !'."\n";
564 564
 	    if ($buffer != '') $reset = 0;
565
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
566
-	    $buffer = explode('\n',$buffer);
565
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
566
+	    $buffer = explode('\n', $buffer);
567 567
 	    foreach ($buffer as $line) {
568 568
 		if ($line != '') {
569 569
 		    $data = array();
570
-		    $data['mmsi'] = (int)substr($line,0,9);
571
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
570
+		    $data['mmsi'] = (int) substr($line, 0, 9);
571
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
572 572
 		    //$data['status'] = substr($line,21,2);
573 573
 		    //$data['type'] = substr($line,24,3);
574
-		    $data['latitude'] = substr($line,29,9);
575
-		    $data['longitude'] = substr($line,41,9);
576
-		    $data['speed'] = round(substr($line,51,5));
574
+		    $data['latitude'] = substr($line, 29, 9);
575
+		    $data['longitude'] = substr($line, 41, 9);
576
+		    $data['speed'] = round(substr($line, 51, 5));
577 577
 		    //$data['course'] = substr($line,57,5);
578
-		    $data['heading'] = round(substr($line,63,3));
578
+		    $data['heading'] = round(substr($line, 63, 3));
579 579
 		    //$data['draft'] = substr($line,67,4);
580 580
 		    //$data['length'] = substr($line,72,3);
581 581
 		    //$data['beam'] = substr($line,76,2);
582
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
582
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
583 583
 		    //$data['callsign'] = trim(substr($line,100,7);
584 584
 		    //$data['dest'] = substr($line,108,20);
585 585
 		    //$data['etaDate'] = substr($line,129,5);
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
599 599
 	    //$buffer = $Common->getData($hosts[$id]);
600 600
 	    $buffer = $Common->getData($value['host']);
601
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
602
-	    $buffer = explode('\n',$buffer);
601
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
602
+	    $buffer = explode('\n', $buffer);
603 603
 	    $reset = 0;
604 604
 	    foreach ($buffer as $line) {
605 605
     		if ($line != '') {
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
611 611
 			$data['pilot_id'] = $line[1];
612 612
 			$data['pilot_name'] = $line[2];
613
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
613
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
614 614
 			$data['ident'] = $line[0]; // ident
615 615
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
616 616
 			$data['speed'] = $line[8]; // speed
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
627 627
 			//if (isset($line[37])) $data['last_update'] = $line[37];
628 628
 		        $data['departure_airport_icao'] = $line[11];
629
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
629
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
630 630
 		        $data['arrival_airport_icao'] = $line[13];
631 631
 			$data['frequency'] = $line[4];
632 632
 			$data['type'] = $line[18];
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
     			$data['id_source'] = $id_source;
636 636
 	    		//$data['arrival_airport_time'] = ;
637 637
 	    		if ($line[9] != '') {
638
-	    		    $aircraft_data = explode('/',$line[9]);
638
+	    		    $aircraft_data = explode('/', $line[9]);
639 639
 	    		    if (isset($aircraft_data[1])) {
640 640
 	    			$data['aircraft_icao'] = $aircraft_data[1];
641 641
 	    		    }
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
     			if ($line[3] == 'PILOT') $SI->add($data);
651 651
 			elseif ($line[3] == 'ATC') {
652 652
 				//print_r($data);
653
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
654
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
655
-				$typec = substr($data['ident'],-3);
653
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
654
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
655
+				$typec = substr($data['ident'], -3);
656 656
 				if ($typec == 'APP') $data['type'] = 'Approach';
657 657
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
658 658
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
664 664
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
665 665
 				if (!isset($data['source_name'])) $data['source_name'] = '';
666
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
666
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
667 667
 			}
668 668
     			unset($data);
669 669
     		    }
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
     	    $last_exec[$id]['last'] = time();
675 675
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
676 676
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
677
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
677
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
678 678
 	    if ($buffer != '') {
679
-	    $all_data = json_decode($buffer,true);
679
+	    $all_data = json_decode($buffer, true);
680 680
 	    if (isset($all_data['acList'])) {
681 681
 		$reset = 0;
682 682
 		foreach ($all_data['acList'] as $line) {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 		    $data['emergency'] = ''; // emergency
694 694
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
695 695
 		    
696
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
696
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
697 697
 		    else $data['datetime'] = date('Y-m-d H:i:s');
698 698
 		    
699 699
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
720 720
 		    $data['squawk'] = $line['squawk']; // squawk
721 721
 		    $data['emergency'] = ''; // emergency
722
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
722
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
723 723
 		    else $data['datetime'] = date('Y-m-d H:i:s');
724 724
 	    	    $data['format_source'] = 'aircraftlistjson';
725 725
     		    $data['id_source'] = $id_source;
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
736 736
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
737 737
 	    $buffer = $Common->getData($value['host']);
738
-	    $all_data = json_decode($buffer,true);
738
+	    $all_data = json_decode($buffer, true);
739 739
 	    if (isset($all_data['planes'])) {
740 740
 		$reset = 0;
741 741
 		foreach ($all_data['planes'] as $key => $line) {
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 		    $data['emergency'] = ''; // emergency
753 753
 		    $data['registration'] = $line[2];
754 754
 		    $data['aircraft_icao'] = $line[0];
755
-		    $deparr = explode('-',$line[1]);
755
+		    $deparr = explode('-', $line[1]);
756 756
 		    if (count($deparr) == 2) {
757 757
 			$data['departure_airport_icao'] = $deparr[0];
758 758
 			$data['arrival_airport_icao'] = $deparr[1];
759 759
 		    }
760
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
760
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
761 761
 	    	    $data['format_source'] = 'planeupdatefaa';
762 762
     		    $data['id_source'] = $id_source;
763 763
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
     	    $last_exec[$id]['last'] = time();
771 771
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
772 772
 	    $buffer = $Common->getData($value['host']);
773
-	    $all_data = json_decode($buffer,true);
773
+	    $all_data = json_decode($buffer, true);
774 774
 	    if (isset($all_data['states'])) {
775 775
 		$reset = 0;
776 776
 		foreach ($all_data['states'] as $key => $line) {
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		    //$data['emergency'] = ''; // emergency
788 788
 		    //$data['registration'] = $line[2];
789 789
 		    //$data['aircraft_icao'] = $line[0];
790
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
790
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
791 791
 	    	    $data['format_source'] = 'opensky';
792 792
     		    $data['id_source'] = $id_source;
793 793
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
802 802
 	    //$buffer = $Common->getData($hosts[$id]);
803 803
 	    $buffer = $Common->getData($value['host']);
804
-	    $all_data = json_decode($buffer,true);
804
+	    $all_data = json_decode($buffer, true);
805 805
 	    if (!empty($all_data)) $reset = 0;
806 806
 	    foreach ($all_data as $key => $line) {
807 807
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -834,11 +834,11 @@  discard block
 block discarded – undo
834 834
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
835 835
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
836 836
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
837
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
837
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
838 838
 	    //echo $buffer;
839
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
840
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
841
-	    $all_data = json_decode($buffer,true);
839
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
840
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
841
+	    $all_data = json_decode($buffer, true);
842 842
 	    if (json_last_error() != JSON_ERROR_NONE) {
843 843
 		die(json_last_error_msg());
844 844
 	    }
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 			//$data['departure_airport_iata'] = $line[11];
862 862
 			//$data['arrival_airport_iata'] = $line[12];
863 863
 	    		//$data['emergency'] = ''; // emergency
864
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
864
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
865 865
 	    		$data['format_source'] = 'radarvirtueljson';
866 866
     			$data['id_source'] = $id_source;
867 867
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -877,14 +877,14 @@  discard block
 block discarded – undo
877 877
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
878 878
 	    //$buffer = $Common->getData($hosts[$id]);
879 879
 	    $buffer = $Common->getData($value['host'].'?'.time());
880
-	    $all_data = json_decode(utf8_encode($buffer),true);
880
+	    $all_data = json_decode(utf8_encode($buffer), true);
881 881
 	    
882 882
 	    if (isset($all_data['pireps'])) {
883 883
 		$reset = 0;
884 884
 	        foreach ($all_data['pireps'] as $line) {
885 885
 		    $data = array();
886 886
 		    $data['id'] = $line['id'];
887
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
887
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
888 888
 		    $data['ident'] = $line['callsign']; // ident
889 889
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
890 890
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -914,9 +914,9 @@  discard block
 block discarded – undo
914 914
 			$SI->add($data);
915 915
 		    //    print_r($data);
916 916
     		    } elseif ($line['icon'] == 'ct') {
917
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
918
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
919
-			$typec = substr($data['ident'],-3);
917
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
918
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
919
+			$typec = substr($data['ident'], -3);
920 920
 			$data['type'] = '';
921 921
 			if ($typec == 'APP') $data['type'] = 'Approach';
922 922
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
928 928
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
929 929
 			else $data['type'] = 'Observer';
930
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
930
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
931 931
 		    }
932 932
 		    unset($data);
933 933
 		}
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 	    //$buffer = $Common->getData($hosts[$id]);
940 940
 	    if ($globalDebug) echo 'Get Data...'."\n";
941 941
 	    $buffer = $Common->getData($value['host']);
942
-	    $all_data = json_decode($buffer,true);
942
+	    $all_data = json_decode($buffer, true);
943 943
 	    if ($buffer != '' && is_array($all_data)) {
944 944
 		$reset = 0;
945 945
 		foreach ($all_data as $line) {
946 946
 	    	    $data = array();
947 947
 	    	    //$data['id'] = $line['id']; // id not usable
948 948
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
949
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
949
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
950 950
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
951 951
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
952 952
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -970,14 +970,14 @@  discard block
 block discarded – undo
970 970
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
971 971
 		    if (isset($line['aircraftname'])) {
972 972
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
973
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
974
-	    		$aircraft_data = explode('-',$line['aircraftname']);
973
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
974
+	    		$aircraft_data = explode('-', $line['aircraftname']);
975 975
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
976 976
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
977 977
 	    		else {
978
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
979
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
980
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
978
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
979
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
980
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
981 981
 	    		}
982 982
 	    	    }
983 983
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -997,14 +997,14 @@  discard block
 block discarded – undo
997 997
 	    //$buffer = $Common->getData($hosts[$id]);
998 998
 	    if ($globalDebug) echo 'Get Data...'."\n";
999 999
 	    $buffer = $Common->getData($value['host']);
1000
-	    $all_data = json_decode($buffer,true);
1000
+	    $all_data = json_decode($buffer, true);
1001 1001
 	    if ($buffer != '' && is_array($all_data)) {
1002 1002
 		$reset = 0;
1003 1003
 		foreach ($all_data as $line) {
1004 1004
 	    	    $data = array();
1005 1005
 	    	    //$data['id'] = $line['id']; // id not usable
1006 1006
 	    	    $data['id'] = trim($line['flight_id']);
1007
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1007
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1008 1008
 	    	    $data['pilot_name'] = $line['pilot_name'];
1009 1009
 	    	    $data['pilot_id'] = $line['pilot_id'];
1010 1010
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
 		    //$value = $formats[$nb];
1057 1057
 		    $format = $globalSources[$nb]['format'];
1058 1058
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1059
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1059
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1060 1060
 		    } elseif ($format == 'vrstcp') {
1061 1061
 			$buffer = @socket_read($r, 6000);
1062 1062
 		    } else {
1063
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1063
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1064 1064
 		    }
1065 1065
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1066 1066
 		    //echo $buffer."\n";
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 		    $error = false;
1070 1070
 		    //$SI::del();
1071 1071
 		    if ($format == 'vrstcp') {
1072
-			$buffer = explode('},{',$buffer);
1073
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1072
+			$buffer = explode('},{', $buffer);
1073
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1074 1074
 		    // SBS format is CSV format
1075 1075
 		    if ($buffer !== FALSE && $buffer != '') {
1076 1076
 			$tt[$format] = 0;
@@ -1104,13 +1104,13 @@  discard block
 block discarded – undo
1104 1104
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1105 1105
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1106 1106
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1107
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1107
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1108 1108
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1109 1109
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1110 1110
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1111 1111
 
1112 1112
 			    if (isset($ais_data['timestamp'])) {
1113
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1113
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1114 1114
 			    } else {
1115 1115
 				$data['datetime'] = date('Y-m-d H:i:s');
1116 1116
 			    }
@@ -1121,10 +1121,10 @@  discard block
 block discarded – undo
1121 1121
                         } elseif ($format == 'flightgearsp') {
1122 1122
                     	    //echo $buffer."\n";
1123 1123
                     	    if (strlen($buffer) > 5) {
1124
-				$line = explode(',',$buffer);
1124
+				$line = explode(',', $buffer);
1125 1125
 				$data = array();
1126 1126
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1127
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1127
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1128 1128
 				$data['ident'] = $line[6];
1129 1129
 				$data['aircraft_name'] = $line[7];
1130 1130
 				$data['longitude'] = $line[1];
@@ -1136,21 +1136,21 @@  discard block
 block discarded – undo
1136 1136
 				$data['format_source'] = 'flightgearsp';
1137 1137
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1138 1138
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1139
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1139
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1140 1140
 			    }
1141 1141
                         } elseif ($format == 'acars') {
1142 1142
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1143 1143
 			    $ACARS->add(trim($buffer));
1144
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1144
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1145 1145
 			    $ACARS->deleteLiveAcarsData();
1146 1146
 			} elseif ($format == 'flightgearmp') {
1147
-			    if (substr($buffer,0,1) != '#') {
1147
+			    if (substr($buffer, 0, 1) != '#') {
1148 1148
 				$data = array();
1149 1149
 				//echo $buffer."\n";
1150
-				$line = explode(' ',$buffer);
1150
+				$line = explode(' ', $buffer);
1151 1151
 				if (count($line) == 11) {
1152
-				    $userserver = explode('@',$line[0]);
1153
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1152
+				    $userserver = explode('@', $line[0]);
1153
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1154 1154
 				    $data['ident'] = $userserver[0];
1155 1155
 				    $data['registration'] = $userserver[0];
1156 1156
 				    $data['latitude'] = $line[4];
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
 				    $data['altitude'] = $line[6];
1159 1159
 				    $data['datetime'] = date('Y-m-d H:i:s');
1160 1160
 				    $aircraft_type = $line[10];
1161
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1162
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1161
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1162
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1163 1163
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1164 1164
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1165 1165
 				}
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1169 1169
 			    die;
1170 1170
 			} elseif ($format == 'vrstcp') {
1171
-			    foreach($buffer as $all_data) {
1172
-				$line = json_decode('{'.$all_data.'}',true);
1171
+			    foreach ($buffer as $all_data) {
1172
+				$line = json_decode('{'.$all_data.'}', true);
1173 1173
 				$data = array();
1174 1174
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1175 1175
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1196 1196
 				unset($data);
1197 1197
 			    }
1198
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1198
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1199 1199
 			    $line = explode("\t", $buffer);
1200
-			    for($k = 0; $k < count($line); $k=$k+2) {
1200
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1201 1201
 				$key = $line[$k];
1202
-			        $lined[$key] = $line[$k+1];
1202
+			        $lined[$key] = $line[$k + 1];
1203 1203
 			    }
1204 1204
     			    if (count($lined) > 3) {
1205 1205
     				$data['hex'] = $lined['hexid'];
1206 1206
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1207
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1207
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1208 1208
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1209 1209
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1210 1210
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1223,22 +1223,22 @@  discard block
 block discarded – undo
1223 1223
     			    } else $error = true;
1224 1224
 			} elseif ($format == 'aprs' && $use_aprs) {
1225 1225
 			    if ($aprs_connect == 0) {
1226
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1226
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1227 1227
 				$aprs_connect = 1;
1228 1228
 			    }
1229 1229
 			    
1230
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1230
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1231 1231
 				$aprs_last_tx = time();
1232 1232
 				$data_aprs = "# Keep alive";
1233
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1233
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1234 1234
 			    }
1235 1235
 			    
1236 1236
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1237 1237
 			    //echo 'APRS data : '.$buffer."\n";
1238
-			    $buffer = str_replace('APRS <- ','',$buffer);
1239
-			    $buffer = str_replace('APRS -> ','',$buffer);
1238
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1239
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1240 1240
 			    //echo $buffer."\n";
1241
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1241
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1242 1242
 				$line = $APRS->parse($buffer);
1243 1243
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1244 1244
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1254 1254
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1255 1255
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1256
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1256
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1257 1257
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1258 1258
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1259 1259
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 				connect_all($sourceee);
1383 1383
 				$sourceee = array();
1384 1384
 				//connect_all($globalSources);
1385
-				$tt[$format]=0;
1385
+				$tt[$format] = 0;
1386 1386
 				break;
1387 1387
 			    }
1388 1388
 			}
@@ -1391,14 +1391,14 @@  discard block
 block discarded – undo
1391 1391
 	    } else {
1392 1392
 		$error = socket_strerror(socket_last_error());
1393 1393
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1394
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1394
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1395 1395
 			if (isset($globalDebug)) echo "Restarting...\n";
1396 1396
 			// Restart the script if possible
1397 1397
 			if (is_array($sockets)) {
1398 1398
 			    if ($globalDebug) echo "Shutdown all sockets...";
1399 1399
 			    
1400 1400
 			    foreach ($sockets as $sock) {
1401
-				@socket_shutdown($sock,2);
1401
+				@socket_shutdown($sock, 2);
1402 1402
 				@socket_close($sock);
1403 1403
 			    }
1404 1404
 			    
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
99
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
107
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
163
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
 	    if (isset($flight['lastupdate'])) {
187
-		if ($flight['lastupdate'] < (time()-5900)) {
187
+		if ($flight['lastupdate'] < (time() - 5900)) {
188 188
 		    $this->delKey($key);
189 189
 		}
190 190
 	    }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$real_arrival = $this->arrival($key);
201 201
 			$Spotter = new Spotter($this->db);
202 202
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
203
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
204 204
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205 205
 			}
206 206
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
239 239
 
@@ -267,25 +267,25 @@  discard block
 block discarded – undo
267 267
 		
268 268
 		if (!isset($this->all_flights[$id])) {
269 269
 		    $this->all_flights[$id] = array();
270
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
271
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
272
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
271
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
272
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
273 273
 		    if (!isset($line['id'])) {
274 274
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
275 275
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
276 276
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
277
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
277
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
278 278
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
279
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
280 280
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
281 281
 		}
282 282
 		if (isset($line['source_type']) && $line['source_type'] != '') {
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
283
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
284 284
 		}
285 285
 		
286 286
 		//print_r($this->all_flights);
287 287
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
288
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
289 289
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
290 290
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
291 291
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
295 295
 			    $Spotter = new Spotter($this->db);
296 296
 			    if (isset($this->all_flights[$id]['source_type'])) {
297
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
297
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
298 298
 			    } else {
299 299
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
300 300
 			    }
301 301
 			    $Spotter->db = null;
302
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
303
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
302
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
303
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
304 304
 			}
305 305
 		    }
306 306
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 			$Spotter = new Spotter($this->db);
312 312
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
313 313
 			$Spotter->db = null;
314
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
314
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
315 315
 		}
316 316
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
317 317
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 				$Spotter = new Spotter($this->db);
320 320
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
321 321
 				$Spotter->db = null;
322
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
322
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324 324
 		}
325 325
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
328 328
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
329 329
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
330
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
330
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
331 331
 		}
332 332
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
333
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
333
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
334 334
 		}
335 335
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
336
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
336
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
337 337
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
339 339
 		    } else {
340 340
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
341 341
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -346,31 +346,31 @@  discard block
 block discarded – undo
346 346
 				*/
347 347
 				return '';
348 348
 		    }
349
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
349
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
350 350
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
351 351
 			return '';
352
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
352
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
353 353
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
354 354
 			return '';
355 355
 		} elseif (!isset($line['datetime'])) {
356 356
 			date_default_timezone_set('UTC');
357
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
357
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
358 358
 		} else {
359 359
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
360 360
 			return '';
361 361
 		}
362 362
 
363 363
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
364
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
364
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
365 365
 		}
366 366
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
367
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
367
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
368 368
 		}
369 369
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
370
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
370
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
371 371
 		}
372 372
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
373
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
373
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
374 374
 		}
375 375
  
376 376
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
379 379
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 2300) {
380 380
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
381
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
382
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
383
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
384
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
385
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
381
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
382
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
383
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
384
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
385
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
386 386
 			} else {
387
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
387
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
388 388
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
389 389
 				$timeelapsed = microtime(true);
390 390
             			$Spotter = new Spotter($this->db);
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
395 395
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
396 396
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
397
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
397
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
398 398
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
399 399
 				$Spotter->db = null;
400
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
400
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
401 401
 			    }
402 402
 			}
403
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
404 404
 		    
405 405
 /*
406 406
 		    if (!isset($line['id'])) {
@@ -410,25 +410,25 @@  discard block
 block discarded – undo
410 410
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
411 411
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
412 412
   */
413
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
413
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
414 414
 
415 415
 		    //$putinarchive = true;
416 416
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
417
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
417
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
418 418
 		    }
419 419
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
420
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
420
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
421 421
 		    }
422 422
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
423
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
423
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
424 424
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
425 425
 			$timeelapsed = microtime(true);
426 426
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
427 427
 				$Spotter = new Spotter($this->db);
428 428
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
429 429
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
430
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
431
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
430
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
431
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
432 432
                         }
433 433
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
434 434
 			$timeelapsed = microtime(true);
@@ -442,34 +442,34 @@  discard block
 block discarded – undo
442 442
 				$Translation->db = null;
443 443
 			    }
444 444
 			    $Spotter->db = null;
445
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
446 446
                     	}
447 447
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
448 448
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
449 449
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
450 450
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
451
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
451
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
452 452
 		    	    }
453 453
 			}
454 454
 			if (!isset($globalFork)) $globalFork = TRUE;
455 455
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
456
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
456
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
457 457
 			}
458 458
 		    }
459 459
 		}
460 460
 
461 461
 		if (isset($line['speed']) && $line['speed'] != '') {
462 462
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
463
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
464
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
463
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
464
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
465 465
 		    //$dataFound = true;
466 466
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
467
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
467
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
468 468
 		    if ($distance > 1000 && $distance < 10000) {
469 469
 		    // use datetime
470 470
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
471 471
 			$speed = $speed*3.6;
472
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
472
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
473 473
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
474 474
 		    }
475 475
 		}
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 
478 478
 
479 479
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) {
480
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
480
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
481 481
 	    	    else unset($timediff);
482
-	    	    if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
482
+	    	    if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
483 483
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
484
-			    if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
484
+			    if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
485 485
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
486 486
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
487 487
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 				    $timeelapsed = microtime(true);
492 492
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
493 493
 					$Spotter = new Spotter($this->db);
494
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
494
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
495 495
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
496 496
 					else $this->all_flights[$id]['over_country'] = '';
497 497
 					$Spotter->db = null;
498
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
499 499
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
500 500
 				    }
501 501
 				}
@@ -505,13 +505,13 @@  discard block
 block discarded – undo
505 505
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
506 506
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
507 507
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
508
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
508
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
509 509
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
510 510
 				    $dataFound = true;
511 511
 				    $this->all_flights[$id]['time_last_coord'] = time();
512 512
 				}
513 513
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
514
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
514
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
515 515
 				/*
516 516
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
517 517
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
530 530
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
531 531
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
532
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
532
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
533 533
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
534 534
 				    $dataFound = true;
535 535
 				    $this->all_flights[$id]['time_last_coord'] = time();
536 536
 				}
537 537
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
538
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
538
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
539 539
 				/*
540 540
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
541 541
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -553,46 +553,46 @@  discard block
 block discarded – undo
553 553
 		    } else if ($globalDebug && $timediff > 30) {
554 554
 			$this->tmd = $this->tmd + 1;
555 555
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
556
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
557
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
556
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
557
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
558 558
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
559 559
 		    }
560 560
 		}
561 561
 		if (isset($line['last_update']) && $line['last_update'] != '') {
562 562
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
563
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
563
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
564 564
 		}
565 565
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
566
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
567 567
 		    //$dataFound = true;
568 568
 		}
569 569
 		if (isset($line['format_source']) && $line['format_source'] != '') {
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
570
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
571 571
 		}
572 572
 		if (isset($line['source_name']) && $line['source_name'] != '') {
573
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
573
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
574 574
 		}
575 575
 		if (isset($line['emergency']) && $line['emergency'] != '') {
576
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
576
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
577 577
 		    //$dataFound = true;
578 578
 		}
579 579
 		if (isset($line['ground']) && $line['ground'] != '') {
580 580
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
581 581
 			// Here we force archive of flight because after ground it's a new one (or should be)
582
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
583
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
584
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
585
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
586
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
582
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
583
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
584
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
585
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
586
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
587 587
 		    }
588 588
 		    if ($line['ground'] != 1) $line['ground'] = 0;
589
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
589
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
590 590
 		    //$dataFound = true;
591 591
 		}
592 592
 		if (isset($line['squawk']) && $line['squawk'] != '') {
593 593
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
594 594
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
595
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
595
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
596 596
 			    $highlight = '';
597 597
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
598 598
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -601,59 +601,59 @@  discard block
 block discarded – undo
601 601
 				$timeelapsed = microtime(true);
602 602
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
603 603
 				    $Spotter = new Spotter($this->db);
604
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
604
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
605 605
 				    $Spotter->db = null;
606
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
606
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
607 607
 				}
608 608
 				//$putinarchive = true;
609 609
 				//$highlight = '';
610 610
 			    }
611 611
 			    
612
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
612
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
613 613
 		    //$dataFound = true;
614 614
 		}
615 615
 
616 616
 		if (isset($line['altitude']) && $line['altitude'] != '') {
617 617
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
618
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
619
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
620
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
618
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
619
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
620
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
621 621
 			//$dataFound = true;
622 622
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
623 623
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
624 624
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 2300) {
625 625
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
626
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
627
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
628
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
629
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
630
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
626
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
627
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
628
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
629
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
630
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
631 631
 			}
632 632
 		    }
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
633
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
634 634
 		}
635 635
 
636 636
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
637
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
637
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
638 638
 		}
639 639
 		
640 640
 		if (isset($line['heading']) && $line['heading'] != '') {
641
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
642
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
641
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
642
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
643
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
644 644
 		    //$dataFound = true;
645 645
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
646
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
648
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
646
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
647
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
648
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
649 649
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
650 650
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
651 651
   		    // If not enough messages and ACARS set heading to 0
652
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
652
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
653 653
   		}
654
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
655
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
656
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinupdate) && $globalAircraftMinupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
654
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
655
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
656
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinupdate) && $globalAircraftMinupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
657 657
 
658 658
 //		print_r($this->all_flights[$id]);
659 659
 		//gets the callsign from the last hour
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
664 664
 		    $this->all_flights[$id]['lastupdate'] = time();
665 665
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
666
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
666
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
667 667
 			    //print_r($this->all_flights);
668 668
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
669 669
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -674,61 +674,61 @@  discard block
 block discarded – undo
674 674
 				    $SpotterLive = new SpotterLive($this->db);
675 675
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
676 676
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
677
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
677
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
678 678
 				    } elseif (isset($line['id'])) {
679 679
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
680
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
680
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
681 681
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
682 682
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
683
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
683
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
684 684
 				    } else $recent_ident = '';
685
-				    $SpotterLive->db=null;
685
+				    $SpotterLive->db = null;
686 686
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
687 687
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
688 688
 				} else $recent_ident = '';
689 689
 			    } else {
690 690
 				$recent_ident = '';
691
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
691
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
692 692
 			    }
693 693
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
694
-			    if($recent_ident == "")
694
+			    if ($recent_ident == "")
695 695
 			    {
696 696
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
697 697
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
698 698
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
699 699
 				//adds the spotter data for the archive
700 700
 				$ignoreImport = false;
701
-				foreach($globalAirportIgnore as $airportIgnore) {
701
+				foreach ($globalAirportIgnore as $airportIgnore) {
702 702
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
703 703
 					$ignoreImport = true;
704 704
 				    }
705 705
 				}
706 706
 				if (count($globalAirportAccept) > 0) {
707 707
 				    $ignoreImport = true;
708
-				    foreach($globalAirportIgnore as $airportIgnore) {
708
+				    foreach ($globalAirportIgnore as $airportIgnore) {
709 709
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
710 710
 					    $ignoreImport = false;
711 711
 					}
712 712
 				    }
713 713
 				}
714 714
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
715
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
716
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
715
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
716
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
717 717
 					    $ignoreImport = true;
718 718
 					}
719 719
 				    }
720 720
 				}
721 721
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
722 722
 				    $ignoreImport = true;
723
-				    foreach($globalAirlineAccept as $airlineAccept) {
724
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
723
+				    foreach ($globalAirlineAccept as $airlineAccept) {
724
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
725 725
 					    $ignoreImport = false;
726 726
 					}
727 727
 				    }
728 728
 				}
729 729
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
730 730
 				    $ignoreImport = true;
731
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
731
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
732 732
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
733 733
 					    $ignoreImport = false;
734 734
 					}
@@ -740,32 +740,32 @@  discard block
 block discarded – undo
740 740
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
741 741
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
742 742
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
743
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
743
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
744 744
 				    $timeelapsed = microtime(true);
745 745
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
746 746
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
747 747
 					    $Spotter = new Spotter($this->db);
748
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
748
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
749 749
 					    $Spotter->db = null;
750 750
 					    if ($globalDebug && isset($result)) echo $result."\n";
751 751
 					}
752 752
 				    }
753
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
753
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
754 754
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
755 755
 
756 756
 				    // Add source stat in DB
757 757
 				    $Stats = new Stats($this->db);
758 758
 				    if (!empty($this->stats)) {
759 759
 					if ($globalDebug) echo 'Add source stats : ';
760
-				        foreach($this->stats as $date => $data) {
761
-					    foreach($data as $source => $sourced) {
760
+				        foreach ($this->stats as $date => $data) {
761
+					    foreach ($data as $source => $sourced) {
762 762
 					        //print_r($sourced);
763
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
764
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
763
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
764
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
765 765
 				    		if (isset($sourced['msg'])) {
766 766
 				    		    if (time() - $sourced['msg']['date'] > 10) {
767 767
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
768
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
768
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
769 769
 			    			        unset($this->stats[$date][$source]['msg']);
770 770
 			    			    }
771 771
 			    			}
@@ -803,14 +803,14 @@  discard block
 block discarded – undo
803 803
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
804 804
 					    $SpotterLive = new SpotterLive($this->db);
805 805
 					    $SpotterLive->deleteLiveSpotterData();
806
-					    $SpotterLive->db=null;
806
+					    $SpotterLive->db = null;
807 807
 					}
808 808
 				    }
809 809
 				    if ($globalDebug) echo " Done\n";
810 810
 				    $this->last_delete = time();
811 811
 				}
812 812
 			    } else {
813
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs')) {
813
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs')) {
814 814
 				    $this->all_flights[$id]['id'] = $recent_ident;
815 815
 				    $this->all_flights[$id]['addedSpotter'] = 1;
816 816
 				}
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
819 819
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
820 820
 					    $Spotter = new Spotter($this->db);
821
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
821
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
822 822
 					    $Spotter->db = null;
823 823
 					}
824 824
 				    }
@@ -844,37 +844,37 @@  discard block
 block discarded – undo
844 844
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
845 845
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
846 846
 
847
-		    foreach($globalAirportIgnore as $airportIgnore) {
847
+		    foreach ($globalAirportIgnore as $airportIgnore) {
848 848
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
849 849
 			    $ignoreImport = true;
850 850
 			}
851 851
 		    }
852 852
 		    if (count($globalAirportAccept) > 0) {
853 853
 		        $ignoreImport = true;
854
-		        foreach($globalAirportIgnore as $airportIgnore) {
854
+		        foreach ($globalAirportIgnore as $airportIgnore) {
855 855
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
856 856
 				$ignoreImport = false;
857 857
 			    }
858 858
 			}
859 859
 		    }
860 860
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
861
-			foreach($globalAirlineIgnore as $airlineIgnore) {
862
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
861
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
862
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
863 863
 				$ignoreImport = true;
864 864
 			    }
865 865
 			}
866 866
 		    }
867 867
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
868 868
 			$ignoreImport = true;
869
-			foreach($globalAirlineAccept as $airlineAccept) {
870
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
869
+			foreach ($globalAirlineAccept as $airlineAccept) {
870
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
871 871
 				$ignoreImport = false;
872 872
 			    }
873 873
 			}
874 874
 		    }
875 875
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
876 876
 			$ignoreImport = true;
877
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
877
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
878 878
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
879 879
 			        $ignoreImport = false;
880 880
 			    }
@@ -882,23 +882,23 @@  discard block
 block discarded – undo
882 882
 		    }
883 883
 
884 884
 		    if (!$ignoreImport) {
885
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
886
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
885
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
886
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
887 887
 				$timeelapsed = microtime(true);
888 888
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
889 889
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
890 890
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
891 891
 					$SpotterLive = new SpotterLive($this->db);
892
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
892
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
893 893
 					$SpotterLive->db = null;
894 894
 					if ($globalDebug) echo $result."\n";
895 895
 				    }
896 896
 				}
897 897
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
898
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
898
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
899 899
 				}
900 900
 				$this->all_flights[$id]['putinarchive'] = false;
901
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
901
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
902 902
 
903 903
 				// Put statistics in $this->stats variable
904 904
 				//if ($line['format_source'] != 'aprs') {
@@ -917,19 +917,19 @@  discard block
 block discarded – undo
917 917
 							$latitude = $globalCenterLatitude;
918 918
 							$longitude = $globalCenterLongitude;
919 919
 						}
920
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
920
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
921 921
 					} else {
922 922
 						$latitude = $this->source_location[$source]['latitude'];
923 923
 						$longitude = $this->source_location[$source]['longitude'];
924 924
 					}
925
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
925
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
926 926
 					//$stats_heading = $stats_heading%22.5;
927 927
 					$stats_heading = round($stats_heading/22.5);
928
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
928
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
929 929
 					$current_date = date('Y-m-d');
930 930
 					if ($stats_heading == 16) $stats_heading = 0;
931 931
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
932
-						for ($i=0;$i<=15;$i++) {
932
+						for ($i = 0; $i <= 15; $i++) {
933 933
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
934 934
 						}
935 935
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -944,9 +944,9 @@  discard block
 block discarded – undo
944 944
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
945 945
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
946 946
 						    end($this->stats[$current_date][$source]['hist']);
947
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
947
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
948 948
 						} else $mini = 0;
949
-						for ($i=$mini;$i<=$distance;$i+=10) {
949
+						for ($i = $mini; $i <= $distance; $i += 10) {
950 950
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
951 951
 						}
952 952
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 				$this->all_flights[$id]['lastupdate'] = time();
960 960
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
961 961
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
962
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
962
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
963 963
 			//$this->del();
964 964
 			
965 965
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.