Completed
Push — master ( cc50d0...0f8c33 )
by Yannick
09:46
created
install/class.update_db.php 1 patch
Spacing   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253 253
                         $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
254
+                } catch (PDOException $e) {
255 255
                         return "error : ".$e->getMessage();
256 256
                 }
257 257
 		return '';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268 268
                         $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
269
+                } catch (PDOException $e) {
270 270
                         return "error : ".$e->getMessage();
271 271
                 }
272 272
 		
273
-		if ($fh = fopen($database_file,"r")) {
273
+		if ($fh = fopen($database_file, "r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
275 275
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
276 276
 		
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281 281
             			while (!feof($fh)) {
282 282
             				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
283
+            				$line = $Common->hex2str(fgets($fh, 9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
285
+            				$values['ModeS'] = substr($line, 0, 6);
286
+            				$values['Registration'] = trim(substr($line, 69, 6));
287
+            				$aircraft_name = trim(substr($line, 48, 6));
288 288
             				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
+            				$aircraft_name_split = explode(' ', $aircraft_name);
290 290
             				$search_more = '';
291 291
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292 292
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	            				if (isset($result['icao']) && $result['icao'] != '') {
299 299
 	            				    $values['ICAOTypeCode'] = $result['icao'];
300 300
 	            				} 
301
-					} catch(PDOException $e) {
301
+					} catch (PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
304 304
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
305 305
 					// Add data to db
306 306
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 307
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
308
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
309 309
 						//print_r($query_dest_values);
310 310
 						$sth_dest->execute($query_dest_values);
311 311
 					}
312 312
 				}
313 313
 				if ($globalTransaction) $Connection->db->commit();
314
-			} catch(PDOException $e) {
314
+			} catch (PDOException $e) {
315 315
 				return "error : ".$e->getMessage();
316 316
 			}
317 317
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323 323
                         $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
324
+                } catch (PDOException $e) {
325 325
                         return "error : ".$e->getMessage();
326 326
                 }
327 327
 		return '';
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337 337
                         $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
338
+                } catch (PDOException $e) {
339 339
                         return "error : ".$e->getMessage();
340 340
                 }
341 341
 		
342
-		if ($fh = fopen($database_file,"r")) {
342
+		if ($fh = fopen($database_file, "r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
344 344
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
345 345
 		
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			$sth_dest = $Connection->db->prepare($query_dest);
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350
-				$tmp = fgetcsv($fh,9999,',',"'");
350
+				$tmp = fgetcsv($fh, 9999, ',', "'");
351 351
             			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
352
+            				$line = fgetcsv($fh, 9999, ',', "'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				$values['Registration'] = $line[3];
358 358
             				$aircraft_name = $line[2];
359 359
             				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
+            				$aircraft_name_split = explode(' ', $aircraft_name);
361 361
             				$search_more = '';
362 362
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
                                     		$sth_search->execute();
367 367
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368 368
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369
-					} catch(PDOException $e) {
369
+					} catch (PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
372 372
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
373 373
 					// Add data to db
374 374
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
375 375
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
376
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
376
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
377 377
 						//print_r($query_dest_values);
378 378
 						$sth_dest->execute($query_dest_values);
379 379
 					}
380 380
 				}
381 381
 				if ($globalTransaction) $Connection->db->commit();
382
-			} catch(PDOException $e) {
382
+			} catch (PDOException $e) {
383 383
 				return "error : ".$e->getMessage();
384 384
 			}
385 385
 		}
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
                         $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return "error : ".$e->getMessage();
394 394
                 }
395 395
 		return '';
396 396
 	}
397 397
 
398
-	public static function retrieve_owner($database_file,$country = 'F') {
398
+	public static function retrieve_owner($database_file, $country = 'F') {
399 399
 		global $globalTransaction, $globalMasterSource;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405 405
                         $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
406
+                } catch (PDOException $e) {
407 407
                         return "error : ".$e->getMessage();
408 408
                 }
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411
-		if ($fh = fopen($database_file,"r")) {
411
+		if ($fh = fopen($database_file, "r")) {
412 412
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414 414
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 			$sth_modes = $Connection->db->prepare($query_modes);
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421
-				$tmp = fgetcsv($fh,9999,',','"');
421
+				$tmp = fgetcsv($fh, 9999, ',', '"');
422 422
             			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
423
+            				$line = fgetcsv($fh, 9999, ',', '"');
424 424
             				$values = array();
425 425
             				//print_r($line);
426 426
             				if ($country == 'F') {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
             				    $values['base'] = $line[4];
429 429
             				    $values['owner'] = $line[5];
430 430
             				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
431
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
432 432
 					    $values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434 434
 					    // TODO : add modeS & reg to aircraft_modes
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             				    $values['base'] = $line[3];
437 437
             				    $values['owner'] = $line[2];
438 438
             				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
439
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
440 440
 					    $values['cancel'] = '';
441 441
 					    $values['modes'] = $line[7];
442 442
 					    $values['icao'] = $line[8];
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[5];
458 458
             				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
460 460
 					    $values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462 462
 					    // TODO : add modeS & reg to aircraft_modes
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
             				    $values['base'] = null;
465 465
             				    $values['owner'] = $line[12];
466 466
             				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
467
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
468 468
 
469 469
 					    $values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -484,28 +484,28 @@  discard block
 block discarded – undo
484 484
             				    $values['base'] = null;
485 485
             				    $values['owner'] = $line[8];
486 486
             				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
487
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
488 488
 					    $values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490 490
             				    $values['registration'] = $line[0];
491 491
             				    $values['base'] = null;
492 492
             				    $values['owner'] = $line[4];
493 493
             				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
494
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
495 495
 					    $values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497 497
             				    $values['registration'] = $line[0];
498 498
             				    $values['base'] = null;
499 499
             				    $values['owner'] = $line[4];
500 500
             				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
501
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
502 502
 					    $values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504 504
             				    $values['registration'] = $line[0];
505 505
             				    $values['base'] = null;
506 506
             				    $values['owner'] = $line[3];
507 507
             				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
508
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
509 509
 					    $values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511 511
             				    $values['registration'] = $line[0];
@@ -519,18 +519,18 @@  discard block
 block discarded – undo
519 519
             				    $values['registration'] = $line[0];
520 520
             				    $values['base'] = null;
521 521
             				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
522
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
523
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
524 524
 					    $values['modes'] = $line[4];
525 525
 					    $values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527 527
             				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
528
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
529 529
 					    $values['modes'] = $line[5];
530 530
 					    $values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532 532
             				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
534 534
 					    $values['modes'] = $line[4];
535 535
 					    $values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
 					    $values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
544
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
545 545
 						$sth_dest->execute($query_dest_values);
546 546
 					}
547 547
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
548 548
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
549
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
549
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
550 550
 						$sth_modes->execute($query_modes_values);
551 551
 					}
552 552
 				}
553 553
 				if ($globalTransaction) $Connection->db->commit();
554
-			} catch(PDOException $e) {
554
+			} catch (PDOException $e) {
555 555
 				return "error : ".$e->getMessage();
556 556
 			}
557 557
 		}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668 668
                         $sth->execute();
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         return "error : ".$e->getMessage();
671 671
                 }
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678 678
                         $sth->execute();
679
-                } catch(PDOException $e) {
679
+                } catch (PDOException $e) {
680 680
                         return "error : ".$e->getMessage();
681 681
                 }
682 682
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		if ($globalTransaction) $Connection->db->beginTransaction();
688 688
   
689 689
 		$i = 0;
690
-		while($row = sparql_fetch_array($result))
690
+		while ($row = sparql_fetch_array($result))
691 691
 		{
692 692
 			if ($i >= 1) {
693 693
 			//print_r($row);
@@ -707,31 +707,31 @@  discard block
 block discarded – undo
707 707
 				$row['image'] = '';
708 708
 				$row['image_thumb'] = '';
709 709
 			} else {
710
-				$image = str_replace(' ','_',$row['image']);
710
+				$image = str_replace(' ', '_', $row['image']);
711 711
 				$digest = md5($image);
712
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
713
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
714
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
715
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
712
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
713
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
714
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
715
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
716 716
 			}
717 717
 			
718
-			$country = explode('-',$row['country']);
718
+			$country = explode('-', $row['country']);
719 719
 			$row['country'] = $country[0];
720 720
 			
721 721
 			$row['type'] = trim($row['type']);
722
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
722
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
723 723
 				$row['type'] = 'Military';
724 724
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
725 725
 				$row['type'] = 'small_airport';
726 726
 			}
727 727
 			
728
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
729
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
728
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
729
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
730 730
 			//print_r($query_dest_values);
731 731
 			
732 732
 			try {
733 733
 				$sth_dest->execute($query_dest_values);
734
-			} catch(PDOException $e) {
734
+			} catch (PDOException $e) {
735 735
 				return "error : ".$e->getMessage();
736 736
 			}
737 737
 			}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747 747
                         $sth->execute();
748
-                } catch(PDOException $e) {
748
+                } catch (PDOException $e) {
749 749
                         return "error : ".$e->getMessage();
750 750
                 }
751 751
 
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
754 754
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 755
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
756
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760 760
                         $sth->execute($query_values);
761
-                } catch(PDOException $e) {
761
+                } catch (PDOException $e) {
762 762
                         return "error : ".$e->getMessage();
763 763
                 }
764 764
 		$i++;
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		echo "Download data from ourairports.com...\n";
777 777
 		$delimiter = ',';
778 778
 		$out_file = $tmp_dir.'airports.csv';
779
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
779
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
780 780
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
781 781
 		echo "Add data from ourairports.com...\n";
782 782
 
@@ -787,32 +787,32 @@  discard block
 block discarded – undo
787 787
 			//$Connection->db->beginTransaction();
788 788
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 789
 			{
790
-				if(!$header) $header = $row;
790
+				if (!$header) $header = $row;
791 791
 				else {
792 792
 					$data = array();
793 793
 					$data = array_combine($header, $row);
794 794
 					try {
795 795
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
796 796
 						$sth->execute(array(':icao' => $data['gps_code']));
797
-					} catch(PDOException $e) {
797
+					} catch (PDOException $e) {
798 798
 						return "error : ".$e->getMessage();
799 799
 					}
800 800
 					if ($sth->fetchColumn() > 0) {
801 801
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
802 802
 						try {
803 803
 							$sth = $Connection->db->prepare($query);
804
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
805
-						} catch(PDOException $e) {
804
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
805
+						} catch (PDOException $e) {
806 806
 							return "error : ".$e->getMessage();
807 807
 						}
808 808
 					} else {
809 809
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
810 810
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
811
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
811
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
812 812
 						try {
813 813
 							$sth = $Connection->db->prepare($query);
814 814
 							$sth->execute($query_values);
815
-						} catch(PDOException $e) {
815
+						} catch (PDOException $e) {
816 816
 							return "error : ".$e->getMessage();
817 817
 						}
818 818
 						$i++;
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 
826 826
 		echo "Download data from another free database...\n";
827 827
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
828
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
829 829
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
830 830
 		update_db::unzip($out_file);
831 831
 		$header = NULL;
@@ -837,15 +837,15 @@  discard block
 block discarded – undo
837 837
 			//$Connection->db->beginTransaction();
838 838
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 839
 			{
840
-				if(!$header) $header = $row;
840
+				if (!$header) $header = $row;
841 841
 				else {
842 842
 					$data = $row;
843 843
 
844 844
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
845 845
 					try {
846 846
 						$sth = $Connection->db->prepare($query);
847
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
848
-					} catch(PDOException $e) {
847
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
848
+					} catch (PDOException $e) {
849 849
 						return "error : ".$e->getMessage();
850 850
 					}
851 851
 				}
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
 		try {
860 860
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
861 861
 			$sth->execute();
862
-		} catch(PDOException $e) {
862
+		} catch (PDOException $e) {
863 863
 			return "error : ".$e->getMessage();
864 864
 		}
865 865
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
866 866
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
867 867
 			try {
868 868
 				$sth2 = $Connection->db->prepare($query2);
869
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
870
-			} catch(PDOException $e) {
869
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
870
+			} catch (PDOException $e) {
871 871
 				return "error : ".$e->getMessage();
872 872
 			}
873 873
 		}
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893 893
                         $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
894
+                } catch (PDOException $e) {
895 895
                         return "error : ".$e->getMessage();
896 896
                 }
897 897
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
909 909
 			{
910 910
 				$i++;
911
-				if($i > 12) {
911
+				if ($i > 12) {
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
                                                 //echo substr($operator, 0, 2)."\n";;
917 917
                                                 if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919
-							$operator = $airline_array[0]['icao'].substr($operator,2);
919
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
920 920
                                                 }
921 921
                                         }
922 922
 					
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925 925
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926 926
                                                 if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
927
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
928 928
                                             	}
929 929
                                         }
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
933
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
-					} catch(PDOException $e) {
933
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
+					} catch (PDOException $e) {
935 935
 						return "error : ".$e->getMessage();
936 936
 					}
937 937
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
-					} catch(PDOException $e) {
974
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997 997
                         $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         return "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
 
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006 1006
                         $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1007
+                } catch (PDOException $e) {
1008 1008
                         return "error : ".$e->getMessage();
1009 1009
                 }
1010 1010
 
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1022 1022
 					try {
1023 1023
 						$sths = $Connection->db->prepare($query_search);
1024
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1025
-					} catch(PDOException $e) {
1024
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1025
+					} catch (PDOException $e) {
1026 1026
 						return "error s : ".$e->getMessage();
1027 1027
 					}
1028 1028
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 							//}
1036 1036
 						try {
1037 1037
 							$sthi = $Connection->db->prepare($queryi);
1038
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1039
-						} catch(PDOException $e) {
1038
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1039
+						} catch (PDOException $e) {
1040 1040
 							return "error u : ".$e->getMessage();
1041 1041
 						}
1042 1042
 					} else {
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 						try {
1045 1045
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1046 1046
 							$sthsm->execute(array(':mfr' => $data[2]));
1047
-						} catch(PDOException $e) {
1047
+						} catch (PDOException $e) {
1048 1048
 							return "error mfr : ".$e->getMessage();
1049 1049
 						}
1050 1050
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1055
 							try {
1056 1056
 								$sthf = $Connection->db->prepare($queryf);
1057
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1058
-							} catch(PDOException $e) {
1057
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1058
+							} catch (PDOException $e) {
1059 1059
 								return "error f : ".$e->getMessage();
1060 1060
 							}
1061 1061
 						}
@@ -1065,13 +1065,13 @@  discard block
 block discarded – undo
1065 1065
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1066
 						try {
1067 1067
 							$sth = $Connection->db->prepare($query);
1068
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1069
-						} catch(PDOException $e) {
1068
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1069
+						} catch (PDOException $e) {
1070 1070
 							return "error i : ".$e->getMessage();
1071 1071
 						}
1072 1072
 					}
1073 1073
 				}
1074
-				if ($i % 90 == 0) {
1074
+				if ($i%90 == 0) {
1075 1075
 					if ($globalTransaction) $Connection->db->commit();
1076 1076
 					if ($globalTransaction) $Connection->db->beginTransaction();
1077 1077
 				}
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092 1092
                         $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1093
+                } catch (PDOException $e) {
1094 1094
                         return "error : ".$e->getMessage();
1095 1095
                 }
1096 1096
 
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1112
 					try {
1113 1113
 						$sth = $Connection->db->prepare($query);
1114
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1115
-					} catch(PDOException $e) {
1114
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1115
+					} catch (PDOException $e) {
1116 1116
 						return "error : ".$e->getMessage();
1117 1117
 					}
1118 1118
 				}
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133 1133
                         $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1134
+                } catch (PDOException $e) {
1135 1135
                         return "error : ".$e->getMessage();
1136 1136
                 }
1137 1137
 
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1148 1148
 					try {
1149 1149
 						$sth = $Connection->db->prepare($query);
1150
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1151
-					} catch(PDOException $e) {
1150
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1151
+					} catch (PDOException $e) {
1152 1152
 						print_r($data);
1153 1153
 						return "error : ".$e->getMessage();
1154 1154
 					}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170 1170
                         $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1171
+                } catch (PDOException $e) {
1172 1172
                         return "error : ".$e->getMessage();
1173 1173
                 }
1174 1174
 
@@ -1188,8 +1188,8 @@  discard block
 block discarded – undo
1188 1188
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1189 1189
 					try {
1190 1190
 						$sth = $Connection->db->prepare($query);
1191
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1192
-					} catch(PDOException $e) {
1191
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1192
+					} catch (PDOException $e) {
1193 1193
 						return "error : ".$e->getMessage();
1194 1194
 					}
1195 1195
 				}
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210 1210
 			$sth->execute();
1211
-		} catch(PDOException $e) {
1211
+		} catch (PDOException $e) {
1212 1212
 			return "error : ".$e->getMessage();
1213 1213
 		}
1214 1214
 
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 					try {
1225 1225
 						$sth = $Connection->db->prepare($query);
1226 1226
 						$sth->execute(array(':icao' => $icao));
1227
-					} catch(PDOException $e) {
1227
+					} catch (PDOException $e) {
1228 1228
 						return "error : ".$e->getMessage();
1229 1229
 					}
1230 1230
 				}
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		return '';
1236 1236
         }
1237 1237
 
1238
-	public static function tle($filename,$tletype) {
1238
+	public static function tle($filename, $tletype) {
1239 1239
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1240 1240
 		global $tmp_dir, $globalTransaction;
1241 1241
 		//$Spotter = new Spotter();
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 			$Connection = new Connection();
1246 1246
 			$sth = $Connection->db->prepare($query);
1247 1247
                         $sth->execute(array(':source' => $filename));
1248
-                } catch(PDOException $e) {
1248
+                } catch (PDOException $e) {
1249 1249
                         return "error : ".$e->getMessage();
1250 1250
                 }
1251 1251
 		
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1271 1271
 					try {
1272 1272
 						$sth = $Connection->db->prepare($query);
1273
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1274
-					} catch(PDOException $e) {
1273
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1274
+					} catch (PDOException $e) {
1275 1275
 						return "error : ".$e->getMessage();
1276 1276
 					}
1277 1277
 
@@ -1291,28 +1291,28 @@  discard block
 block discarded – undo
1291 1291
         */
1292 1292
         private static function table2array($data) {
1293 1293
                 $html = str_get_html($data);
1294
-                $tabledata=array();
1295
-                foreach($html->find('tr') as $element)
1294
+                $tabledata = array();
1295
+                foreach ($html->find('tr') as $element)
1296 1296
                 {
1297 1297
                         $td = array();
1298
-                        foreach( $element->find('th') as $row)
1298
+                        foreach ($element->find('th') as $row)
1299 1299
                         {
1300 1300
                                 $td [] = trim($row->plaintext);
1301 1301
                         }
1302
-                        $td=array_filter($td);
1302
+                        $td = array_filter($td);
1303 1303
                         $tabledata[] = $td;
1304 1304
 
1305 1305
                         $td = array();
1306 1306
                         $tdi = array();
1307
-                        foreach( $element->find('td') as $row)
1307
+                        foreach ($element->find('td') as $row)
1308 1308
                         {
1309 1309
                                 $td [] = trim($row->plaintext);
1310 1310
                                 $tdi [] = trim($row->innertext);
1311 1311
                         }
1312
-                        $td=array_filter($td);
1313
-                        $tdi=array_filter($tdi);
1312
+                        $td = array_filter($td);
1313
+                        $tdi = array_filter($tdi);
1314 1314
                     //    $tabledata[]=array_merge($td,$tdi);
1315
-                        $tabledata[]=$td;
1315
+                        $tabledata[] = $td;
1316 1316
                 }
1317 1317
                 return(array_filter($tabledata));
1318 1318
         }
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1386
 			{
1387 1387
 				$i++;
1388
-				if($i > 3 && count($row) > 2) {
1388
+				if ($i > 3 && count($row) > 2) {
1389 1389
 					$data = array_values(array_filter($row));
1390 1390
 					$cntdata = count($data);
1391 1391
 					if ($cntdata > 10) {
1392 1392
 						$value = $data[9];
1393 1393
 						
1394
-						for ($i =10;$i < $cntdata;$i++) {
1394
+						for ($i = 10; $i < $cntdata; $i++) {
1395 1395
 							$value .= ' '.$data[$i];
1396 1396
 						}
1397 1397
 						$data[9] = $value;
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1402 1402
 						try {
1403 1403
 							$sth = $Connection->db->prepare($query);
1404
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1405
-						} catch(PDOException $e) {
1404
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1405
+						} catch (PDOException $e) {
1406 1406
 							return "error : ".$e->getMessage();
1407 1407
 						}
1408 1408
 					}
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 			$Connection = new Connection();
1424 1424
 			$sth = $Connection->db->prepare($query);
1425 1425
                         $sth->execute();
1426
-                } catch(PDOException $e) {
1426
+                } catch (PDOException $e) {
1427 1427
                         return "error : ".$e->getMessage();
1428 1428
                 }
1429 1429
 
@@ -1435,12 +1435,12 @@  discard block
 block discarded – undo
1435 1435
 			if ($globalTransaction) $Connection->db->beginTransaction();
1436 1436
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1437 1437
 			{
1438
-				if(count($row) > 1) {
1438
+				if (count($row) > 1) {
1439 1439
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1440 1440
 					try {
1441 1441
 						$sth = $Connection->db->prepare($query);
1442
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1443
-					} catch(PDOException $e) {
1442
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1443
+					} catch (PDOException $e) {
1444 1444
 						return "error : ".$e->getMessage();
1445 1445
 					}
1446 1446
 				}
@@ -1460,21 +1460,21 @@  discard block
 block discarded – undo
1460 1460
 			try {
1461 1461
 				$sth = $Connection->db->prepare($query);
1462 1462
                     		$sth->execute();
1463
-	                } catch(PDOException $e) {
1463
+	                } catch (PDOException $e) {
1464 1464
 				return "error : ".$e->getMessage();
1465 1465
 	                }
1466 1466
 	        }
1467 1467
 
1468 1468
 
1469
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1469
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1470 1470
 		else {
1471
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1471
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1472 1472
 			$query = "CREATE EXTENSION postgis";
1473
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1473
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1474 1474
 			try {
1475 1475
 				$sth = $Connection->db->prepare($query);
1476 1476
 				$sth->execute();
1477
-			} catch(PDOException $e) {
1477
+			} catch (PDOException $e) {
1478 1478
 				return "error : ".$e->getMessage();
1479 1479
 			}
1480 1480
 		}
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 		include_once('class.create_db.php');
1488 1488
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1489 1489
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1490
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1490
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1491 1491
 		$error = '';
1492 1492
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1493 1493
 			if ($globalDebug) echo "Gunzip...";
@@ -1519,14 +1519,14 @@  discard block
 block discarded – undo
1519 1519
 			try {
1520 1520
 				$sth = $Connection->db->prepare($query);
1521 1521
             	        	$sth->execute();
1522
-	                } catch(PDOException $e) {
1522
+	                } catch (PDOException $e) {
1523 1523
     	                	echo "error : ".$e->getMessage();
1524 1524
 	                }
1525 1525
 		}
1526 1526
 		if ($globalDBdriver == 'mysql') {
1527
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1527
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1528 1528
 		} else {
1529
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1529
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1530 1530
 		}
1531 1531
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1532 1532
 		return $error;
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1540 1540
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1541 1541
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1542
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1542
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1543 1543
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1544 1544
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1545 1545
 		return $error;
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1560 1560
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1561 1561
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1562
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1562
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1563 1563
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1564 1564
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1565 1565
 		if ($error != '') {
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 		global $tmp_dir, $globalDebug;
1573 1573
 		$error = '';
1574 1574
 		if ($globalDebug) echo "Routes : Download...";
1575
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1575
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1576 1576
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1577 1577
 			if ($globalDebug) echo "Gunzip...";
1578 1578
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 		global $tmp_dir, $globalDebug;
1589 1589
 		$error = '';
1590 1590
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1591
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1591
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1592 1592
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1593 1593
 			if ($globalDebug) echo "Gunzip...";
1594 1594
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 		global $tmp_dir, $globalDebug;
1605 1605
 		$error = '';
1606 1606
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1607
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1607
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1608 1608
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1609 1609
 			if ($globalDebug) echo "Gunzip...";
1610 1610
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 */
1633 1633
 		if ($globalDebug) echo "Modes : Download...";
1634 1634
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1635
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1635
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1636 1636
 
1637 1637
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1638 1638
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 	public static function update_ModeS_faa() {
1653 1653
 		global $tmp_dir, $globalDebug;
1654 1654
 		if ($globalDebug) echo "Modes FAA: Download...";
1655
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1655
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1656 1656
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1657 1657
 			if ($globalDebug) echo "Unzip...";
1658 1658
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
 	public static function update_ModeS_flarm() {
1669 1669
 		global $tmp_dir, $globalDebug;
1670 1670
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1671
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1671
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1672 1672
 		if (file_exists($tmp_dir.'data.fln')) {
1673 1673
 			if ($globalDebug) echo "Add to DB...";
1674 1674
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 	public static function update_ModeS_ogn() {
1683 1683
 		global $tmp_dir, $globalDebug;
1684 1684
 		if ($globalDebug) echo "Modes OGN: Download...";
1685
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1685
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1686 1686
 		if (file_exists($tmp_dir.'ogn.csv')) {
1687 1687
 			if ($globalDebug) echo "Add to DB...";
1688 1688
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1697,201 +1697,201 @@  discard block
 block discarded – undo
1697 1697
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1698 1698
 		
1699 1699
 		if ($globalDebug) echo "Owner France: Download...";
1700
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1700
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1701 1701
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1702 1702
 			if ($globalDebug) echo "Add to DB...";
1703
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1703
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1704 1704
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1705 1705
 		if ($error != '') {
1706 1706
 			return $error;
1707 1707
 		} elseif ($globalDebug) echo "Done\n";
1708 1708
 		
1709 1709
 		if ($globalDebug) echo "Owner Ireland: Download...";
1710
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1710
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1711 1711
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1712 1712
 			if ($globalDebug) echo "Add to DB...";
1713
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1713
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1714 1714
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1715 1715
 		if ($error != '') {
1716 1716
 			return $error;
1717 1717
 		} elseif ($globalDebug) echo "Done\n";
1718 1718
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1719
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1719
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1720 1720
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1721 1721
 			if ($globalDebug) echo "Add to DB...";
1722
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1722
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1723 1723
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1724 1724
 		if ($error != '') {
1725 1725
 			return $error;
1726 1726
 		} elseif ($globalDebug) echo "Done\n";
1727 1727
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1728
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1728
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1729 1729
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1730 1730
 			if ($globalDebug) echo "Add to DB...";
1731
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1731
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1732 1732
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1733 1733
 		if ($error != '') {
1734 1734
 			return $error;
1735 1735
 		} elseif ($globalDebug) echo "Done\n";
1736 1736
 		if ($globalDebug) echo "Owner Australia: Download...";
1737
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1737
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1738 1738
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1739 1739
 			if ($globalDebug) echo "Add to DB...";
1740
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1740
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1741 1741
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1742 1742
 		if ($error != '') {
1743 1743
 			return $error;
1744 1744
 		} elseif ($globalDebug) echo "Done\n";
1745 1745
 		if ($globalDebug) echo "Owner Austria: Download...";
1746
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1746
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1747 1747
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1748 1748
 			if ($globalDebug) echo "Add to DB...";
1749
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1749
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1750 1750
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1751 1751
 		if ($error != '') {
1752 1752
 			return $error;
1753 1753
 		} elseif ($globalDebug) echo "Done\n";
1754 1754
 		if ($globalDebug) echo "Owner Chile: Download...";
1755
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1755
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1756 1756
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1757 1757
 			if ($globalDebug) echo "Add to DB...";
1758
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1758
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1759 1759
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1760 1760
 		if ($error != '') {
1761 1761
 			return $error;
1762 1762
 		} elseif ($globalDebug) echo "Done\n";
1763 1763
 		if ($globalDebug) echo "Owner Colombia: Download...";
1764
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1764
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1765 1765
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1766 1766
 			if ($globalDebug) echo "Add to DB...";
1767
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1767
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1768 1768
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1769 1769
 		if ($error != '') {
1770 1770
 			return $error;
1771 1771
 		} elseif ($globalDebug) echo "Done\n";
1772 1772
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1773
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1773
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1774 1774
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1775 1775
 			if ($globalDebug) echo "Add to DB...";
1776
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1776
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1777 1777
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1778 1778
 		if ($error != '') {
1779 1779
 			return $error;
1780 1780
 		} elseif ($globalDebug) echo "Done\n";
1781 1781
 		if ($globalDebug) echo "Owner Brazil: Download...";
1782
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1782
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1783 1783
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1784 1784
 			if ($globalDebug) echo "Add to DB...";
1785
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1785
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1786 1786
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1787 1787
 		if ($error != '') {
1788 1788
 			return $error;
1789 1789
 		} elseif ($globalDebug) echo "Done\n";
1790 1790
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1791
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1791
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1792 1792
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1793 1793
 			if ($globalDebug) echo "Add to DB...";
1794
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1794
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1795 1795
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1796 1796
 		if ($error != '') {
1797 1797
 			return $error;
1798 1798
 		} elseif ($globalDebug) echo "Done\n";
1799 1799
 		if ($globalDebug) echo "Owner Croatia: Download...";
1800
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1800
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1801 1801
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1802 1802
 			if ($globalDebug) echo "Add to DB...";
1803
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1803
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1804 1804
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
1807 1807
 		} elseif ($globalDebug) echo "Done\n";
1808 1808
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1809
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1809
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1810 1810
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1811 1811
 			if ($globalDebug) echo "Add to DB...";
1812
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1812
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1813 1813
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1814 1814
 		if ($error != '') {
1815 1815
 			return $error;
1816 1816
 		} elseif ($globalDebug) echo "Done\n";
1817 1817
 		if ($globalDebug) echo "Owner Maldives: Download...";
1818
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1818
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1819 1819
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1820 1820
 			if ($globalDebug) echo "Add to DB...";
1821
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1821
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1822 1822
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1823 1823
 		if ($error != '') {
1824 1824
 			return $error;
1825 1825
 		} elseif ($globalDebug) echo "Done\n";
1826 1826
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1827
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1827
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1828 1828
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1829 1829
 			if ($globalDebug) echo "Add to DB...";
1830
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1830
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1831 1831
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1832 1832
 		if ($error != '') {
1833 1833
 			return $error;
1834 1834
 		} elseif ($globalDebug) echo "Done\n";
1835 1835
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1836
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1836
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1837 1837
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1838 1838
 			if ($globalDebug) echo "Add to DB...";
1839
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1839
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1840 1840
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1841 1841
 		if ($error != '') {
1842 1842
 			return $error;
1843 1843
 		} elseif ($globalDebug) echo "Done\n";
1844 1844
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1845
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1845
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1846 1846
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1847 1847
 			if ($globalDebug) echo "Add to DB...";
1848
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1848
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1849 1849
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1850 1850
 		if ($error != '') {
1851 1851
 			return $error;
1852 1852
 		} elseif ($globalDebug) echo "Done\n";
1853 1853
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1854
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1854
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1855 1855
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1856 1856
 			if ($globalDebug) echo "Add to DB...";
1857
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1857
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1858 1858
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1859 1859
 		if ($error != '') {
1860 1860
 			return $error;
1861 1861
 		} elseif ($globalDebug) echo "Done\n";
1862 1862
 		if ($globalDebug) echo "Owner Iceland: Download...";
1863
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1863
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1864 1864
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1865 1865
 			if ($globalDebug) echo "Add to DB...";
1866
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1866
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1867 1867
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1868 1868
 		if ($error != '') {
1869 1869
 			return $error;
1870 1870
 		} elseif ($globalDebug) echo "Done\n";
1871 1871
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1872
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1872
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1873 1873
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1874 1874
 			if ($globalDebug) echo "Add to DB...";
1875
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1875
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1876 1876
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1877 1877
 		if ($error != '') {
1878 1878
 			return $error;
1879 1879
 		} elseif ($globalDebug) echo "Done\n";
1880 1880
 		if ($globalMasterSource) {
1881 1881
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1882
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1882
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1883 1883
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1884 1884
 				if ($globalDebug) echo "Add to DB...";
1885
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1885
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1886 1886
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1887 1887
 			if ($error != '') {
1888 1888
 				return $error;
1889 1889
 			} elseif ($globalDebug) echo "Done\n";
1890 1890
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1891
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1891
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1892 1892
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1893 1893
 				if ($globalDebug) echo "Add to DB...";
1894
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1894
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1895 1895
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1896 1896
 			if ($error != '') {
1897 1897
 				return $error;
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 		global $tmp_dir, $globalDebug;
1905 1905
 		$error = '';
1906 1906
 		if ($globalDebug) echo "Translation : Download...";
1907
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1907
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1908 1908
 		if (file_exists($tmp_dir.'translation.zip')) {
1909 1909
 			if ($globalDebug) echo "Unzip...";
1910 1910
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
 	public static function update_translation_fam() {
1921 1921
 		global $tmp_dir, $globalDebug;
1922 1922
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1923
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1923
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1924 1924
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1925 1925
 			if ($globalDebug) echo "Gunzip...";
1926 1926
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 	public static function update_ModeS_fam() {
1936 1936
 		global $tmp_dir, $globalDebug;
1937 1937
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1938
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1938
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1939 1939
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1940 1940
 			if ($globalDebug) echo "Gunzip...";
1941 1941
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1951,9 +1951,9 @@  discard block
 block discarded – undo
1951 1951
 		global $tmp_dir, $globalDebug, $globalOwner;
1952 1952
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1953 1953
 		if ($globalOwner === TRUE) {
1954
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1954
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1955 1955
 		} else {
1956
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1956
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1957 1957
 		}
1958 1958
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1959 1959
 			if ($globalDebug) echo "Gunzip...";
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	public static function update_routes_fam() {
1970 1970
 		global $tmp_dir, $globalDebug;
1971 1971
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1972
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1972
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1973 1973
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1974 1974
 			if ($globalDebug) echo "Gunzip...";
1975 1975
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 	public static function update_banned_fam() {
1985 1985
 		global $tmp_dir, $globalDebug;
1986 1986
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
1987
-		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1987
+		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv');
1988 1988
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1989 1989
 			//if ($globalDebug) echo "Gunzip...";
1990 1990
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2003,18 +2003,18 @@  discard block
 block discarded – undo
2003 2003
 		$error = '';
2004 2004
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2005 2005
 		if ($globalDBdriver == 'mysql') {
2006
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2006
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2007 2007
 		} else {
2008
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2008
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2009 2009
 		}
2010 2010
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2011
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2011
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2012 2012
 			$airspace_md5 = $airspace_md5_file[0];
2013 2013
 			if (!update_db::check_airspace_version($airspace_md5)) {
2014 2014
 				if ($globalDBdriver == 'mysql') {
2015
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2015
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2016 2016
 				} else {
2017
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2017
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2018 2018
 				}
2019 2019
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2020 2020
 					if ($globalDebug) echo "Gunzip...";
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 						try {
2027 2027
 							$sth = $Connection->db->prepare($query);
2028 2028
     	    	    					$sth->execute();
2029
-			            		} catch(PDOException $e) {
2029
+			            		} catch (PDOException $e) {
2030 2030
 							return "error : ".$e->getMessage();
2031 2031
 		            			}
2032 2032
 		    			}
@@ -2044,15 +2044,15 @@  discard block
 block discarded – undo
2044 2044
 	public static function update_tle() {
2045 2045
 		global $tmp_dir, $globalDebug;
2046 2046
 		if ($globalDebug) echo "Download TLE : Download...";
2047
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2048
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2049
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2047
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2048
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2049
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2050 2050
 		foreach ($alltle as $filename) {
2051 2051
 			if ($globalDebug) echo "downloading ".$filename.'...';
2052
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2052
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2053 2053
 			if (file_exists($tmp_dir.$filename)) {
2054 2054
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2055
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2055
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2056 2056
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2057 2057
 			if ($error != '') {
2058 2058
 				echo $error."\n";
@@ -2065,32 +2065,32 @@  discard block
 block discarded – undo
2065 2065
 		global $tmp_dir, $globalDebug;
2066 2066
 		$error = '';
2067 2067
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2068
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2068
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2069 2069
 		if (file_exists($tmp_dir.'models.md5sum')) {
2070 2070
 			if ($globalDebug) echo "Check files...\n";
2071 2071
 			$newmodelsdb = array();
2072
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2073
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2072
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2073
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2074 2074
 					$model = trim($row[2]);
2075 2075
 					$newmodelsdb[$model] = trim($row[0]);
2076 2076
 				}
2077 2077
 			}
2078 2078
 			$modelsdb = array();
2079 2079
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2080
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2081
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2080
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2081
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2082 2082
 						$model = trim($row[2]);
2083 2083
 						$modelsdb[$model] = trim($row[0]);
2084 2084
 					}
2085 2085
 				}
2086 2086
 			}
2087
-			$diff = array_diff($newmodelsdb,$modelsdb);
2087
+			$diff = array_diff($newmodelsdb, $modelsdb);
2088 2088
 			foreach ($diff as $key => $value) {
2089 2089
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2090
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2090
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2091 2091
 				
2092 2092
 			}
2093
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2093
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2094 2094
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2095 2095
 		if ($error != '') {
2096 2096
 			return $error;
@@ -2102,32 +2102,32 @@  discard block
 block discarded – undo
2102 2102
 		global $tmp_dir, $globalDebug;
2103 2103
 		$error = '';
2104 2104
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2105
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2105
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2106 2106
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2107 2107
 			if ($globalDebug) echo "Check files...\n";
2108 2108
 			$newmodelsdb = array();
2109
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2110
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2109
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2110
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2111 2111
 					$model = trim($row[2]);
2112 2112
 					$newmodelsdb[$model] = trim($row[0]);
2113 2113
 				}
2114 2114
 			}
2115 2115
 			$modelsdb = array();
2116 2116
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2117
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2118
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2117
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2118
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2119 2119
 						$model = trim($row[2]);
2120 2120
 						$modelsdb[$model] = trim($row[0]);
2121 2121
 					}
2122 2122
 				}
2123 2123
 			}
2124
-			$diff = array_diff($newmodelsdb,$modelsdb);
2124
+			$diff = array_diff($newmodelsdb, $modelsdb);
2125 2125
 			foreach ($diff as $key => $value) {
2126 2126
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2127
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2127
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2128 2128
 				
2129 2129
 			}
2130
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2130
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2131 2131
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2132 2132
 		if ($error != '') {
2133 2133
 			return $error;
@@ -2150,8 +2150,8 @@  discard block
 block discarded – undo
2150 2150
 		*/
2151 2151
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2152 2152
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
-		    $result = fread($fh,100000000);
2153
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2154
+		    $result = fread($fh, 100000000);
2155 2155
 		    //echo $result;
2156 2156
 		    //var_dump(str_get_html($result));
2157 2157
 		    //print_r(self::table2array($result));
@@ -2169,23 +2169,23 @@  discard block
 block discarded – undo
2169 2169
 			$Connection = new Connection();
2170 2170
 			$sth = $Connection->db->prepare($query);
2171 2171
                         $sth->execute();
2172
-                } catch(PDOException $e) {
2172
+                } catch (PDOException $e) {
2173 2173
                         return "error : ".$e->getMessage();
2174 2174
                 }
2175 2175
 
2176 2176
 		$error = '';
2177 2177
 		if ($globalDebug) echo "Notam : Download...";
2178
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2178
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2179 2179
 		if (file_exists($tmp_dir.'notam.rss')) {
2180
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2180
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2181 2181
 			foreach ($notams['channel']['item'] as $notam) {
2182
-				$title = explode(':',$notam['title']);
2182
+				$title = explode(':', $notam['title']);
2183 2183
 				$data['ref'] = trim($title[0]);
2184 2184
 				unset($title[0]);
2185
-				$data['title'] = trim(implode(':',$title));
2186
-				$description = strip_tags($notam['description'],'<pre>');
2187
-				preg_match(':^(.*?)<pre>:',$description,$match);
2188
-				$q = explode('/',$match[1]);
2185
+				$data['title'] = trim(implode(':', $title));
2186
+				$description = strip_tags($notam['description'], '<pre>');
2187
+				preg_match(':^(.*?)<pre>:', $description, $match);
2188
+				$q = explode('/', $match[1]);
2189 2189
 				$data['fir'] = $q[0];
2190 2190
 				$data['code'] = $q[1];
2191 2191
 				$ifrvfr = $q[2];
@@ -2201,30 +2201,30 @@  discard block
 block discarded – undo
2201 2201
 				$data['lower_limit'] = $q[5];
2202 2202
 				$data['upper_limit'] = $q[6];
2203 2203
 				$latlonrad = $q[7];
2204
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2205
-				$latitude = $Common->convertDec($las,'latitude');
2206
-				$longitude = $Common->convertDec($lns,'longitude');
2204
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2205
+				$latitude = $Common->convertDec($las, 'latitude');
2206
+				$longitude = $Common->convertDec($lns, 'longitude');
2207 2207
 				if ($lac == 'S') $latitude = '-'.$latitude;
2208 2208
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2209 2209
 				$data['center_latitude'] = $latitude;
2210 2210
 				$data['center_longitude'] = $longitude;
2211 2211
 				$data['radius'] = intval($radius);
2212 2212
 				
2213
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2213
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2214 2214
 				$data['text'] = $match[1];
2215
-				preg_match(':</pre>(.*?)$:',$description,$match);
2215
+				preg_match(':</pre>(.*?)$:', $description, $match);
2216 2216
 				$fromto = $match[1];
2217
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2217
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2218 2218
 				$fromall = trim($match[1]);
2219
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2219
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2220 2220
 				$from = trim($match[1]);
2221
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2222
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2221
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2222
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2223 2223
 				$toall = trim($match[1]);
2224
-				if (!preg_match(':Permanent:',$toall)) {
2225
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2224
+				if (!preg_match(':Permanent:', $toall)) {
2225
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2226 2226
 					$to = trim($match[1]);
2227
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2227
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2228 2228
 					$data['permanent'] = 0;
2229 2229
 				} else {
2230 2230
 				    $data['date_end'] = NULL;
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
 				}
2233 2233
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2234 2234
 				$NOTAM = new NOTAM();
2235
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2235
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2236 2236
 				unset($data);
2237 2237
 			} 
2238 2238
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2255,16 +2255,16 @@  discard block
 block discarded – undo
2255 2255
 				$Connection = new Connection();
2256 2256
 				$sth = $Connection->db->prepare($query);
2257 2257
 				$sth->execute();
2258
-			} catch(PDOException $e) {
2258
+			} catch (PDOException $e) {
2259 2259
 				return "error : ".$e->getMessage();
2260 2260
 			}
2261 2261
 		}
2262 2262
 		$Common = new Common();
2263 2263
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2264
-		$airspace_json = json_decode($airspace_lst,true);
2264
+		$airspace_json = json_decode($airspace_lst, true);
2265 2265
 		foreach ($airspace_json['records'] as $airspace) {
2266 2266
 			if ($globalDebug) echo $airspace['name']."...\n";
2267
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2267
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2268 2268
 			if (file_exists($tmp_dir.$airspace['name'])) {
2269 2269
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2270 2270
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2286,7 +2286,7 @@  discard block
 block discarded – undo
2286 2286
 				$Connection = new Connection();
2287 2287
 				$sth = $Connection->db->prepare($query);
2288 2288
 				$sth->execute(array(':new' => $new, ':old' => $old));
2289
-			} catch(PDOException $e) {
2289
+			} catch (PDOException $e) {
2290 2290
 				return "error : ".$e->getMessage();
2291 2291
 			}
2292 2292
 		}
@@ -2303,7 +2303,7 @@  discard block
 block discarded – undo
2303 2303
 			$Connection = new Connection();
2304 2304
 			$sth = $Connection->db->prepare($query);
2305 2305
                         $sth->execute();
2306
-                } catch(PDOException $e) {
2306
+                } catch (PDOException $e) {
2307 2307
                         return "error : ".$e->getMessage();
2308 2308
                 }
2309 2309
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 			$Connection = new Connection();
2319 2319
 			$sth = $Connection->db->prepare($query);
2320 2320
                         $sth->execute();
2321
-                } catch(PDOException $e) {
2321
+                } catch (PDOException $e) {
2322 2322
                         return "error : ".$e->getMessage();
2323 2323
                 }
2324 2324
 	}
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 			$Connection = new Connection();
2330 2330
 			$sth = $Connection->db->prepare($query);
2331 2331
                         $sth->execute(array(':version' => $version));
2332
-                } catch(PDOException $e) {
2332
+                } catch (PDOException $e) {
2333 2333
                         return "error : ".$e->getMessage();
2334 2334
                 }
2335 2335
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
 			$Connection = new Connection();
2346 2346
 			$sth = $Connection->db->prepare($query);
2347 2347
                         $sth->execute(array(':version' => $version));
2348
-                } catch(PDOException $e) {
2348
+                } catch (PDOException $e) {
2349 2349
                         return "error : ".$e->getMessage();
2350 2350
                 }
2351 2351
 	}
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 			$Connection = new Connection();
2362 2362
 			$sth = $Connection->db->prepare($query);
2363 2363
                         $sth->execute();
2364
-                } catch(PDOException $e) {
2364
+                } catch (PDOException $e) {
2365 2365
                         return "error : ".$e->getMessage();
2366 2366
                 }
2367 2367
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
 			$Connection = new Connection();
2377 2377
 			$sth = $Connection->db->prepare($query);
2378 2378
                         $sth->execute();
2379
-                } catch(PDOException $e) {
2379
+                } catch (PDOException $e) {
2380 2380
                         return "error : ".$e->getMessage();
2381 2381
                 }
2382 2382
 	}
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 			$Connection = new Connection();
2392 2392
 			$sth = $Connection->db->prepare($query);
2393 2393
                         $sth->execute();
2394
-                } catch(PDOException $e) {
2394
+                } catch (PDOException $e) {
2395 2395
                         return "error : ".$e->getMessage();
2396 2396
                 }
2397 2397
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 			$Connection = new Connection();
2407 2407
 			$sth = $Connection->db->prepare($query);
2408 2408
                         $sth->execute();
2409
-                } catch(PDOException $e) {
2409
+                } catch (PDOException $e) {
2410 2410
                         return "error : ".$e->getMessage();
2411 2411
                 }
2412 2412
 	}
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 			$Connection = new Connection();
2423 2423
 			$sth = $Connection->db->prepare($query);
2424 2424
                         $sth->execute();
2425
-                } catch(PDOException $e) {
2425
+                } catch (PDOException $e) {
2426 2426
                         return "error : ".$e->getMessage();
2427 2427
                 }
2428 2428
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
 			$Connection = new Connection();
2438 2438
 			$sth = $Connection->db->prepare($query);
2439 2439
                         $sth->execute();
2440
-                } catch(PDOException $e) {
2440
+                } catch (PDOException $e) {
2441 2441
                         return "error : ".$e->getMessage();
2442 2442
                 }
2443 2443
 	}
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 			$Connection = new Connection();
2453 2453
 			$sth = $Connection->db->prepare($query);
2454 2454
                         $sth->execute();
2455
-                } catch(PDOException $e) {
2455
+                } catch (PDOException $e) {
2456 2456
                         return "error : ".$e->getMessage();
2457 2457
                 }
2458 2458
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 			$Connection = new Connection();
2468 2468
 			$sth = $Connection->db->prepare($query);
2469 2469
                         $sth->execute();
2470
-                } catch(PDOException $e) {
2470
+                } catch (PDOException $e) {
2471 2471
                         return "error : ".$e->getMessage();
2472 2472
                 }
2473 2473
 	}
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 			$Connection = new Connection();
2483 2483
 			$sth = $Connection->db->prepare($query);
2484 2484
                         $sth->execute();
2485
-                } catch(PDOException $e) {
2485
+                } catch (PDOException $e) {
2486 2486
                         return "error : ".$e->getMessage();
2487 2487
                 }
2488 2488
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 			$Connection = new Connection();
2498 2498
 			$sth = $Connection->db->prepare($query);
2499 2499
                         $sth->execute();
2500
-                } catch(PDOException $e) {
2500
+                } catch (PDOException $e) {
2501 2501
                         return "error : ".$e->getMessage();
2502 2502
                 }
2503 2503
 	}
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
 			$Connection = new Connection();
2513 2513
 			$sth = $Connection->db->prepare($query);
2514 2514
                         $sth->execute();
2515
-                } catch(PDOException $e) {
2515
+                } catch (PDOException $e) {
2516 2516
                         return "error : ".$e->getMessage();
2517 2517
                 }
2518 2518
 	}
@@ -2527,7 +2527,7 @@  discard block
 block discarded – undo
2527 2527
 			$Connection = new Connection();
2528 2528
 			$sth = $Connection->db->prepare($query);
2529 2529
                         $sth->execute();
2530
-                } catch(PDOException $e) {
2530
+                } catch (PDOException $e) {
2531 2531
                         return "error : ".$e->getMessage();
2532 2532
                 }
2533 2533
 	}
Please login to merge, or discard this patch.
install/index.php 2 patches
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.create_db.php');
11 11
 require_once(dirname(__FILE__).'/class.update_schema.php');
12 12
 require_once(dirname(__FILE__).'/class.settings.php');
13
-$title="Install";
13
+$title = "Install";
14 14
 require(dirname(__FILE__).'/../require/settings.php');
15 15
 require(dirname(__FILE__).'/header.php');
16 16
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 if (!extension_loaded('curl')) {
70 70
 	$error[] = "Curl is not loaded.";
71 71
 }
72
-if(function_exists('apache_get_modules') ){
73
-	if(!in_array('mod_rewrite',apache_get_modules())) {
72
+if (function_exists('apache_get_modules')) {
73
+	if (!in_array('mod_rewrite', apache_get_modules())) {
74 74
 		$error[] = "mod_rewrite is not available.";
75 75
 	}
76 76
 /*
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
87 87
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
88 88
 	if (function_exists('get_headers')) {
89
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
90
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
89
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
90
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
91 91
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
92 92
 		}
93 93
 	}
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 ?>
439 439
 							<tr>
440 440
 								<?php
441
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
441
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
442 442
 								?>
443 443
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
444 444
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
445 445
 								<?php
446 446
 								    } else {
447
-									$hostport = explode(':',$source['host']);
447
+									$hostport = explode(':', $source['host']);
448 448
 									if (isset($hostport[1])) {
449 449
 										$host = $hostport[0];
450 450
 										$port = $hostport[1];
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 			<br />
781 781
 			<p>
782 782
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
783
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
783
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
784 784
 			</p>
785 785
 			<br />
786 786
 			<p>
@@ -826,14 +826,14 @@  discard block
 block discarded – undo
826 826
 $error = '';
827 827
 
828 828
 if (isset($_POST['dbtype'])) {
829
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
830
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
831
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
832
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
833
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
834
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
835
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
836
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
829
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
830
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
831
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
832
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
833
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
834
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
835
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
836
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
837 837
 
838 838
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
839 839
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -853,48 +853,48 @@  discard block
 block discarded – undo
853 853
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
854 854
 	*/
855 855
 	
856
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
856
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
857 857
 
858
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
859
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
860
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
861
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
862
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
858
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
859
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
860
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
861
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
862
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
863 863
 
864
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
865
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
866
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
867
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
868
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
869
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
870
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
871
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
872
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
864
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
865
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
866
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
867
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
868
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
869
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
870
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
871
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
872
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
873 873
 	
874
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
875
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
876
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
877
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
878
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
879
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
874
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
875
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
876
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
877
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
878
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
879
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
880 880
 
881
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
882
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
881
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
882
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
883 883
 
884
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
885
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
886
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
884
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
885
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
886
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
887 887
 
888
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
888
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
889 889
 	if ($acars == 'acars') {
890
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
890
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
891 891
 	} else {
892
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
892
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
893 893
 	}
894 894
 
895
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
896
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
897
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
895
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
896
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
897
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
898 898
 	
899 899
 	$source_name = $_POST['source_name'];
900 900
 	$source_latitude = $_POST['source_latitude'];
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
 	
909 909
 	$sources = array();
910 910
 	foreach ($source_name as $keys => $name) {
911
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
912
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
911
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
912
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
913 913
 	}
914 914
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
915 915
 
@@ -922,23 +922,23 @@  discard block
 block discarded – undo
922 922
 	$sbsurl = $_POST['sbsurl'];
923 923
 	*/
924 924
 
925
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
926
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
927
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
928
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
929
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
930
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
931
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
925
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
926
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
927
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
928
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
929
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
930
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
931
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
932 932
 
933
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
934
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
935
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
936
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
937
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
938
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
939
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
940
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
941
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
933
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
934
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
935
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
936
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
937
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
938
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
939
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
940
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
941
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
942 942
 
943 943
 /*	
944 944
 	$globalSBS1Hosts = array();
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 	}
955 955
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
956 956
 */
957
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
957
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
958 958
 	$host = $_POST['host'];
959 959
 	$port = $_POST['port'];
960 960
 	$name = $_POST['name'];
@@ -965,96 +965,96 @@  discard block
 block discarded – undo
965 965
 	foreach ($host as $key => $h) {
966 966
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
967 967
 		else $cov = 'FALSE';
968
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
968
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
969 969
 	}
970
-	$settings = array_merge($settings,array('globalSources' => $gSources));
970
+	$settings = array_merge($settings, array('globalSources' => $gSources));
971 971
 
972 972
 /*
973 973
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
974 974
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
975 975
 */
976
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
977
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
978
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
976
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
977
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
978
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
979 979
 
980
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
981
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
980
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
981
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
982 982
 
983
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
984
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
985
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
986
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
983
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
984
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
985
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
986
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
987 987
 
988
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
989
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
990
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
988
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
989
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
990
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
991 991
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
992
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
993
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
992
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
993
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
994 994
 
995
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
996
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
997
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
998
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
999
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1000
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1001
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1002
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
995
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
996
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
997
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
998
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
999
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1000
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1001
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1002
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1003 1003
 
1004
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1005
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1004
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1005
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1006 1006
 
1007
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1008
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1007
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1008
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1009 1009
 	
1010
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1010
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1011 1011
 	if ($archiveyear == "archiveyear") {
1012
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1012
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1013 1013
 	} else {
1014
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1014
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1015 1015
 	}
1016
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1017
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1018
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1019
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1016
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1017
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1018
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1019
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1020 1020
 
1021
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1022
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1023
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1024
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1021
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1022
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1023
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1024
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1025 1025
 
1026
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1027
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1028
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1026
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1027
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1028
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1029 1029
 
1030 1030
 	// Create in settings.php keys not yet configurable if not already here
1031 1031
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1032
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1032
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1033 1033
 
1034
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1034
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1035 1035
 	if ($resetyearstats == 'resetyearstats') {
1036
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1036
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1037 1037
 	} else {
1038
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1038
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1039 1039
 	}
1040 1040
 
1041
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1041
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1042 1042
 	if ($archive == 'archive') {
1043
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1043
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1044 1044
 	} else {
1045
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1045
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1046 1046
 	}
1047
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1047
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1048 1048
 	if ($daemon == 'daemon') {
1049
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1049
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1050 1050
 	} else {
1051
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1051
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1052 1052
 	}
1053
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1053
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1054 1054
 	if ($schedules == 'schedules') {
1055
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1055
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1056 1056
 	} else {
1057
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1057
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1058 1058
 	}
1059 1059
 
1060 1060
 /*
@@ -1065,177 +1065,177 @@  discard block
 block discarded – undo
1065 1065
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1066 1066
 	}
1067 1067
 */
1068
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1069
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1070
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1071
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1068
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1069
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1070
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1071
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1072
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1073 1073
 	if ($globalivao == 'ivao') {
1074 1074
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1075
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1076
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1075
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1076
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1077 1077
 	if ($globalvatsim == 'vatsim') {
1078 1078
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1079
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1080
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1079
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1080
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1081 1081
 	if ($globalphpvms == 'phpvms') {
1082
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1083
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1082
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1083
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1084 1084
 	if ($globalvam == 'vam') {
1085
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1086
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1085
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1086
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1087 1087
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1088
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1089
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1088
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1089
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1090 1090
 	
1091 1091
 
1092 1092
 
1093
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1093
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1094 1094
 	if ($notam == 'notam') {
1095
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1095
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1096 1096
 	} else {
1097
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1097
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1098 1098
 	}
1099
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1099
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1100 1100
 	if ($owner == 'owner') {
1101
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1101
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1102 1102
 	} else {
1103
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1103
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1104 1104
 	}
1105
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1105
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1106 1106
 	if ($map3d == 'map3d') {
1107
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1107
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1108 1108
 	} else {
1109
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1109
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1110 1110
 	}
1111
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1111
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1112 1112
 	if ($crash == 'crash') {
1113
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1113
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1114 1114
 	} else {
1115
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1115
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1116 1116
 	}
1117
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1117
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1118 1118
 	if ($mapsatellites == 'mapsatellites') {
1119
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1119
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1120 1120
 	} else {
1121
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1121
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1122 1122
 	}
1123
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1123
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1124 1124
 	if ($map3ddefault == 'map3ddefault') {
1125
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1125
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1126 1126
 	} else {
1127
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1127
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1128 1128
 	}
1129
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1129
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1130 1130
 	if ($translate == 'translate') {
1131
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1131
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1132 1132
 	} else {
1133
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1133
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1134 1134
 	}
1135
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1135
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1136 1136
 	if ($realairlines == 'realairlines') {
1137
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1137
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1138 1138
 	} else {
1139
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1139
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1140 1140
 	}
1141
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1141
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1142 1142
 	if ($estimation == 'estimation') {
1143
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1143
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1144 1144
 	} else {
1145
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1145
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1146 1146
 	}
1147
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1147
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1148 1148
 	if ($metar == 'metar') {
1149
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1149
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1150 1150
 	} else {
1151
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1151
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1152 1152
 	}
1153
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1153
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1154 1154
 	if ($metarcycle == 'metarcycle') {
1155
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1155
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1156 1156
 	} else {
1157
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1157
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1158 1158
 	}
1159
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1159
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1160 1160
 	if ($fork == 'fork') {
1161
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1161
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1162 1162
 	} else {
1163
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1163
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1164 1164
 	}
1165 1165
 
1166
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1166
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1167 1167
 	if ($colormap == 'colormap') {
1168
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1168
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1169 1169
 	} else {
1170
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1170
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1171 1171
 	}
1172 1172
 	
1173 1173
 	if (isset($_POST['aircrafticoncolor'])) {
1174
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1175
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1174
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1175
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1176 1176
 	}
1177 1177
 
1178
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1179
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1178
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1179
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1180 1180
 
1181
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1182
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1183
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1184
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1185
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1186
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1181
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1182
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1183
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1184
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1185
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1186
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1187 1187
 
1188
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1188
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1189 1189
 	if ($mappopup == 'mappopup') {
1190
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1190
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1191 1191
 	} else {
1192
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1192
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1193 1193
 	}
1194
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1194
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1195 1195
 	if ($airportpopup == 'airportpopup') {
1196
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1196
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1197 1197
 	} else {
1198
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1198
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1199 1199
 	}
1200
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1200
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1201 1201
 	if ($maphistory == 'maphistory') {
1202
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1202
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1203 1203
 	} else {
1204
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1204
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1205 1205
 	}
1206
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1206
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1207 1207
 	if ($flightroute == 'flightroute') {
1208
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1208
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1209 1209
 	} else {
1210
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1210
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1211 1211
 	}
1212
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1212
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1213 1213
 	if ($allflights == 'allflights') {
1214
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1214
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1215 1215
 	} else {
1216
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1216
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1217 1217
 	}
1218
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1218
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1219 1219
 	if ($waypoints == 'waypoints') {
1220
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1220
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1221 1221
 	} else {
1222
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1222
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1223 1223
 	}
1224 1224
 
1225
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1225
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1226 1226
 
1227 1227
 	// Set some defaults values...
1228 1228
 	if (!isset($globalAircraftImageSources)) {
1229
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1230
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1229
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1230
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1231 1231
 	}
1232 1232
 
1233 1233
 	if (!isset($globalSchedulesSources)) {
1234
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1235
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1234
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1235
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1236 1236
     	}
1237 1237
 
1238
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1238
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1239 1239
 
1240 1240
 	if ($error == '') settings::modify_settings($settings);
1241 1241
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +428 added lines, -113 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -397,11 +498,17 @@  discard block
 block discarded – undo
397 498
 			<div id="flightaware_data">
398 499
 				<p>
399 500
 					<label for="flightawareusername">FlightAware username</label>
400
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
501
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
502
+	print $globalFlightAwareUsername;
503
+}
504
+?>" />
401 505
 				</p>
402 506
 				<p>
403 507
 					<label for="flightawarepassword">FlightAware password/API key</label>
404
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
508
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
509
+	print $globalFlightAwarePassword;
510
+}
511
+?>" />
405 512
 				</p>
406 513
 			</div>
407 514
 -->
@@ -460,26 +567,80 @@  discard block
 block discarded – undo
460 567
 								?>
461 568
 								<td>
462 569
 									<select name="format[]" id="format">
463
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
464
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
465
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
466
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
467
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
468
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
469
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
470
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
471
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
472
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
473
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
474
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
475
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
476
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
477
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
478
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
570
+										<option value="auto" <?php if (!isset($source['format'])) {
571
+	print 'selected';
572
+}
573
+?>>Auto</option>
574
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
575
+	print 'selected';
576
+}
577
+?>>SBS</option>
578
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
579
+	print 'selected';
580
+}
581
+?>>TSV</option>
582
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
583
+	print 'selected';
584
+}
585
+?>>Raw</option>
586
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
587
+	print 'selected';
588
+}
589
+?>>APRS</option>
590
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
591
+	print 'selected';
592
+}
593
+?>>Radarcape deltadb.txt</option>
594
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
595
+	print 'selected';
596
+}
597
+?>>Vatsim</option>
598
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
599
+	print 'selected';
600
+}
601
+?>>Virtual Radar Server</option>
602
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
603
+	print 'selected';
604
+}
605
+?>>phpVMS</option>
606
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
607
+	print 'selected';
608
+}
609
+?>>Virtual Airlines Manager</option>
610
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
611
+	print 'selected';
612
+}
613
+?>>IVAO</option>
614
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
615
+	print 'selected';
616
+}
617
+?>>FlightGear Multiplayer</option>
618
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
619
+	print 'selected';
620
+}
621
+?>>FlightGear Singleplayer</option>
622
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
623
+	print 'selected';
624
+}
625
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
626
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
627
+	print 'selected';
628
+}
629
+?>>ACARS SBS-3 over TCP</option>
630
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
631
+	print 'selected';
632
+}
633
+?>>NMEA AIS over TCP</option>
479 634
 									</select>
480 635
 								</td>
481
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
482
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
636
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
637
+	print $source['name'];
638
+}
639
+?>" /></td>
640
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
641
+	print 'checked';
642
+}
643
+?> /></td>
483 644
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
484 645
 							</tr>
485 646
 <?php
@@ -526,11 +687,17 @@  discard block
 block discarded – undo
526 687
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
527 688
 					<p>
528 689
 						<label for="acarshost">ACARS UDP host</label>
529
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
690
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
691
+	print $globalACARSHost;
692
+}
693
+?>" />
530 694
 					</p>
531 695
 					<p>
532 696
 						<label for="acarsport">ACARS UDP port</label>
533
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
697
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
698
+	print $globalACARSPort;
699
+}
700
+?>" />
534 701
 					</p>
535 702
 				</fieldset>
536 703
 			</div>
@@ -610,13 +777,19 @@  discard block
 block discarded – undo
610 777
 			<div id="schedules_options">
611 778
 				<p>
612 779
 					<label for="britishairways">British Airways API Key</label>
613
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
780
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
781
+	print $globalBritishAirwaysKey;
782
+}
783
+?>" />
614 784
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
615 785
 				</p>
616 786
 				<!--
617 787
 				<p>
618 788
 					<label for="transavia">Transavia Test API Consumer Key</label>
619
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
789
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
790
+	print $globalTransaviaKey;
791
+}
792
+?>" />
620 793
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
621 794
 				</p>
622 795
 				-->
@@ -625,10 +798,16 @@  discard block
 block discarded – undo
625 798
 						<b>Lufthansa API Key</b>
626 799
 						<p>
627 800
 							<label for="lufthansakey">Key</label>
628
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
801
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
802
+	print $globalLufthansaKey['key'];
803
+}
804
+?>" />
629 805
 						</p><p>
630 806
 							<label for="lufthansasecret">Secret</label>
631
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
807
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
808
+	print $globalLufthansaKey['secret'];
809
+}
810
+?>" />
632 811
 						</p>
633 812
 					</div>
634 813
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -648,7 +827,10 @@  discard block
 block discarded – undo
648 827
 			</p>
649 828
 			<p>
650 829
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
651
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
830
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
831
+	print $globalNOTAMSource;
832
+}
833
+?>" />
652 834
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
653 835
 			</p>
654 836
 			<br />
@@ -664,14 +846,20 @@  discard block
 block discarded – undo
664 846
 			<div id="metarsrc">
665 847
 				<p>
666 848
 					<label for="metarsource">URL of your METAR source</label>
667
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
849
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
850
+	print $globalMETARurl;
851
+}
852
+?>" />
668 853
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
669 854
 				</p>
670 855
 			</div>
671 856
 			<br />
672 857
 			<p>
673 858
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
674
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
859
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
860
+	print $globalBitlyAccessToken;
861
+}
862
+?>" />
675 863
 			</p>
676 864
 			<br />
677 865
 			<p>
@@ -691,7 +879,12 @@  discard block
 block discarded – undo
691 879
 			</p>
692 880
 			<p>
693 881
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
694
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
882
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
883
+	print $globalArchiveMonths;
884
+} else {
885
+	echo '0';
886
+}
887
+?>" />
695 888
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
696 889
 			</p>
697 890
 			<p>
@@ -701,12 +894,22 @@  discard block
 block discarded – undo
701 894
 			</p>
702 895
 			<p>
703 896
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
704
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
897
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
898
+	print $globalArchiveKeepMonths;
899
+} else {
900
+	echo '0';
901
+}
902
+?>" />
705 903
 				<p class="help-block">0 to disable</p>
706 904
 			</p>
707 905
 			<p>
708 906
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
709
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
907
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
908
+	print $globalArchiveKeepTrackMonths;
909
+} else {
910
+	echo '0';
911
+}
912
+?>" />
710 913
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
711 914
 			</p>
712 915
 			<br />
@@ -716,7 +919,12 @@  discard block
 block discarded – undo
716 919
 				<p class="help-block">Uncheck if the script is running as cron job</p>
717 920
 				<div id="cronends"> 
718 921
 					<label for="cronend">Run script for xx seconds</label>
719
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
922
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
923
+	print $globalCronEnd;
924
+} else {
925
+	print '0';
926
+}
927
+?>" />
720 928
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
721 929
 				</div>
722 930
 			</p>
@@ -761,26 +969,49 @@  discard block
 block discarded – undo
761 969
 			<br />
762 970
 			<p>
763 971
 				<label for="refresh">Show flights detected since xxx seconds</label>
764
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
972
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
973
+	echo $globalLiveInterval;
974
+} else {
975
+	echo '200';
976
+}
977
+?>" />
765 978
 			</p>
766 979
 			<p>
767 980
 				<label for="maprefresh">Live map refresh (in seconds)</label>
768
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
981
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
982
+	echo $globalMapRefresh;
983
+} else {
984
+	echo '30';
985
+}
986
+?>" />
769 987
 			</p>
770 988
 			<p>
771 989
 				<label for="mapidle">Map idle timeout (in minutes)</label>
772
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
990
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
991
+	echo $globalMapIdleTimeout;
992
+} else {
993
+	echo '30';
994
+}
995
+?>" />
773 996
 				<p class="help-block">0 to disable</p>
774 997
 			</p>
775 998
 			<br />
776 999
 			<p>
777 1000
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
778
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1001
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1002
+	echo $globalClosestMinDist;
1003
+} else {
1004
+	echo '50';
1005
+}
1006
+?>" />
779 1007
 			</p>
780 1008
 			<br />
781 1009
 			<p>
782 1010
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
783
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1011
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1012
+	echo $globalAircraftSize;
1013
+}
1014
+?>" />
784 1015
 			</p>
785 1016
 			<br />
786 1017
 			<p>
@@ -788,7 +1019,12 @@  discard block
 block discarded – undo
788 1019
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
789 1020
 			?>
790 1021
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
791
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1022
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1023
+	echo $globalAircraftIconColor;
1024
+} else {
1025
+	echo '1a3151';
1026
+}
1027
+?>" />
792 1028
 			<?php
793 1029
 				if (!is_writable('../cache')) {
794 1030
 			?>
@@ -806,8 +1042,18 @@  discard block
 block discarded – undo
806 1042
 			<p>
807 1043
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
808 1044
 				<div class="range">
809
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
810
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1045
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1046
+	echo $globalAirportZoom;
1047
+} else {
1048
+	echo '7';
1049
+}
1050
+?>" />
1051
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1052
+	echo $globalAirportZoom;
1053
+} else {
1054
+	echo '7';
1055
+}
1056
+?></output>
811 1057
 				</div>
812 1058
 			</p>
813 1059
 		</fieldset>
@@ -835,8 +1081,12 @@  discard block
 block discarded – undo
835 1081
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
836 1082
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
837 1083
 
838
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
839
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1084
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1085
+		$error .= 'Mysql driver for PDO must be loaded';
1086
+	}
1087
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1088
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1089
+	}
840 1090
 	
841 1091
 	$_SESSION['database_root'] = $dbroot;
842 1092
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -903,15 +1153,23 @@  discard block
 block discarded – undo
903 1153
 	$source_city = $_POST['source_city'];
904 1154
 	$source_country = $_POST['source_country'];
905 1155
 	$source_ref = $_POST['source_ref'];
906
-	if (isset($source_id)) $source_id = $_POST['source_id'];
907
-	else $source_id = array();
1156
+	if (isset($source_id)) {
1157
+		$source_id = $_POST['source_id'];
1158
+	} else {
1159
+		$source_id = array();
1160
+	}
908 1161
 	
909 1162
 	$sources = array();
910 1163
 	foreach ($source_name as $keys => $name) {
911
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
912
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1164
+	    if (isset($source_id[$keys])) {
1165
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1166
+	    } else {
1167
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1168
+	    }
1169
+	}
1170
+	if (count($sources) > 0) {
1171
+		$_SESSION['sources'] = $sources;
913 1172
 	}
914
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
915 1173
 
916 1174
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
917 1175
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -931,14 +1189,23 @@  discard block
 block discarded – undo
931 1189
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
932 1190
 
933 1191
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
934
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
935
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1192
+	if ($globalaircraft == 'aircraft') {
1193
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1194
+	} else {
1195
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1196
+	}
936 1197
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
937
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
938
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1198
+	if ($globaltracker == 'tracker') {
1199
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1200
+	} else {
1201
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1202
+	}
939 1203
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
940
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
941
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1204
+	if ($globalmarine == 'marine') {
1205
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1206
+	} else {
1207
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1208
+	}
942 1209
 
943 1210
 /*	
944 1211
 	$globalSBS1Hosts = array();
@@ -959,13 +1226,21 @@  discard block
 block discarded – undo
959 1226
 	$port = $_POST['port'];
960 1227
 	$name = $_POST['name'];
961 1228
 	$format = $_POST['format'];
962
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
963
-	else $sourcestats = array();
1229
+	if (isset($_POST['sourcestats'])) {
1230
+		$sourcestats = $_POST['sourcestats'];
1231
+	} else {
1232
+		$sourcestats = array();
1233
+	}
964 1234
 	$gSources = array();
965 1235
 	foreach ($host as $key => $h) {
966
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
967
-		else $cov = 'FALSE';
968
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1236
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1237
+			$cov = 'TRUE';
1238
+		} else {
1239
+			$cov = 'FALSE';
1240
+		}
1241
+		if ($h != '') {
1242
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1243
+		}
969 1244
 	}
970 1245
 	$settings = array_merge($settings,array('globalSources' => $gSources));
971 1246
 
@@ -990,7 +1265,9 @@  discard block
 block discarded – undo
990 1265
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
991 1266
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
992 1267
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
993
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1268
+	} else {
1269
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1270
+	}
994 1271
 
995 1272
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
996 1273
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1029,7 +1306,9 @@  discard block
 block discarded – undo
1029 1306
 
1030 1307
 	// Create in settings.php keys not yet configurable if not already here
1031 1308
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1032
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1309
+	if (!isset($globalDebug)) {
1310
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1311
+	}
1033 1312
 
1034 1313
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1035 1314
 	if ($resetyearstats == 'resetyearstats') {
@@ -1066,27 +1345,43 @@  discard block
 block discarded – undo
1066 1345
 	}
1067 1346
 */
1068 1347
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1069
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1070
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1071
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1348
+	if ($globalsbs == 'sbs') {
1349
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1350
+	} else {
1351
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1352
+	}
1353
+	if ($globalaprs == 'aprs') {
1354
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1355
+	} else {
1356
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1357
+	}
1073 1358
 	if ($globalivao == 'ivao') {
1074 1359
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1075 1360
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1076
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1361
+	} else {
1362
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1363
+	}
1077 1364
 	if ($globalvatsim == 'vatsim') {
1078 1365
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1079 1366
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1080
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1367
+	} else {
1368
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1369
+	}
1081 1370
 	if ($globalphpvms == 'phpvms') {
1082 1371
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1083
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1372
+	} else {
1373
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1374
+	}
1084 1375
 	if ($globalvam == 'vam') {
1085 1376
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1086
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1377
+	} else {
1378
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1379
+	}
1087 1380
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1088 1381
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1089
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1382
+	} else {
1383
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1384
+	}
1090 1385
 	
1091 1386
 
1092 1387
 
@@ -1222,7 +1517,9 @@  discard block
 block discarded – undo
1222 1517
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1223 1518
 	}
1224 1519
 
1225
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1520
+	if (!isset($globalTransaction)) {
1521
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1522
+	}
1226 1523
 
1227 1524
 	// Set some defaults values...
1228 1525
 	if (!isset($globalAircraftImageSources)) {
@@ -1237,15 +1534,23 @@  discard block
 block discarded – undo
1237 1534
 
1238 1535
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1239 1536
 
1240
-	if ($error == '') settings::modify_settings($settings);
1241
-	if ($error == '') settings::comment_settings($settings_comment);
1537
+	if ($error == '') {
1538
+		settings::modify_settings($settings);
1539
+	}
1540
+	if ($error == '') {
1541
+		settings::comment_settings($settings_comment);
1542
+	}
1242 1543
 	if ($error != '') {
1243 1544
 		print '<div class="info column">'.$error.'</div>';
1244 1545
 		require('../footer.php');
1245 1546
 		exit;
1246 1547
 	} else {
1247
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1248
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1548
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1549
+			$_SESSION['waypoints'] = 1;
1550
+		}
1551
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1552
+			$_SESSION['owner'] = 1;
1553
+		}
1249 1554
 		if (isset($_POST['createdb'])) {
1250 1555
 			$_SESSION['install'] = 'database_create';
1251 1556
 		} else {
@@ -1286,10 +1591,18 @@  discard block
 block discarded – undo
1286 1591
 	$popw = false;
1287 1592
 	foreach ($_SESSION['done'] as $done) {
1288 1593
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1289
-	    if ($done == 'Create database') $pop = true;
1290
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1291
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1292
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1594
+	    if ($done == 'Create database') {
1595
+	    	$pop = true;
1596
+	    }
1597
+	    if ($_SESSION['install'] == 'database_create') {
1598
+	    	$pop = true;
1599
+	    }
1600
+	    if ($_SESSION['install'] == 'database_import') {
1601
+	    	$popi = true;
1602
+	    }
1603
+	    if ($_SESSION['install'] == 'waypoints') {
1604
+	    	$popw = true;
1605
+	    }
1293 1606
 	}
1294 1607
 	if ($pop) {
1295 1608
 	    sleep(5);
@@ -1300,7 +1613,9 @@  discard block
 block discarded – undo
1300 1613
 	} else if ($popw) {
1301 1614
 	    sleep(5);
1302 1615
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1303
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1616
+	} else {
1617
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1618
+	}
1304 1619
 	print '</div></ul>';
1305 1620
 	print '<div id="error"></div>';
1306 1621
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +607 added lines, -607 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 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
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431 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
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1641,173 +1641,173 @@  discard block
 block discarded – undo
1641 1641
 	}
1642 1642
 
1643 1643
 
1644
-    	public static function check_version($update = false) {
1645
-    	    global $globalDBname;
1646
-    	    $version = 0;
1647
-    	    $Connection = new Connection();
1648
-    	    if ($Connection->tableExists('aircraft')) {
1649
-    		if (!$Connection->tableExists('config')) {
1650
-    		    $version = '1';
1651
-    		    if ($update) return self::update_from_1();
1652
-    		    else return $version;
1644
+		public static function check_version($update = false) {
1645
+			global $globalDBname;
1646
+			$version = 0;
1647
+			$Connection = new Connection();
1648
+			if ($Connection->tableExists('aircraft')) {
1649
+			if (!$Connection->tableExists('config')) {
1650
+				$version = '1';
1651
+				if ($update) return self::update_from_1();
1652
+				else return $version;
1653 1653
 		} else {
1654
-    		    $Connection = new Connection();
1655
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1656
-		    try {
1657
-            		$sth = $Connection->db->prepare($query);
1658
-		        $sth->execute();
1659
-		    } catch(PDOException $e) {
1654
+				$Connection = new Connection();
1655
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1656
+			try {
1657
+					$sth = $Connection->db->prepare($query);
1658
+				$sth->execute();
1659
+			} catch(PDOException $e) {
1660 1660
 			return "error : ".$e->getMessage()."\n";
1661
-    		    }
1662
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1663
-    		    if ($update) {
1664
-    			if ($result['value'] == '2') {
1665
-    			    $error = self::update_from_2();
1666
-    			    if ($error != '') return $error;
1667
-    			    else return self::check_version(true);
1668
-    			} elseif ($result['value'] == '3') {
1669
-    			    $error = self::update_from_3();
1670
-    			    if ($error != '') return $error;
1671
-    			    else return self::check_version(true);
1672
-    			} elseif ($result['value'] == '4') {
1673
-    			    $error = self::update_from_4();
1674
-    			    if ($error != '') return $error;
1675
-    			    else return self::check_version(true);
1676
-    			} elseif ($result['value'] == '5') {
1677
-    			    $error = self::update_from_5();
1678
-    			    if ($error != '') return $error;
1679
-    			    else return self::check_version(true);
1680
-    			} elseif ($result['value'] == '6') {
1681
-    			    $error = self::update_from_6();
1682
-    			    if ($error != '') return $error;
1683
-    			    else return self::check_version(true);
1684
-    			} elseif ($result['value'] == '7') {
1685
-    			    $error = self::update_from_7();
1686
-    			    if ($error != '') return $error;
1687
-    			    else return self::check_version(true);
1688
-    			} elseif ($result['value'] == '8') {
1689
-    			    $error = self::update_from_8();
1690
-    			    if ($error != '') return $error;
1691
-    			    else return self::check_version(true);
1692
-    			} elseif ($result['value'] == '9') {
1693
-    			    $error = self::update_from_9();
1694
-    			    if ($error != '') return $error;
1695
-    			    else return self::check_version(true);
1696
-    			} elseif ($result['value'] == '10') {
1697
-    			    $error = self::update_from_10();
1698
-    			    if ($error != '') return $error;
1699
-    			    else return self::check_version(true);
1700
-    			} elseif ($result['value'] == '11') {
1701
-    			    $error = self::update_from_11();
1702
-    			    if ($error != '') return $error;
1703
-    			    else return self::check_version(true);
1704
-    			} elseif ($result['value'] == '12') {
1705
-    			    $error = self::update_from_12();
1706
-    			    if ($error != '') return $error;
1707
-    			    else return self::check_version(true);
1708
-    			} elseif ($result['value'] == '13') {
1709
-    			    $error = self::update_from_13();
1710
-    			    if ($error != '') return $error;
1711
-    			    else return self::check_version(true);
1712
-    			} elseif ($result['value'] == '14') {
1713
-    			    $error = self::update_from_14();
1714
-    			    if ($error != '') return $error;
1715
-    			    else return self::check_version(true);
1716
-    			} elseif ($result['value'] == '15') {
1717
-    			    $error = self::update_from_15();
1718
-    			    if ($error != '') return $error;
1719
-    			    else return self::check_version(true);
1720
-    			} elseif ($result['value'] == '16') {
1721
-    			    $error = self::update_from_16();
1722
-    			    if ($error != '') return $error;
1723
-    			    else return self::check_version(true);
1724
-    			} elseif ($result['value'] == '17') {
1725
-    			    $error = self::update_from_17();
1726
-    			    if ($error != '') return $error;
1727
-    			    else return self::check_version(true);
1728
-    			} elseif ($result['value'] == '18') {
1729
-    			    $error = self::update_from_18();
1730
-    			    if ($error != '') return $error;
1731
-    			    else return self::check_version(true);
1732
-    			} elseif ($result['value'] == '19') {
1733
-    			    $error = self::update_from_19();
1734
-    			    if ($error != '') return $error;
1735
-    			    else return self::check_version(true);
1736
-    			} elseif ($result['value'] == '20') {
1737
-    			    $error = self::update_from_20();
1738
-    			    if ($error != '') return $error;
1739
-    			    else return self::check_version(true);
1740
-    			} elseif ($result['value'] == '21') {
1741
-    			    $error = self::update_from_21();
1742
-    			    if ($error != '') return $error;
1743
-    			    else return self::check_version(true);
1744
-    			} elseif ($result['value'] == '22') {
1745
-    			    $error = self::update_from_22();
1746
-    			    if ($error != '') return $error;
1747
-    			    else return self::check_version(true);
1748
-    			} elseif ($result['value'] == '23') {
1749
-    			    $error = self::update_from_23();
1750
-    			    if ($error != '') return $error;
1751
-    			    else return self::check_version(true);
1752
-    			} elseif ($result['value'] == '24') {
1753
-    			    $error = self::update_from_24();
1754
-    			    if ($error != '') return $error;
1755
-    			    else return self::check_version(true);
1756
-    			} elseif ($result['value'] == '25') {
1757
-    			    $error = self::update_from_25();
1758
-    			    if ($error != '') return $error;
1759
-    			    else return self::check_version(true);
1760
-    			} elseif ($result['value'] == '26') {
1761
-    			    $error = self::update_from_26();
1762
-    			    if ($error != '') return $error;
1763
-    			    else return self::check_version(true);
1764
-    			} elseif ($result['value'] == '27') {
1765
-    			    $error = self::update_from_27();
1766
-    			    if ($error != '') return $error;
1767
-    			    else return self::check_version(true);
1768
-    			} elseif ($result['value'] == '28') {
1769
-    			    $error = self::update_from_28();
1770
-    			    if ($error != '') return $error;
1771
-    			    else return self::check_version(true);
1772
-    			} elseif ($result['value'] == '29') {
1773
-    			    $error = self::update_from_29();
1774
-    			    if ($error != '') return $error;
1775
-    			    else return self::check_version(true);
1776
-    			} elseif ($result['value'] == '30') {
1777
-    			    $error = self::update_from_30();
1778
-    			    if ($error != '') return $error;
1779
-    			    else return self::check_version(true);
1780
-    			} elseif ($result['value'] == '31') {
1781
-    			    $error = self::update_from_31();
1782
-    			    if ($error != '') return $error;
1783
-    			    else return self::check_version(true);
1784
-    			} elseif ($result['value'] == '32') {
1785
-    			    $error = self::update_from_32();
1786
-    			    if ($error != '') return $error;
1787
-    			    else return self::check_version(true);
1788
-    			} elseif ($result['value'] == '33') {
1789
-    			    $error = self::update_from_33();
1790
-    			    if ($error != '') return $error;
1791
-    			    else return self::check_version(true);
1792
-    			} elseif ($result['value'] == '34') {
1793
-    			    $error = self::update_from_34();
1794
-    			    if ($error != '') return $error;
1795
-    			    else return self::check_version(true);
1796
-    			} elseif ($result['value'] == '35') {
1797
-    			    $error = self::update_from_35();
1798
-    			    if ($error != '') return $error;
1799
-    			    else return self::check_version(true);
1800
-    			} elseif ($result['value'] == '36') {
1801
-    			    $error = self::update_from_36();
1802
-    			    if ($error != '') return $error;
1803
-    			    else return self::check_version(true);
1804
-    			} else return '';
1805
-    		    }
1806
-    		    else return $result['value'];
1661
+				}
1662
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1663
+				if ($update) {
1664
+				if ($result['value'] == '2') {
1665
+					$error = self::update_from_2();
1666
+					if ($error != '') return $error;
1667
+					else return self::check_version(true);
1668
+				} elseif ($result['value'] == '3') {
1669
+					$error = self::update_from_3();
1670
+					if ($error != '') return $error;
1671
+					else return self::check_version(true);
1672
+				} elseif ($result['value'] == '4') {
1673
+					$error = self::update_from_4();
1674
+					if ($error != '') return $error;
1675
+					else return self::check_version(true);
1676
+				} elseif ($result['value'] == '5') {
1677
+					$error = self::update_from_5();
1678
+					if ($error != '') return $error;
1679
+					else return self::check_version(true);
1680
+				} elseif ($result['value'] == '6') {
1681
+					$error = self::update_from_6();
1682
+					if ($error != '') return $error;
1683
+					else return self::check_version(true);
1684
+				} elseif ($result['value'] == '7') {
1685
+					$error = self::update_from_7();
1686
+					if ($error != '') return $error;
1687
+					else return self::check_version(true);
1688
+				} elseif ($result['value'] == '8') {
1689
+					$error = self::update_from_8();
1690
+					if ($error != '') return $error;
1691
+					else return self::check_version(true);
1692
+				} elseif ($result['value'] == '9') {
1693
+					$error = self::update_from_9();
1694
+					if ($error != '') return $error;
1695
+					else return self::check_version(true);
1696
+				} elseif ($result['value'] == '10') {
1697
+					$error = self::update_from_10();
1698
+					if ($error != '') return $error;
1699
+					else return self::check_version(true);
1700
+				} elseif ($result['value'] == '11') {
1701
+					$error = self::update_from_11();
1702
+					if ($error != '') return $error;
1703
+					else return self::check_version(true);
1704
+				} elseif ($result['value'] == '12') {
1705
+					$error = self::update_from_12();
1706
+					if ($error != '') return $error;
1707
+					else return self::check_version(true);
1708
+				} elseif ($result['value'] == '13') {
1709
+					$error = self::update_from_13();
1710
+					if ($error != '') return $error;
1711
+					else return self::check_version(true);
1712
+				} elseif ($result['value'] == '14') {
1713
+					$error = self::update_from_14();
1714
+					if ($error != '') return $error;
1715
+					else return self::check_version(true);
1716
+				} elseif ($result['value'] == '15') {
1717
+					$error = self::update_from_15();
1718
+					if ($error != '') return $error;
1719
+					else return self::check_version(true);
1720
+				} elseif ($result['value'] == '16') {
1721
+					$error = self::update_from_16();
1722
+					if ($error != '') return $error;
1723
+					else return self::check_version(true);
1724
+				} elseif ($result['value'] == '17') {
1725
+					$error = self::update_from_17();
1726
+					if ($error != '') return $error;
1727
+					else return self::check_version(true);
1728
+				} elseif ($result['value'] == '18') {
1729
+					$error = self::update_from_18();
1730
+					if ($error != '') return $error;
1731
+					else return self::check_version(true);
1732
+				} elseif ($result['value'] == '19') {
1733
+					$error = self::update_from_19();
1734
+					if ($error != '') return $error;
1735
+					else return self::check_version(true);
1736
+				} elseif ($result['value'] == '20') {
1737
+					$error = self::update_from_20();
1738
+					if ($error != '') return $error;
1739
+					else return self::check_version(true);
1740
+				} elseif ($result['value'] == '21') {
1741
+					$error = self::update_from_21();
1742
+					if ($error != '') return $error;
1743
+					else return self::check_version(true);
1744
+				} elseif ($result['value'] == '22') {
1745
+					$error = self::update_from_22();
1746
+					if ($error != '') return $error;
1747
+					else return self::check_version(true);
1748
+				} elseif ($result['value'] == '23') {
1749
+					$error = self::update_from_23();
1750
+					if ($error != '') return $error;
1751
+					else return self::check_version(true);
1752
+				} elseif ($result['value'] == '24') {
1753
+					$error = self::update_from_24();
1754
+					if ($error != '') return $error;
1755
+					else return self::check_version(true);
1756
+				} elseif ($result['value'] == '25') {
1757
+					$error = self::update_from_25();
1758
+					if ($error != '') return $error;
1759
+					else return self::check_version(true);
1760
+				} elseif ($result['value'] == '26') {
1761
+					$error = self::update_from_26();
1762
+					if ($error != '') return $error;
1763
+					else return self::check_version(true);
1764
+				} elseif ($result['value'] == '27') {
1765
+					$error = self::update_from_27();
1766
+					if ($error != '') return $error;
1767
+					else return self::check_version(true);
1768
+				} elseif ($result['value'] == '28') {
1769
+					$error = self::update_from_28();
1770
+					if ($error != '') return $error;
1771
+					else return self::check_version(true);
1772
+				} elseif ($result['value'] == '29') {
1773
+					$error = self::update_from_29();
1774
+					if ($error != '') return $error;
1775
+					else return self::check_version(true);
1776
+				} elseif ($result['value'] == '30') {
1777
+					$error = self::update_from_30();
1778
+					if ($error != '') return $error;
1779
+					else return self::check_version(true);
1780
+				} elseif ($result['value'] == '31') {
1781
+					$error = self::update_from_31();
1782
+					if ($error != '') return $error;
1783
+					else return self::check_version(true);
1784
+				} elseif ($result['value'] == '32') {
1785
+					$error = self::update_from_32();
1786
+					if ($error != '') return $error;
1787
+					else return self::check_version(true);
1788
+				} elseif ($result['value'] == '33') {
1789
+					$error = self::update_from_33();
1790
+					if ($error != '') return $error;
1791
+					else return self::check_version(true);
1792
+				} elseif ($result['value'] == '34') {
1793
+					$error = self::update_from_34();
1794
+					if ($error != '') return $error;
1795
+					else return self::check_version(true);
1796
+				} elseif ($result['value'] == '35') {
1797
+					$error = self::update_from_35();
1798
+					if ($error != '') return $error;
1799
+					else return self::check_version(true);
1800
+				} elseif ($result['value'] == '36') {
1801
+					$error = self::update_from_36();
1802
+					if ($error != '') return $error;
1803
+					else return self::check_version(true);
1804
+				} else return '';
1805
+				}
1806
+				else return $result['value'];
1807 1807
 		}
1808 1808
 		
1809
-	    } else return $version;
1810
-    	}
1809
+		} else return $version;
1810
+		}
1811 1811
     	
1812 1812
 }
1813 1813
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 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
 		}
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 			try {
1592 1592
 				$sth = $Connection->db->prepare($query);
1593 1593
 				$sth->execute();
1594
-			} catch(PDOException $e) {
1594
+			} catch (PDOException $e) {
1595 1595
 				return "error (change ModeS column in spotter_* to NULL) : ".$e->getMessage()."\n";
1596 1596
 			}
1597 1597
 		} else {
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
 			try {
1600 1600
 				$sth = $Connection->db->prepare($query);
1601 1601
 				$sth->execute();
1602
-			} catch(PDOException $e) {
1602
+			} catch (PDOException $e) {
1603 1603
 				return "error (change ModeS column in spotter_* to NULL) : ".$e->getMessage()."\n";
1604 1604
 			}
1605 1605
 		}
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 		try {
1635 1635
 			$sth = $Connection->db->prepare($query);
1636 1636
 			$sth->execute();
1637
-		} catch(PDOException $e) {
1637
+		} catch (PDOException $e) {
1638 1638
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1639 1639
 		}
1640 1640
 		return $error;
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 		    try {
1657 1657
             		$sth = $Connection->db->prepare($query);
1658 1658
 		        $sth->execute();
1659
-		    } catch(PDOException $e) {
1659
+		    } catch (PDOException $e) {
1660 1660
 			return "error : ".$e->getMessage()."\n";
1661 1661
     		    }
1662 1662
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +323 added lines, -120 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1605,30 +1671,54 @@  discard block
 block discarded – undo
1605 1671
 		}
1606 1672
 		if ($globalDBdriver == 'mysql') {
1607 1673
 			$error .= create_db::import_file('../db/tracker_output.sql');
1608
-			if ($error != '') return $error;
1674
+			if ($error != '') {
1675
+				return $error;
1676
+			}
1609 1677
 			$error .= create_db::import_file('../db/tracker_live.sql');
1610
-			if ($error != '') return $error;
1678
+			if ($error != '') {
1679
+				return $error;
1680
+			}
1611 1681
 			$error .= create_db::import_file('../db/marine_output.sql');
1612
-			if ($error != '') return $error;
1682
+			if ($error != '') {
1683
+				return $error;
1684
+			}
1613 1685
 			$error .= create_db::import_file('../db/marine_live.sql');
1614
-			if ($error != '') return $error;
1686
+			if ($error != '') {
1687
+				return $error;
1688
+			}
1615 1689
 			$error .= create_db::import_file('../db/marine_identity.sql');
1616
-			if ($error != '') return $error;
1690
+			if ($error != '') {
1691
+				return $error;
1692
+			}
1617 1693
 			$error .= create_db::import_file('../db/marine_mid.sql');
1618
-			if ($error != '') return $error;
1694
+			if ($error != '') {
1695
+				return $error;
1696
+			}
1619 1697
 		} else {
1620 1698
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1621
-			if ($error != '') return $error;
1699
+			if ($error != '') {
1700
+				return $error;
1701
+			}
1622 1702
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1623
-			if ($error != '') return $error;
1703
+			if ($error != '') {
1704
+				return $error;
1705
+			}
1624 1706
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1625
-			if ($error != '') return $error;
1707
+			if ($error != '') {
1708
+				return $error;
1709
+			}
1626 1710
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1627
-			if ($error != '') return $error;
1711
+			if ($error != '') {
1712
+				return $error;
1713
+			}
1628 1714
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1629
-			if ($error != '') return $error;
1715
+			if ($error != '') {
1716
+				return $error;
1717
+			}
1630 1718
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1631
-			if ($error != '') return $error;
1719
+			if ($error != '') {
1720
+				return $error;
1721
+			}
1632 1722
 		}
1633 1723
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1634 1724
 		try {
@@ -1648,8 +1738,11 @@  discard block
 block discarded – undo
1648 1738
     	    if ($Connection->tableExists('aircraft')) {
1649 1739
     		if (!$Connection->tableExists('config')) {
1650 1740
     		    $version = '1';
1651
-    		    if ($update) return self::update_from_1();
1652
-    		    else return $version;
1741
+    		    if ($update) {
1742
+    		    	return self::update_from_1();
1743
+    		    } else {
1744
+    		    	return $version;
1745
+    		    }
1653 1746
 		} else {
1654 1747
     		    $Connection = new Connection();
1655 1748
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1663,150 +1756,260 @@  discard block
 block discarded – undo
1663 1756
     		    if ($update) {
1664 1757
     			if ($result['value'] == '2') {
1665 1758
     			    $error = self::update_from_2();
1666
-    			    if ($error != '') return $error;
1667
-    			    else return self::check_version(true);
1759
+    			    if ($error != '') {
1760
+    			    	return $error;
1761
+    			    } else {
1762
+    			    	return self::check_version(true);
1763
+    			    }
1668 1764
     			} elseif ($result['value'] == '3') {
1669 1765
     			    $error = self::update_from_3();
1670
-    			    if ($error != '') return $error;
1671
-    			    else return self::check_version(true);
1766
+    			    if ($error != '') {
1767
+    			    	return $error;
1768
+    			    } else {
1769
+    			    	return self::check_version(true);
1770
+    			    }
1672 1771
     			} elseif ($result['value'] == '4') {
1673 1772
     			    $error = self::update_from_4();
1674
-    			    if ($error != '') return $error;
1675
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1676 1778
     			} elseif ($result['value'] == '5') {
1677 1779
     			    $error = self::update_from_5();
1678
-    			    if ($error != '') return $error;
1679
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1680 1785
     			} elseif ($result['value'] == '6') {
1681 1786
     			    $error = self::update_from_6();
1682
-    			    if ($error != '') return $error;
1683
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1684 1792
     			} elseif ($result['value'] == '7') {
1685 1793
     			    $error = self::update_from_7();
1686
-    			    if ($error != '') return $error;
1687
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1688 1799
     			} elseif ($result['value'] == '8') {
1689 1800
     			    $error = self::update_from_8();
1690
-    			    if ($error != '') return $error;
1691
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1692 1806
     			} elseif ($result['value'] == '9') {
1693 1807
     			    $error = self::update_from_9();
1694
-    			    if ($error != '') return $error;
1695
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1696 1813
     			} elseif ($result['value'] == '10') {
1697 1814
     			    $error = self::update_from_10();
1698
-    			    if ($error != '') return $error;
1699
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1700 1820
     			} elseif ($result['value'] == '11') {
1701 1821
     			    $error = self::update_from_11();
1702
-    			    if ($error != '') return $error;
1703
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1704 1827
     			} elseif ($result['value'] == '12') {
1705 1828
     			    $error = self::update_from_12();
1706
-    			    if ($error != '') return $error;
1707
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1708 1834
     			} elseif ($result['value'] == '13') {
1709 1835
     			    $error = self::update_from_13();
1710
-    			    if ($error != '') return $error;
1711
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1712 1841
     			} elseif ($result['value'] == '14') {
1713 1842
     			    $error = self::update_from_14();
1714
-    			    if ($error != '') return $error;
1715
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1716 1848
     			} elseif ($result['value'] == '15') {
1717 1849
     			    $error = self::update_from_15();
1718
-    			    if ($error != '') return $error;
1719
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1720 1855
     			} elseif ($result['value'] == '16') {
1721 1856
     			    $error = self::update_from_16();
1722
-    			    if ($error != '') return $error;
1723
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1724 1862
     			} elseif ($result['value'] == '17') {
1725 1863
     			    $error = self::update_from_17();
1726
-    			    if ($error != '') return $error;
1727
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1728 1869
     			} elseif ($result['value'] == '18') {
1729 1870
     			    $error = self::update_from_18();
1730
-    			    if ($error != '') return $error;
1731
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1732 1876
     			} elseif ($result['value'] == '19') {
1733 1877
     			    $error = self::update_from_19();
1734
-    			    if ($error != '') return $error;
1735
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1736 1883
     			} elseif ($result['value'] == '20') {
1737 1884
     			    $error = self::update_from_20();
1738
-    			    if ($error != '') return $error;
1739
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1740 1890
     			} elseif ($result['value'] == '21') {
1741 1891
     			    $error = self::update_from_21();
1742
-    			    if ($error != '') return $error;
1743
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1744 1897
     			} elseif ($result['value'] == '22') {
1745 1898
     			    $error = self::update_from_22();
1746
-    			    if ($error != '') return $error;
1747
-    			    else return self::check_version(true);
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1748 1904
     			} elseif ($result['value'] == '23') {
1749 1905
     			    $error = self::update_from_23();
1750
-    			    if ($error != '') return $error;
1751
-    			    else return self::check_version(true);
1906
+    			    if ($error != '') {
1907
+    			    	return $error;
1908
+    			    } else {
1909
+    			    	return self::check_version(true);
1910
+    			    }
1752 1911
     			} elseif ($result['value'] == '24') {
1753 1912
     			    $error = self::update_from_24();
1754
-    			    if ($error != '') return $error;
1755
-    			    else return self::check_version(true);
1913
+    			    if ($error != '') {
1914
+    			    	return $error;
1915
+    			    } else {
1916
+    			    	return self::check_version(true);
1917
+    			    }
1756 1918
     			} elseif ($result['value'] == '25') {
1757 1919
     			    $error = self::update_from_25();
1758
-    			    if ($error != '') return $error;
1759
-    			    else return self::check_version(true);
1920
+    			    if ($error != '') {
1921
+    			    	return $error;
1922
+    			    } else {
1923
+    			    	return self::check_version(true);
1924
+    			    }
1760 1925
     			} elseif ($result['value'] == '26') {
1761 1926
     			    $error = self::update_from_26();
1762
-    			    if ($error != '') return $error;
1763
-    			    else return self::check_version(true);
1927
+    			    if ($error != '') {
1928
+    			    	return $error;
1929
+    			    } else {
1930
+    			    	return self::check_version(true);
1931
+    			    }
1764 1932
     			} elseif ($result['value'] == '27') {
1765 1933
     			    $error = self::update_from_27();
1766
-    			    if ($error != '') return $error;
1767
-    			    else return self::check_version(true);
1934
+    			    if ($error != '') {
1935
+    			    	return $error;
1936
+    			    } else {
1937
+    			    	return self::check_version(true);
1938
+    			    }
1768 1939
     			} elseif ($result['value'] == '28') {
1769 1940
     			    $error = self::update_from_28();
1770
-    			    if ($error != '') return $error;
1771
-    			    else return self::check_version(true);
1941
+    			    if ($error != '') {
1942
+    			    	return $error;
1943
+    			    } else {
1944
+    			    	return self::check_version(true);
1945
+    			    }
1772 1946
     			} elseif ($result['value'] == '29') {
1773 1947
     			    $error = self::update_from_29();
1774
-    			    if ($error != '') return $error;
1775
-    			    else return self::check_version(true);
1948
+    			    if ($error != '') {
1949
+    			    	return $error;
1950
+    			    } else {
1951
+    			    	return self::check_version(true);
1952
+    			    }
1776 1953
     			} elseif ($result['value'] == '30') {
1777 1954
     			    $error = self::update_from_30();
1778
-    			    if ($error != '') return $error;
1779
-    			    else return self::check_version(true);
1955
+    			    if ($error != '') {
1956
+    			    	return $error;
1957
+    			    } else {
1958
+    			    	return self::check_version(true);
1959
+    			    }
1780 1960
     			} elseif ($result['value'] == '31') {
1781 1961
     			    $error = self::update_from_31();
1782
-    			    if ($error != '') return $error;
1783
-    			    else return self::check_version(true);
1962
+    			    if ($error != '') {
1963
+    			    	return $error;
1964
+    			    } else {
1965
+    			    	return self::check_version(true);
1966
+    			    }
1784 1967
     			} elseif ($result['value'] == '32') {
1785 1968
     			    $error = self::update_from_32();
1786
-    			    if ($error != '') return $error;
1787
-    			    else return self::check_version(true);
1969
+    			    if ($error != '') {
1970
+    			    	return $error;
1971
+    			    } else {
1972
+    			    	return self::check_version(true);
1973
+    			    }
1788 1974
     			} elseif ($result['value'] == '33') {
1789 1975
     			    $error = self::update_from_33();
1790
-    			    if ($error != '') return $error;
1791
-    			    else return self::check_version(true);
1976
+    			    if ($error != '') {
1977
+    			    	return $error;
1978
+    			    } else {
1979
+    			    	return self::check_version(true);
1980
+    			    }
1792 1981
     			} elseif ($result['value'] == '34') {
1793 1982
     			    $error = self::update_from_34();
1794
-    			    if ($error != '') return $error;
1795
-    			    else return self::check_version(true);
1983
+    			    if ($error != '') {
1984
+    			    	return $error;
1985
+    			    } else {
1986
+    			    	return self::check_version(true);
1987
+    			    }
1796 1988
     			} elseif ($result['value'] == '35') {
1797 1989
     			    $error = self::update_from_35();
1798
-    			    if ($error != '') return $error;
1799
-    			    else return self::check_version(true);
1990
+    			    if ($error != '') {
1991
+    			    	return $error;
1992
+    			    } else {
1993
+    			    	return self::check_version(true);
1994
+    			    }
1800 1995
     			} elseif ($result['value'] == '36') {
1801 1996
     			    $error = self::update_from_36();
1802
-    			    if ($error != '') return $error;
1803
-    			    else return self::check_version(true);
1804
-    			} else return '';
1997
+    			    if ($error != '') {
1998
+    			    	return $error;
1999
+    			    } else {
2000
+    			    	return self::check_version(true);
2001
+    			    }
2002
+    			} else {
2003
+    				return '';
2004
+    			}
2005
+    		    } else {
2006
+    		    	return $result['value'];
1805 2007
     		    }
1806
-    		    else return $result['value'];
1807 2008
 		}
1808 2009
 		
1809
-	    } else return $version;
2010
+	    } else {
2011
+	    	return $version;
2012
+	    }
1810 2013
     	}
1811 2014
     	
1812 2015
 }
Please login to merge, or discard this patch.
marine-data.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime);
16
+		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime);
17 17
 		/*
18 18
 		if (empty($spotter_array)) {
19 19
 			$from_archive = true;
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 }
33 33
 if (isset($_GET['fammarine_id'])) {
34
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
34
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
35 35
 	if (isset($_GET['currenttime'])) {
36
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
36
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
37 37
 		$currenttime = round($currenttime/1000);
38
-		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime);
38
+		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime);
39 39
 		/*
40 40
 		if (empty($spotter_array)) {
41 41
 			$from_archive = true;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
65
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
66 66
 	} else $image = $spotter_item['image_thumbnail'];
67 67
 
68 68
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
require/class.APRS.php 2 patches
Spacing   +64 added lines, -65 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 
87 87
     private function urshift($n, $s) {
88
-	return ($n >= 0) ? ($n >> $s) :
89
-	    (($n & 0x7fffffff) >> $s) | 
88
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
90 89
 		(0x40000000 >> ($s - 1));
91 90
     }
92 91
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	//$split_input = str_split($input);
99 98
 
100 99
 	/* Find the end of header checking for NULL bytes while doing it. */
101
-	$splitpos = strpos($input,':');
100
+	$splitpos = strpos($input, ':');
102 101
 	
103 102
 	/* Check that end was found and body has at least one byte. */
104 103
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -108,28 +107,28 @@  discard block
 block discarded – undo
108 107
 	
109 108
 	if ($debug) echo 'input : '.$input."\n";
110 109
 	/* Save header and body. */
111
-	$body = substr($input,$splitpos+1,$input_len);
110
+	$body = substr($input, $splitpos + 1, $input_len);
112 111
 	$body_len = strlen($body);
113
-	$header = substr($input,0,$splitpos);
112
+	$header = substr($input, 0, $splitpos);
114 113
 	//$header_len = strlen($header);
115 114
 	if ($debug) echo 'header : '.$header."\n";
116 115
 	
117 116
 	/* Parse source, target and path. */
118 117
 	//FLRDF0A52>APRS,qAS,LSTB
119
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
118
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
120 119
 	    $ident = $matches[1];
121 120
 	    $all_elements = $matches[2];
122 121
 	    if ($debug) echo 'ident : '.$ident."\n";
123 122
 	    $result['ident'] = $ident;
124 123
 	} else return false;
125
-	$elements = explode(',',$all_elements);
124
+	$elements = explode(',', $all_elements);
126 125
 	$source = end($elements);
127 126
 	$result['source'] = $source;
128 127
 	foreach ($elements as $element) {
129
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
128
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
130 129
 	        //echo "ok";
131 130
 	        //if ($element == 'TCPIP*') return false;
132
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
131
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
133 132
 		if ($debug) echo 'element : '.$element."\n";
134 133
 		return false;
135 134
 	    }
@@ -142,10 +141,10 @@  discard block
 block discarded – undo
142 141
 	    */
143 142
 	}
144 143
 	
145
-	$type = substr($body,0,1);
144
+	$type = substr($body, 0, 1);
146 145
 	if ($debug) echo 'type : '.$type."\n";
147 146
 	if ($type == ';') {
148
-		$result['ident'] = trim(substr($body,1,9));
147
+		$result['ident'] = trim(substr($body, 1, 9));
149 148
 	} elseif ($type == ',') {
150 149
 		// Invalid data or test data
151 150
 		return false;
@@ -153,24 +152,24 @@  discard block
 block discarded – undo
153 152
 	
154 153
 	// Check for Timestamp
155 154
 	$find = false;
156
-	$body_parse = substr($body,1);
155
+	$body_parse = substr($body, 1);
157 156
 	//echo 'Body : '.$body."\n";
158
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
159
-	    $body_parse = substr($body_parse,10);
157
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
158
+	    $body_parse = substr($body_parse, 10);
160 159
 	    $find = true;
161 160
 	    //echo $body_parse."\n";
162 161
 	}
163
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
164
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
162
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
163
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
165 164
 	    $find = true;
166 165
 	    //echo $body_parse."\n";
167 166
 	}
168
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
169
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
167
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
168
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
170 169
 	    $find = true;
171 170
 	    //echo $body_parse."\n";
172 171
 	}
173
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
172
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
174 173
 	    $find = true;
175 174
 	    //print_r($matches);
176 175
 	    $timestamp = $matches[0];
@@ -185,19 +184,19 @@  discard block
 block discarded – undo
185 184
 		// This work or not ?
186 185
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
187 186
 	    }
188
-	    $body_parse = substr($body_parse,7);
187
+	    $body_parse = substr($body_parse, 7);
189 188
 	    $result['timestamp'] = $timestamp;
190 189
 	    //echo date('Ymd H:i:s',$timestamp);
191 190
 	}
192
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
191
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
193 192
 	    $find = true;
194 193
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
195
-	    $body_parse = substr($body_parse,8);
194
+	    $body_parse = substr($body_parse, 8);
196 195
 	    $result['timestamp'] = $timestamp;
197 196
 	    //echo date('Ymd H:i:s',$timestamp);
198 197
 	}
199 198
 	//if (strlen($body_parse) > 19) {
200
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
199
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
201 200
 	    $find = true;
202 201
 		// 4658.70N/00707.78Ez
203 202
 		//print_r(str_split($body_parse));
@@ -223,11 +222,11 @@  discard block
 block discarded – undo
223 222
 	    */
224 223
 		$latitude = $lat + floatval($lat_min)/60;
225 224
 		$longitude = $lon + floatval($lon_min)/60;
226
-		if ($sind == 'S') $latitude = 0-$latitude;
227
-		if ($wind == 'W') $longitude = 0-$longitude;
225
+		if ($sind == 'S') $latitude = 0 - $latitude;
226
+		if ($wind == 'W') $longitude = 0 - $longitude;
228 227
 		$result['latitude'] = $latitude;
229 228
 		$result['longitude'] = $longitude;
230
-		$body_parse = substr($body_parse,18);
229
+		$body_parse = substr($body_parse, 18);
231 230
 		$body_parse_len = strlen($body_parse);
232 231
 	    }
233 232
 	    $body_parse_len = strlen($body_parse);
@@ -254,7 +253,7 @@  discard block
 block discarded – undo
254 253
 		//}
255 254
 		//echo $body_parse;
256 255
 			if ($type != ';' && $type != '>') {
257
-			$body_parse = substr($body_parse,1);
256
+			$body_parse = substr($body_parse, 1);
258 257
 			$body_parse_len = strlen($body_parse);
259 258
 			$result['symbol_code'] = $symbol_code;
260 259
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -265,15 +264,15 @@  discard block
 block discarded – undo
265 264
 		    //$body_parse_len = strlen($body_parse);
266 265
 		    if ($body_parse_len >= 7) {
267 266
 			
268
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
269
-		    	    $course = substr($body_parse,0,3);
267
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
268
+		    	    $course = substr($body_parse, 0, 3);
270 269
 		    	    $tmp_s = intval($course);
271 270
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
272
-		    	    $speed = substr($body_parse,4,3);
271
+		    	    $speed = substr($body_parse, 4, 3);
273 272
 		    	    if ($speed != '...') {
274 273
 		    		    $result['speed'] = round($speed*1.852);
275 274
 		    	    }
276
-		    	    $body_parse = substr($body_parse,7);
275
+		    	    $body_parse = substr($body_parse, 7);
277 276
 		        }
278 277
 		        // Check PHGR, PHG, RNG
279 278
 		    } 
@@ -283,12 +282,12 @@  discard block
 block discarded – undo
283 282
 		    }
284 283
 		    */
285 284
 		    if (strlen($body_parse) > 0) {
286
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
285
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
287 286
 		            $altitude = intval($matches[1]);
288 287
 		            //$result['altitude'] = round($altitude*0.3048);
289 288
 		            $result['altitude'] = $altitude;
290 289
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
291
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
290
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
292 291
 		        }
293 292
 		    }
294 293
 		    
@@ -299,35 +298,35 @@  discard block
 block discarded – undo
299 298
 		    }
300 299
 		    */
301 300
 		    // DAO
302
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
301
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
303 302
 			    $dao = $matches[1];
304
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
303
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
305 304
 				$dao_split = str_split($dao);
306
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
307
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
305
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
306
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
308 307
 			    
309 308
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
310 309
 				else $result['latitude'] += $lat_off;
311 310
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
312 311
 				else $result['longitude'] += $lon_off;
313 312
 			    }
314
-		            $body_parse = substr($body_parse,6);
313
+		            $body_parse = substr($body_parse, 6);
315 314
 		    }
316 315
 		    
317 316
 		    // OGN comment
318 317
 		   // echo "Before OGN : ".$body_parse."\n";
319 318
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
320
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
319
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
321 320
 			$id = $matches[1];
322 321
 			//$mode = substr($id,0,2);
323
-			$address = substr($id,2);
322
+			$address = substr($id, 2);
324 323
 			//print_r($matches);
325
-			$addressType = (intval(substr($id,0,2),16))&3;
324
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
326 325
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
327 326
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
328 327
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
329 328
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
330
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
329
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
331 330
 			$result['aircrafttype_code'] = $aircraftType;
332 331
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
333 332
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -344,7 +343,7 @@  discard block
 block discarded – undo
344 343
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
345 344
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
346 345
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
347
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
346
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
348 347
 			$result['stealth'] = $stealth;
349 348
 			$result['address'] = $address;
350 349
 		    }
@@ -356,39 +355,39 @@  discard block
 block discarded – undo
356 355
 		    //$body_parse = substr($body_parse,1);
357 356
 		    //$body_parse_len = strlen($body_parse);
358 357
 
359
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
358
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
360 359
 			    $result['wind_dir'] = intval($matches[1]);
361
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
362
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
363
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
364
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
365
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
360
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
361
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
362
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
363
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
364
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
366 365
 			$result['wind_dir'] = intval($matches[1]);
367
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
368
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
369
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
370
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
371
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
366
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
367
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
368
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
369
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
370
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
372 371
 			$result['wind_dir'] = intval($matches[1]);
373
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
374
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
375
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
376
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
372
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
373
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
374
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
375
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
377 376
 			$result['wind_dir'] = intval($matches[1]);
378
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
379
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
380
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
377
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
378
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
379
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
381 380
 		    }
382
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
383
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
381
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
382
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
384 383
 		    }
385 384
 		}
386 385
 		} else $result['comment'] = trim($body_parse);
387 386
 
388 387
 	    }
389 388
 	//}
390
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
391
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
389
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
390
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
392 391
 	if ($debug) print_r($result);
393 392
 	return $result;
394 393
     }
Please login to merge, or discard this patch.
Braces   +98 added lines, -39 removed lines patch added patch discarded remove patch
@@ -102,26 +102,36 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
109
-	if ($debug) echo 'input : '.$input."\n";
111
+	if ($debug) {
112
+		echo 'input : '.$input."\n";
113
+	}
110 114
 	/* Save header and body. */
111 115
 	$body = substr($input,$splitpos+1,$input_len);
112 116
 	$body_len = strlen($body);
113 117
 	$header = substr($input,0,$splitpos);
114 118
 	//$header_len = strlen($header);
115
-	if ($debug) echo 'header : '.$header."\n";
119
+	if ($debug) {
120
+		echo 'header : '.$header."\n";
121
+	}
116 122
 	
117 123
 	/* Parse source, target and path. */
118 124
 	//FLRDF0A52>APRS,qAS,LSTB
119 125
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
120 126
 	    $ident = $matches[1];
121 127
 	    $all_elements = $matches[2];
122
-	    if ($debug) echo 'ident : '.$ident."\n";
128
+	    if ($debug) {
129
+	    	echo 'ident : '.$ident."\n";
130
+	    }
123 131
 	    $result['ident'] = $ident;
124
-	} else return false;
132
+	} else {
133
+		return false;
134
+	}
125 135
 	$elements = explode(',',$all_elements);
126 136
 	$source = end($elements);
127 137
 	$result['source'] = $source;
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 	        //echo "ok";
131 141
 	        //if ($element == 'TCPIP*') return false;
132 142
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
133
-		if ($debug) echo 'element : '.$element."\n";
143
+		if ($debug) {
144
+			echo 'element : '.$element."\n";
145
+		}
134 146
 		return false;
135 147
 	    }
136 148
 	    /*
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 	
145 157
 	$type = substr($body,0,1);
146
-	if ($debug) echo 'type : '.$type."\n";
158
+	if ($debug) {
159
+		echo 'type : '.$type."\n";
160
+	}
147 161
 	if ($type == ';') {
148 162
 		$result['ident'] = trim(substr($body,1,9));
149 163
 	} elseif ($type == ',') {
@@ -213,7 +227,9 @@  discard block
 block discarded – undo
213 227
 		//$symbol_table = $matches[4];
214 228
 		$lat = intval($lat_deg);
215 229
 		$lon = intval($lon_deg);
216
-		if ($lat > 89 || $lon > 179) return false;
230
+		if ($lat > 89 || $lon > 179) {
231
+			return false;
232
+		}
217 233
 	    
218 234
 	    /*
219 235
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -223,8 +239,12 @@  discard block
 block discarded – undo
223 239
 	    */
224 240
 		$latitude = $lat + floatval($lat_min)/60;
225 241
 		$longitude = $lon + floatval($lon_min)/60;
226
-		if ($sind == 'S') $latitude = 0-$latitude;
227
-		if ($wind == 'W') $longitude = 0-$longitude;
242
+		if ($sind == 'S') {
243
+			$latitude = 0-$latitude;
244
+		}
245
+		if ($wind == 'W') {
246
+			$longitude = 0-$longitude;
247
+		}
228 248
 		$result['latitude'] = $latitude;
229 249
 		$result['longitude'] = $longitude;
230 250
 		$body_parse = substr($body_parse,18);
@@ -257,7 +277,9 @@  discard block
 block discarded – undo
257 277
 			$body_parse = substr($body_parse,1);
258 278
 			$body_parse_len = strlen($body_parse);
259 279
 			$result['symbol_code'] = $symbol_code;
260
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
280
+			if (isset($this->symbols[$symbol_code])) {
281
+				$result['symbol'] = $this->symbols[$symbol_code];
282
+			}
261 283
 			if ($symbol_code != '_') {
262 284
 			}
263 285
 		    //$body_parse = substr($body_parse,1);
@@ -268,7 +290,9 @@  discard block
 block discarded – undo
268 290
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
269 291
 		    	    $course = substr($body_parse,0,3);
270 292
 		    	    $tmp_s = intval($course);
271
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
293
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
294
+		    	    	$result['heading'] = intval($course);
295
+		    	    }
272 296
 		    	    $speed = substr($body_parse,4,3);
273 297
 		    	    if ($speed != '...') {
274 298
 		    		    $result['speed'] = round($speed*1.852);
@@ -306,10 +330,16 @@  discard block
 block discarded – undo
306 330
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
307 331
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
308 332
 			    
309
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
310
-				else $result['latitude'] += $lat_off;
311
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
312
-				else $result['longitude'] += $lon_off;
333
+				if ($result['latitude'] < 0) {
334
+					$result['latitude'] -= $lat_off;
335
+				} else {
336
+					$result['latitude'] += $lat_off;
337
+				}
338
+				if ($result['longitude'] < 0) {
339
+					$result['longitude'] -= $lon_off;
340
+				} else {
341
+					$result['longitude'] += $lon_off;
342
+				}
313 343
 			    }
314 344
 		            $body_parse = substr($body_parse,6);
315 345
 		    }
@@ -323,27 +353,48 @@  discard block
 block discarded – undo
323 353
 			$address = substr($id,2);
324 354
 			//print_r($matches);
325 355
 			$addressType = (intval(substr($id,0,2),16))&3;
326
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
327
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
328
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
329
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
356
+			if ($addressType == 0) {
357
+				$result['addresstype'] = "RANDOM";
358
+			} elseif ($addressType == 1) {
359
+				$result['addresstype'] = "ICAO";
360
+			} elseif ($addressType == 2) {
361
+				$result['addresstype'] = "FLARM";
362
+			} elseif ($addressType == 3) {
363
+				$result['addresstype'] = "OGN";
364
+			}
330 365
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
331 366
 			$result['aircrafttype_code'] = $aircraftType;
332
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
333
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
334
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
335
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
336
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
337
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
338
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
339
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
340
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
341
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
342
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
343
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
344
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
345
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
346
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
367
+			if ($aircraftType == 0) {
368
+				$result['aircrafttype'] = "UNKNOWN";
369
+			} elseif ($aircraftType == 1) {
370
+				$result['aircrafttype'] = "GLIDER";
371
+			} elseif ($aircraftType == 2) {
372
+				$result['aircrafttype'] = "TOW_PLANE";
373
+			} elseif ($aircraftType == 3) {
374
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
375
+			} elseif ($aircraftType == 4) {
376
+				$result['aircrafttype'] = "PARACHUTE";
377
+			} elseif ($aircraftType == 5) {
378
+				$result['aircrafttype'] = "DROP_PLANE";
379
+			} elseif ($aircraftType == 6) {
380
+				$result['aircrafttype'] = "HANG_GLIDER";
381
+			} elseif ($aircraftType == 7) {
382
+				$result['aircrafttype'] = "PARA_GLIDER";
383
+			} elseif ($aircraftType == 8) {
384
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
385
+			} elseif ($aircraftType == 9) {
386
+				$result['aircrafttype'] = "JET_AIRCRAFT";
387
+			} elseif ($aircraftType == 10) {
388
+				$result['aircrafttype'] = "UFO";
389
+			} elseif ($aircraftType == 11) {
390
+				$result['aircrafttype'] = "BALLOON";
391
+			} elseif ($aircraftType == 12) {
392
+				$result['aircrafttype'] = "AIRSHIP";
393
+			} elseif ($aircraftType == 13) {
394
+				$result['aircrafttype'] = "UAV";
395
+			} elseif ($aircraftType == 15) {
396
+				$result['aircrafttype'] = "STATIC_OBJECT";
397
+			}
347 398
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
348 399
 			$result['stealth'] = $stealth;
349 400
 			$result['address'] = $address;
@@ -383,13 +434,21 @@  discard block
 block discarded – undo
383 434
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
384 435
 		    }
385 436
 		}
386
-		} else $result['comment'] = trim($body_parse);
437
+		} else {
438
+			$result['comment'] = trim($body_parse);
439
+		}
387 440
 
388 441
 	    }
389 442
 	//}
390
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
391
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
392
-	if ($debug) print_r($result);
443
+	if (isset($result['latitude'])) {
444
+		$result['latitude'] = round($result['latitude'],4);
445
+	}
446
+	if (isset($result['longitude'])) {
447
+		$result['longitude'] = round($result['longitude'],4);
448
+	}
449
+	if ($debug) {
450
+		print_r($result);
451
+	}
393 452
 	return $result;
394 453
     }
395 454
 }
Please login to merge, or discard this patch.
require/class.Common.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78 78
 			}
79 79
 		} else {
80
-		    return $result;
80
+			return $result;
81 81
 		}
82 82
 	}
83 83
 	
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 	
108 108
 	/**
109
-	* Convert a HTML table to an array
110
-	* @param String $data HTML page
111
-	* @return Array array of the tables in HTML page
112
-	*/
109
+	 * Convert a HTML table to an array
110
+	 * @param String $data HTML page
111
+	 * @return Array array of the tables in HTML page
112
+	 */
113 113
 	public function table2array($data) {
114 114
 		if (!is_string($data)) return array();
115 115
 		if ($data == '') return array();
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 	
145 145
 	/**
146
-	* Convert <p> part of a HTML page to an array
147
-	* @param String $data HTML page
148
-	* @return Array array of the <p> in HTML page
149
-	*/
146
+	 * Convert <p> part of a HTML page to an array
147
+	 * @param String $data HTML page
148
+	 * @return Array array of the <p> in HTML page
149
+	 */
150 150
 	public function text2array($data) {
151 151
 		$html = str_get_html($data);
152 152
 		if ($html === false) return array();
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 	/**
164
-	* Give distance between 2 coordonnates
165
-	* @param Float $lat latitude of first point
166
-	* @param Float $lon longitude of first point
167
-	* @param Float $latc latitude of second point
168
-	* @param Float $lonc longitude of second point
169
-	* @param String $unit km else no unit used
170
-	* @return Float Distance in $unit
171
-	*/
164
+	 * Give distance between 2 coordonnates
165
+	 * @param Float $lat latitude of first point
166
+	 * @param Float $lon longitude of first point
167
+	 * @param Float $latc latitude of second point
168
+	 * @param Float $lonc longitude of second point
169
+	 * @param String $unit km else no unit used
170
+	 * @return Float Distance in $unit
171
+	 */
172 172
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
173 173
 		if ($lat == $latc && $lon == $lonc) return 0;
174 174
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 
188 188
 	/**
189
-	* Check is distance realistic
190
-	* @param int $timeDifference the time between the reception of both messages
191
-	* @param float $distance distance covered
192
-	* @return whether distance is realistic
193
-	*/
189
+	 * Check is distance realistic
190
+	 * @param int $timeDifference the time between the reception of both messages
191
+	 * @param float $distance distance covered
192
+	 * @return whether distance is realistic
193
+	 */
194 194
 	public function withinThreshold ($timeDifference, $distance) {
195 195
 		$x = abs($timeDifference);
196 196
 		$d = abs($distance);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	}
209 209
 
210 210
 	public function isInteger($input){
211
-	    return(ctype_digit(strval($input)));
211
+		return(ctype_digit(strval($input)));
212 212
 	}
213 213
 
214 214
 
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 	}
225 225
 	
226 226
 	/**
227
-	* Copy folder contents
228
-	* @param       string   $source    Source path
229
-	* @param       string   $dest      Destination path
230
-	* @return      bool     Returns true on success, false on failure
231
-	*/
227
+	 * Copy folder contents
228
+	 * @param       string   $source    Source path
229
+	 * @param       string   $dest      Destination path
230
+	 * @return      bool     Returns true on success, false on failure
231
+	 */
232 232
 	public function xcopy($source, $dest)
233 233
 	{
234 234
 		$files = glob($source.'*.*');
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 	
242 242
 	/**
243
-	* Check if an url exist
244
-	* @param	String $url url to check
245
-	* @return	bool Return true on succes false on failure
246
-	*/
243
+	 * Check if an url exist
244
+	 * @param	String $url url to check
245
+	 * @return	bool Return true on succes false on failure
246
+	 */
247 247
 	public function urlexist($url){
248 248
 		$headers=get_headers($url);
249 249
 		return stripos($headers[0],"200 OK")?true:false;
250 250
 	}
251 251
 	
252 252
 	/**
253
-	* Convert hexa to string
254
-	* @param	String $hex data in hexa
255
-	* @return	String Return result
256
-	*/
253
+	 * Convert hexa to string
254
+	 * @param	String $hex data in hexa
255
+	 * @return	String Return result
256
+	 */
257 257
 	public function hex2str($hex) {
258 258
 		$str = '';
259 259
 		$hexln = strlen($hex);
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 	}
335 335
 	
336 336
 	/**
337
-	* Returns list of available locales
338
-	*
339
-	* @return array
337
+	 * Returns list of available locales
338
+	 *
339
+	 * @return array
340 340
 	 */
341 341
 	public function listLocaleDir()
342 342
 	{
@@ -431,100 +431,100 @@  discard block
 block discarded – undo
431 431
 	public function remove_accents($string) {
432 432
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
433 433
 		$chars = array(
434
-		    // Decompositions for Latin-1 Supplement
435
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
436
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
437
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
438
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
439
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
440
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
441
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
442
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
443
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
444
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
445
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
446
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
447
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
448
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
449
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
450
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
451
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
452
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
453
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
454
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
455
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
456
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
457
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
458
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
459
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
460
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
461
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
462
-		    chr(195).chr(191) => 'y',
463
-		    // Decompositions for Latin Extended-A
464
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
465
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
466
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
467
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
468
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
469
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
470
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
471
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
472
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
473
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
474
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
475
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
476
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
477
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
478
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
479
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
480
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
481
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
482
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
483
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
484
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
485
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
486
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
487
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
488
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
489
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
490
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
491
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
492
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
493
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
494
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
495
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
496
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
497
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
498
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
499
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
500
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
501
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
502
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
503
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
504
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
505
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
506
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
507
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
508
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
509
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
510
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
511
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
512
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
513
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
514
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
515
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
516
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
517
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
518
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
519
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
520
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
521
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
522
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
523
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
524
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
525
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
526
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
527
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
434
+			// Decompositions for Latin-1 Supplement
435
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
436
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
437
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
438
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
439
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
440
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
441
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
442
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
443
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
444
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
445
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
446
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
447
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
448
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
449
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
450
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
451
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
452
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
453
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
454
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
455
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
456
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
457
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
458
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
459
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
460
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
461
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
462
+			chr(195).chr(191) => 'y',
463
+			// Decompositions for Latin Extended-A
464
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
465
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
466
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
467
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
468
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
469
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
470
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
471
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
472
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
473
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
474
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
475
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
476
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
477
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
478
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
479
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
480
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
481
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
482
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
483
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
484
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
485
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
486
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
487
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
488
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
489
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
490
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
491
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
492
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
493
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
494
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
495
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
496
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
497
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
498
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
499
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
500
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
501
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
502
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
503
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
504
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
505
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
506
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
507
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
508
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
509
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
510
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
511
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
512
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
513
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
514
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
515
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
516
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
517
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
518
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
519
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
520
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
521
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
522
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
523
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
524
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
525
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
526
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
527
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
528 528
 		);
529 529
 		$string = strtr($string, $chars);
530 530
 		return $string;
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 		$result = curl_exec($ch);
69 69
 		$info = curl_getinfo($ch);
70 70
 		curl_close($ch);
71
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
71
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
72 72
 			echo "Cloudflare Detected\n";
73 73
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
74 74
 			$useragent = UAgent::random();
75 75
 			cloudflare::useUserAgent($useragent);
76 76
 			if ($clearanceCookie = cloudflare::bypass($url)) {
77
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
77
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
78 78
 			}
79 79
 		} else {
80 80
 		    return $result;
@@ -115,27 +115,27 @@  discard block
 block discarded – undo
115 115
 		if ($data == '') return array();
116 116
 		$html = str_get_html($data);
117 117
 		if ($html === false) return array();
118
-		$tabledata=array();
119
-		foreach($html->find('tr') as $element)
118
+		$tabledata = array();
119
+		foreach ($html->find('tr') as $element)
120 120
 		{
121 121
 			$td = array();
122
-			foreach( $element->find('th') as $row)
122
+			foreach ($element->find('th') as $row)
123 123
 			{
124 124
 				$td [] = trim($row->plaintext);
125 125
 			}
126
-			$td=array_filter($td);
126
+			$td = array_filter($td);
127 127
 			$tabledata[] = $td;
128 128
 
129 129
 			$td = array();
130 130
 			$tdi = array();
131
-			foreach( $element->find('td') as $row)
131
+			foreach ($element->find('td') as $row)
132 132
 			{
133 133
 				$td [] = trim($row->plaintext);
134 134
 				$tdi [] = trim($row->innertext);
135 135
 			}
136
-			$td=array_filter($td);
137
-			$tdi=array_filter($tdi);
138
-			$tabledata[]=array_merge($td,$tdi);
136
+			$td = array_filter($td);
137
+			$tdi = array_filter($tdi);
138
+			$tabledata[] = array_merge($td, $tdi);
139 139
 		}
140 140
 		$html->clear();
141 141
 		unset($html);
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	public function text2array($data) {
151 151
 		$html = str_get_html($data);
152 152
 		if ($html === false) return array();
153
-		$tabledata=array();
154
-		foreach($html->find('p') as $element)
153
+		$tabledata = array();
154
+		foreach ($html->find('p') as $element)
155 155
 		{
156 156
 			$tabledata [] = trim($element->plaintext);
157 157
 		}
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	*/
172 172
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
173 173
 		if ($lat == $latc && $lon == $lonc) return 0;
174
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
174
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
175 175
 		if ($unit == "km") {
176
-			return round($dist * 1.609344);
176
+			return round($dist*1.609344);
177 177
 		} elseif ($unit == "m") {
178
-			return round($dist * 1.609344 * 1000);
178
+			return round($dist*1.609344*1000);
179 179
 		} elseif ($unit == "mile" || $unit == "mi") {
180 180
 			return round($dist);
181 181
 		} elseif ($unit == "nm") {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	* @param float $distance distance covered
192 192
 	* @return whether distance is realistic
193 193
 	*/
194
-	public function withinThreshold ($timeDifference, $distance) {
194
+	public function withinThreshold($timeDifference, $distance) {
195 195
 		$x = abs($timeDifference);
196 196
 		$d = abs($distance);
197 197
 		if ($x == 0 || $d == 0) return true;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 		return ($array !== array_values($array));
208 208
 	}
209 209
 
210
-	public function isInteger($input){
210
+	public function isInteger($input) {
211 211
 	    return(ctype_digit(strval($input)));
212 212
 	}
213 213
 
214 214
 
215
-	public function convertDec($dms,$latlong) {
215
+	public function convertDec($dms, $latlong) {
216 216
 		if ($latlong == 'latitude') {
217 217
 			$deg = substr($dms, 0, 2);
218 218
 			$min = substr($dms, 2, 4);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 			$deg = substr($dms, 0, 3);
221 221
 			$min = substr($dms, 3, 5);
222 222
 		}
223
-		return $deg+(($min*60)/3600);
223
+		return $deg + (($min*60)/3600);
224 224
 	}
225 225
 	
226 226
 	/**
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	public function xcopy($source, $dest)
233 233
 	{
234 234
 		$files = glob($source.'*.*');
235
-		foreach($files as $file){
236
-			$file_to_go = str_replace($source,$dest,$file);
235
+		foreach ($files as $file) {
236
+			$file_to_go = str_replace($source, $dest, $file);
237 237
 			copy($file, $file_to_go);
238 238
 		}
239 239
 		return true;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	* @param	String $url url to check
245 245
 	* @return	bool Return true on succes false on failure
246 246
 	*/
247
-	public function urlexist($url){
248
-		$headers=get_headers($url);
249
-		return stripos($headers[0],"200 OK")?true:false;
247
+	public function urlexist($url) {
248
+		$headers = get_headers($url);
249
+		return stripos($headers[0], "200 OK") ? true : false;
250 250
 	}
251 251
 	
252 252
 	/**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function hex2str($hex) {
258 258
 		$str = '';
259 259
 		$hexln = strlen($hex);
260
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
260
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
261 261
 		return $str;
262 262
 	}
263 263
 	
@@ -266,33 +266,33 @@  discard block
 block discarded – undo
266 266
 		//difference in longitudinal coordinates
267 267
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
268 268
 		//difference in the phi of latitudinal coordinates
269
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
269
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
270 270
 		//we need to recalculate $dLon if it is greater than pi
271
-		if(abs($dLon) > pi()) {
272
-			if($dLon > 0) {
273
-				$dLon = (2 * pi() - $dLon) * -1;
271
+		if (abs($dLon) > pi()) {
272
+			if ($dLon > 0) {
273
+				$dLon = (2*pi() - $dLon)*-1;
274 274
 			} else {
275
-				$dLon = 2 * pi() + $dLon;
275
+				$dLon = 2*pi() + $dLon;
276 276
 			}
277 277
 		}
278 278
 		//return the angle, normalized
279
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
279
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
280 280
 	}
281 281
 	
282
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
282
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
283 283
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
284
-		$a = -($lon2-$lon1);
284
+		$a = -($lon2 - $lon1);
285 285
 		$b = $lat2 - $lat1;
286
-		$c = -($a*$lat1+$b*$lon1);
287
-		$d = $a*$lat3+$b*$lon3+$c;
286
+		$c = -($a*$lat1 + $b*$lon1);
287
+		$d = $a*$lat3 + $b*$lon3 + $c;
288 288
 		if ($d > -$approx && $d < $approx) return true;
289 289
 		else return false;
290 290
 	}
291 291
 	
292 292
 	public function array_merge_noappend() {
293 293
 		$output = array();
294
-		foreach(func_get_args() as $array) {
295
-			foreach($array as $key => $value) {
294
+		foreach (func_get_args() as $array) {
295
+			foreach ($array as $key => $value) {
296 296
 				$output[$key] = isset($output[$key]) ?
297 297
 				array_merge($output[$key], $value) : $value;
298 298
 			}
@@ -356,34 +356,34 @@  discard block
 block discarded – undo
356 356
 		return $result;
357 357
 	}
358 358
 
359
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
359
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
360 360
 		global $globalMapRefresh;
361 361
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
362 362
 		$r = 6378;
363 363
 		$latitude = deg2rad($latitude);
364 364
 		$longitude = deg2rad($longitude);
365 365
 		$bearing = deg2rad($heading); 
366
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
367
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
368
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
366
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
367
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
368
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
369 369
 	}
370 370
 	
371
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
371
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
372 372
 		// distance in meter
373 373
 		$R = 6378.14;
374
-		$latitude1 = $latitude * (M_PI/180);
375
-		$longitude1 = $longitude * (M_PI/180);
376
-		$brng = $bearing * (M_PI/180);
374
+		$latitude1 = $latitude*(M_PI/180);
375
+		$longitude1 = $longitude*(M_PI/180);
376
+		$brng = $bearing*(M_PI/180);
377 377
 		$d = $distance;
378 378
 
379 379
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
380
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
380
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
381 381
 
382
-		$latitude2 = $latitude2 * (180/M_PI);
383
-		$longitude2 = $longitude2 * (180/M_PI);
382
+		$latitude2 = $latitude2*(180/M_PI);
383
+		$longitude2 = $longitude2*(180/M_PI);
384 384
 
385
-		$flat = round ($latitude2,6);
386
-		$flong = round ($longitude2,6);
385
+		$flat = round($latitude2, 6);
386
+		$flong = round($longitude2, 6);
387 387
 /*
388 388
 		$dx = $distance*cos($bearing);
389 389
 		$dy = $distance*sin($bearing);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 		$flong = $longitude + $dlong;
393 393
 		$flat = $latitude + $dlat;
394 394
 */
395
-		return array('latitude' => $flat,'longitude' => $flong);
395
+		return array('latitude' => $flat, 'longitude' => $flong);
396 396
 	}
397 397
 
398 398
 	/**
@@ -406,14 +406,14 @@  discard block
 block discarded – undo
406 406
 	 * @param integer $level GZIP compression level (default: 9)
407 407
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
408 408
 	 */
409
-	public function gzCompressFile($source, $level = 9){ 
410
-		$dest = $source . '.gz'; 
411
-		$mode = 'wb' . $level; 
409
+	public function gzCompressFile($source, $level = 9) { 
410
+		$dest = $source.'.gz'; 
411
+		$mode = 'wb'.$level; 
412 412
 		$error = false; 
413 413
 		if ($fp_out = gzopen($dest, $mode)) { 
414
-			if ($fp_in = fopen($source,'rb')) { 
414
+			if ($fp_in = fopen($source, 'rb')) { 
415 415
 				while (!feof($fp_in)) 
416
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
416
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
417 417
 				fclose($fp_in); 
418 418
 			} else {
419 419
 				$error = true; 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	} 
430 430
 	
431 431
 	public function remove_accents($string) {
432
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
432
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
433 433
 		$chars = array(
434 434
 		    // Decompositions for Latin-1 Supplement
435 435
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
487 487
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
488 488
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
489
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
489
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
490 490
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
491 491
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
492 492
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -502,13 +502,13 @@  discard block
 block discarded – undo
502 502
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
503 503
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
504 504
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
505
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
506
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
507
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
508
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
509
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
510
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
511
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
505
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
506
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
507
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
508
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
509
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
510
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
511
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
512 512
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
513 513
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
514 514
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
543 543
 			if (is_numeric($string[$i]) && $concat_flag) {
544 544
 				$int .= $string[$i];
545
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
545
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
546 546
 				$concat_flag = false;
547 547
 			}
548 548
 		}
Please login to merge, or discard this patch.
require/class.Spotter.php 3 patches
Indentation   +1455 added lines, -1455 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	* Get SQL query part for filter used
59
-	* @param Array $filter the filter
60
-	* @return Array the SQL part
61
-	*/
58
+	 * Get SQL query part for filter used
59
+	 * @param Array $filter the filter
60
+	 * @return Array the SQL part
61
+	 */
62 62
 	public function getFilter($filter = array(),$where = false,$and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Executes the SQL statements to get the spotter information
170
-	*
171
-	* @param String $query the SQL query
172
-	* @param Array $params parameter of the query
173
-	* @param String $limitQuery the limit query
174
-	* @return Array the spotter information
175
-	*
176
-	*/
169
+	 * Executes the SQL statements to get the spotter information
170
+	 *
171
+	 * @param String $query the SQL query
172
+	 * @param Array $params parameter of the query
173
+	 * @param String $limitQuery the limit query
174
+	 * @return Array the spotter information
175
+	 *
176
+	 */
177 177
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 343
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344 344
 					} else $temp_array['aircraft_shadow'] = 'default.png';
345
-                                } else {
346
-                            		$temp_array['aircraft_shadow'] = 'default.png';
345
+								} else {
346
+									$temp_array['aircraft_shadow'] = 'default.png';
347 347
 					$temp_array['aircraft_name'] = 'N/A';
348 348
 					$temp_array['aircraft_manufacturer'] = 'N/A';
349
-                            	}
349
+								}
350 350
 			}
351 351
 			$fromsource = NULL;
352 352
 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 	
543 543
 	
544 544
 	/**
545
-	* Gets all the spotter information
546
-	*
547
-	* @return Array the spotter information
548
-	*
549
-	*/
545
+	 * Gets all the spotter information
546
+	 *
547
+	 * @return Array the spotter information
548
+	 *
549
+	 */
550 550
 	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
551 551
 	{
552 552
 		global $globalTimezone, $globalDBdriver;
@@ -893,11 +893,11 @@  discard block
 block discarded – undo
893 893
 	
894 894
 	
895 895
 	/**
896
-	* Gets all the spotter information based on the latest data entry
897
-	*
898
-	* @return Array the spotter information
899
-	*
900
-	*/
896
+	 * Gets all the spotter information based on the latest data entry
897
+	 *
898
+	 * @return Array the spotter information
899
+	 *
900
+	 */
901 901
 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array())
902 902
 	{
903 903
 		global $global_query;
@@ -936,12 +936,12 @@  discard block
 block discarded – undo
936 936
 	}
937 937
     
938 938
     
939
-    /**
940
-	* Gets all the spotter information based on a user's latitude and longitude
941
-	*
942
-	* @return Array the spotter information
943
-	*
944
-	*/
939
+	/**
940
+	 * Gets all the spotter information based on a user's latitude and longitude
941
+	 *
942
+	 * @return Array the spotter information
943
+	 *
944
+	 */
945 945
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
946 946
 	{
947 947
 		date_default_timezone_set('UTC');
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				return false;
970 970
 			}
971 971
 		}
972
-    		$additional_query = '';
972
+			$additional_query = '';
973 973
 		if ($interval != "")
974 974
 		{
975 975
 			if (!is_string($interval))
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 	}
1010 1010
     
1011 1011
     
1012
-    /**
1013
-	* Gets all the spotter information sorted by the newest aircraft type
1014
-	*
1015
-	* @return Array the spotter information
1016
-	*
1017
-	*/
1012
+	/**
1013
+	 * Gets all the spotter information sorted by the newest aircraft type
1014
+	 *
1015
+	 * @return Array the spotter information
1016
+	 *
1017
+	 */
1018 1018
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
     
1056 1056
     
1057 1057
 	/**
1058
-	* Gets all the spotter information sorted by the newest aircraft registration
1059
-	*
1060
-	* @return Array the spotter information
1061
-	*
1062
-	*/
1058
+	 * Gets all the spotter information sorted by the newest aircraft registration
1059
+	 *
1060
+	 * @return Array the spotter information
1061
+	 *
1062
+	 */
1063 1063
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array())
1064 1064
 	{
1065 1065
 		global $global_query;
@@ -1099,11 +1099,11 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 
1101 1101
 	/**
1102
-	* Gets all the spotter information sorted by the newest airline
1103
-	*
1104
-	* @return Array the spotter information
1105
-	*
1106
-	*/
1102
+	 * Gets all the spotter information sorted by the newest airline
1103
+	 *
1104
+	 * @return Array the spotter information
1105
+	 *
1106
+	 */
1107 1107
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
@@ -1142,12 +1142,12 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
     
1144 1144
     
1145
-    /**
1146
-	* Gets all the spotter information sorted by the newest departure airport
1147
-	*
1148
-	* @return Array the spotter information
1149
-	*
1150
-	*/
1145
+	/**
1146
+	 * Gets all the spotter information sorted by the newest departure airport
1147
+	 *
1148
+	 * @return Array the spotter information
1149
+	 *
1150
+	 */
1151 1151
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array())
1152 1152
 	{
1153 1153
 		global $global_query;
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 
1191 1191
 	/**
1192
-	* Gets all the spotter information sorted by the newest arrival airport
1193
-	*
1194
-	* @return Array the spotter information
1195
-	*
1196
-	*/
1192
+	 * Gets all the spotter information sorted by the newest arrival airport
1193
+	 *
1194
+	 * @return Array the spotter information
1195
+	 *
1196
+	 */
1197 1197
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array())
1198 1198
 	{
1199 1199
 		global $global_query;
@@ -1232,11 +1232,11 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 
1234 1234
 	/**
1235
-	* Gets all the spotter information based on the spotter id
1236
-	*
1237
-	* @return Array the spotter information
1238
-	*
1239
-	*/
1235
+	 * Gets all the spotter information based on the spotter id
1236
+	 *
1237
+	 * @return Array the spotter information
1238
+	 *
1239
+	 */
1240 1240
 	public function getSpotterDataByID($id = '')
1241 1241
 	{
1242 1242
 		global $global_query;
@@ -1258,11 +1258,11 @@  discard block
 block discarded – undo
1258 1258
 	
1259 1259
 	
1260 1260
 	/**
1261
-	* Gets all the spotter information based on the callsign
1262
-	*
1263
-	* @return Array the spotter information
1264
-	*
1265
-	*/
1261
+	 * Gets all the spotter information based on the callsign
1262
+	 *
1263
+	 * @return Array the spotter information
1264
+	 *
1265
+	 */
1266 1266
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
1267 1267
 	{
1268 1268
 		global $global_query;
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
 	}
1315 1315
 	
1316 1316
 	/**
1317
-	* Gets all the spotter information based on the owner
1318
-	*
1319
-	* @return Array the spotter information
1320
-	*
1321
-	*/
1317
+	 * Gets all the spotter information based on the owner
1318
+	 *
1319
+	 * @return Array the spotter information
1320
+	 *
1321
+	 */
1322 1322
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1323 1323
 	{
1324 1324
 		global $global_query;
@@ -1371,11 +1371,11 @@  discard block
 block discarded – undo
1371 1371
 	}
1372 1372
 	
1373 1373
 	/**
1374
-	* Gets all the spotter information based on the pilot
1375
-	*
1376
-	* @return Array the spotter information
1377
-	*
1378
-	*/
1374
+	 * Gets all the spotter information based on the pilot
1375
+	 *
1376
+	 * @return Array the spotter information
1377
+	 *
1378
+	 */
1379 1379
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1380 1380
 	{
1381 1381
 		global $global_query;
@@ -1424,11 +1424,11 @@  discard block
 block discarded – undo
1424 1424
 	
1425 1425
 	
1426 1426
 	/**
1427
-	* Gets all the spotter information based on the aircraft type
1428
-	*
1429
-	* @return Array the spotter information
1430
-	*
1431
-	*/
1427
+	 * Gets all the spotter information based on the aircraft type
1428
+	 *
1429
+	 * @return Array the spotter information
1430
+	 *
1431
+	 */
1432 1432
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array())
1433 1433
 	{
1434 1434
 		global $global_query;
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
 	
1483 1483
 	
1484 1484
 	/**
1485
-	* Gets all the spotter information based on the aircraft registration
1486
-	*
1487
-	* @return Array the spotter information
1488
-	*
1489
-	*/
1485
+	 * Gets all the spotter information based on the aircraft registration
1486
+	 *
1487
+	 * @return Array the spotter information
1488
+	 *
1489
+	 */
1490 1490
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array())
1491 1491
 	{
1492 1492
 		global $global_query;
@@ -1543,11 +1543,11 @@  discard block
 block discarded – undo
1543 1543
 	
1544 1544
 	
1545 1545
 	/**
1546
-	* Gets all the spotter information based on the airline
1547
-	*
1548
-	* @return Array the spotter information
1549
-	*
1550
-	*/
1546
+	 * Gets all the spotter information based on the airline
1547
+	 *
1548
+	 * @return Array the spotter information
1549
+	 *
1550
+	 */
1551 1551
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
@@ -1600,11 +1600,11 @@  discard block
 block discarded – undo
1600 1600
 	
1601 1601
 	
1602 1602
 	/**
1603
-	* Gets all the spotter information based on the airport
1604
-	*
1605
-	* @return Array the spotter information
1606
-	*
1607
-	*/
1603
+	 * Gets all the spotter information based on the airport
1604
+	 *
1605
+	 * @return Array the spotter information
1606
+	 *
1607
+	 */
1608 1608
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
 
1659 1659
 
1660 1660
 	/**
1661
-	* Gets all the spotter information based on the date
1662
-	*
1663
-	* @return Array the spotter information
1664
-	*
1665
-	*/
1661
+	 * Gets all the spotter information based on the date
1662
+	 *
1663
+	 * @return Array the spotter information
1664
+	 *
1665
+	 */
1666 1666
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1726,11 +1726,11 @@  discard block
 block discarded – undo
1726 1726
 
1727 1727
 
1728 1728
 	/**
1729
-	* Gets all the spotter information based on the country name
1730
-	*
1731
-	* @return Array the spotter information
1732
-	*
1733
-	*/
1729
+	 * Gets all the spotter information based on the country name
1730
+	 *
1731
+	 * @return Array the spotter information
1732
+	 *
1733
+	 */
1734 1734
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
@@ -1784,11 +1784,11 @@  discard block
 block discarded – undo
1784 1784
 	
1785 1785
 	
1786 1786
 	/**
1787
-	* Gets all the spotter information based on the manufacturer name
1788
-	*
1789
-	* @return Array the spotter information
1790
-	*
1791
-	*/
1787
+	 * Gets all the spotter information based on the manufacturer name
1788
+	 *
1789
+	 * @return Array the spotter information
1790
+	 *
1791
+	 */
1792 1792
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array())
1793 1793
 	{
1794 1794
 		global $global_query;
@@ -1844,13 +1844,13 @@  discard block
 block discarded – undo
1844 1844
   
1845 1845
   
1846 1846
 	/**
1847
-	* Gets a list of all aircraft that take a route
1848
-	*
1849
-	* @param String $departure_airport_icao ICAO code of departure airport
1850
-	* @param String $arrival_airport_icao ICAO code of arrival airport
1851
-	* @return Array the spotter information
1852
-	*
1853
-	*/
1847
+	 * Gets a list of all aircraft that take a route
1848
+	 *
1849
+	 * @param String $departure_airport_icao ICAO code of departure airport
1850
+	 * @param String $arrival_airport_icao ICAO code of arrival airport
1851
+	 * @return Array the spotter information
1852
+	 *
1853
+	 */
1854 1854
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array())
1855 1855
 	{
1856 1856
 		global $global_query;
@@ -1919,11 +1919,11 @@  discard block
 block discarded – undo
1919 1919
 	
1920 1920
 	
1921 1921
 	/**
1922
-	* Gets all the spotter information based on the special column in the table
1923
-	*
1924
-	* @return Array the spotter information
1925
-	*
1926
-	*/
1922
+	 * Gets all the spotter information based on the special column in the table
1923
+	 *
1924
+	 * @return Array the spotter information
1925
+	 *
1926
+	 */
1927 1927
 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array())
1928 1928
 	{
1929 1929
 		global $global_query;
@@ -1962,11 +1962,11 @@  discard block
 block discarded – undo
1962 1962
 	}
1963 1963
 
1964 1964
 	/**
1965
-	* Gets all the highlight based on a aircraft registration
1966
-	*
1967
-	* @return String the highlight text
1968
-	*
1969
-	*/
1965
+	 * Gets all the highlight based on a aircraft registration
1966
+	 *
1967
+	 * @return String the highlight text
1968
+	 *
1969
+	 */
1970 1970
 	public function getHighlightByRegistration($registration,$filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
@@ -1988,13 +1988,13 @@  discard block
 block discarded – undo
1988 1988
 
1989 1989
 	
1990 1990
 	/**
1991
-	* Gets the squawk usage from squawk code
1992
-	*
1993
-	* @param String $squawk squawk code
1994
-	* @param String $country country
1995
-	* @return String usage
1996
-	*
1997
-	*/
1991
+	 * Gets the squawk usage from squawk code
1992
+	 *
1993
+	 * @param String $squawk squawk code
1994
+	 * @param String $country country
1995
+	 * @return String usage
1996
+	 *
1997
+	 */
1998 1998
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1999 1999
 	{
2000 2000
 		
@@ -2015,12 +2015,12 @@  discard block
 block discarded – undo
2015 2015
 	}
2016 2016
 
2017 2017
 	/**
2018
-	* Gets the airport icao from the iata
2019
-	*
2020
-	* @param String $airport_iata the iata code of the airport
2021
-	* @return String airport iata
2022
-	*
2023
-	*/
2018
+	 * Gets the airport icao from the iata
2019
+	 *
2020
+	 * @param String $airport_iata the iata code of the airport
2021
+	 * @return String airport iata
2022
+	 *
2023
+	 */
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
@@ -2040,14 +2040,14 @@  discard block
 block discarded – undo
2040 2040
 	}
2041 2041
 
2042 2042
 	/**
2043
-	* Gets the airport distance
2044
-	*
2045
-	* @param String $airport_icao the icao code of the airport
2046
-	* @param Float $latitude the latitude
2047
-	* @param Float $longitude the longitude
2048
-	* @return Float distance to the airport
2049
-	*
2050
-	*/
2043
+	 * Gets the airport distance
2044
+	 *
2045
+	 * @param String $airport_icao the icao code of the airport
2046
+	 * @param Float $latitude the latitude
2047
+	 * @param Float $longitude the longitude
2048
+	 * @return Float distance to the airport
2049
+	 *
2050
+	 */
2051 2051
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
2052 2052
 	{
2053 2053
 		
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
 	}
2069 2069
 	
2070 2070
 	/**
2071
-	* Gets the airport info based on the icao
2072
-	*
2073
-	* @param String $airport the icao code of the airport
2074
-	* @return Array airport information
2075
-	*
2076
-	*/
2071
+	 * Gets the airport info based on the icao
2072
+	 *
2073
+	 * @param String $airport the icao code of the airport
2074
+	 * @return Array airport information
2075
+	 *
2076
+	 */
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
@@ -2119,12 +2119,12 @@  discard block
 block discarded – undo
2119 2119
 	}
2120 2120
 	
2121 2121
 	/**
2122
-	* Gets the airport info based on the country
2123
-	*
2124
-	* @param Array $countries Airports countries
2125
-	* @return Array airport information
2126
-	*
2127
-	*/
2122
+	 * Gets the airport info based on the country
2123
+	 *
2124
+	 * @param Array $countries Airports countries
2125
+	 * @return Array airport information
2126
+	 *
2127
+	 */
2128 2128
 	public function getAllAirportInfobyCountry($countries)
2129 2129
 	{
2130 2130
 		$lst_countries = '';
@@ -2162,12 +2162,12 @@  discard block
 block discarded – undo
2162 2162
 	}
2163 2163
 	
2164 2164
 	/**
2165
-	* Gets airports info based on the coord
2166
-	*
2167
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
-	* @return Array airport information
2169
-	*
2170
-	*/
2165
+	 * Gets airports info based on the coord
2166
+	 *
2167
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
+	 * @return Array airport information
2169
+	 *
2170
+	 */
2171 2171
 	public function getAllAirportInfobyCoord($coord)
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
@@ -2198,12 +2198,12 @@  discard block
 block discarded – undo
2198 2198
 	}
2199 2199
 
2200 2200
 	/**
2201
-	* Gets waypoints info based on the coord
2202
-	*
2203
-	* @param Array $coord waypoints coord
2204
-	* @return Array airport information
2205
-	*
2206
-	*/
2201
+	 * Gets waypoints info based on the coord
2202
+	 *
2203
+	 * @param Array $coord waypoints coord
2204
+	 * @return Array airport information
2205
+	 *
2206
+	 */
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
@@ -2237,12 +2237,12 @@  discard block
 block discarded – undo
2237 2237
 	
2238 2238
 	
2239 2239
 	/**
2240
-	* Gets the airline info based on the icao code or iata code
2241
-	*
2242
-	* @param String $airline_icao the iata code of the airport
2243
-	* @return Array airport information
2244
-	*
2245
-	*/
2240
+	 * Gets the airline info based on the icao code or iata code
2241
+	 *
2242
+	 * @param String $airline_icao the iata code of the airport
2243
+	 * @return Array airport information
2244
+	 *
2245
+	 */
2246 2246
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
@@ -2273,7 +2273,7 @@  discard block
 block discarded – undo
2273 2273
 			} else {
2274 2274
 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2275 2275
 			}
2276
-                        /*
2276
+						/*
2277 2277
 			$airline_array = array();
2278 2278
 			$temp_array = array();
2279 2279
 		
@@ -2306,12 +2306,12 @@  discard block
 block discarded – undo
2306 2306
 	}
2307 2307
 	
2308 2308
 	/**
2309
-	* Gets the airline info based on the airline name
2310
-	*
2311
-	* @param String $airline_name the name of the airline
2312
-	* @return Array airline information
2313
-	*
2314
-	*/
2309
+	 * Gets the airline info based on the airline name
2310
+	 *
2311
+	 * @param String $airline_name the name of the airline
2312
+	 * @return Array airline information
2313
+	 *
2314
+	 */
2315 2315
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
@@ -2339,12 +2339,12 @@  discard block
 block discarded – undo
2339 2339
 	
2340 2340
 	
2341 2341
 	/**
2342
-	* Gets the aircraft info based on the aircraft type
2343
-	*
2344
-	* @param String $aircraft_type the aircraft type
2345
-	* @return Array aircraft information
2346
-	*
2347
-	*/
2342
+	 * Gets the aircraft info based on the aircraft type
2343
+	 *
2344
+	 * @param String $aircraft_type the aircraft type
2345
+	 * @return Array aircraft information
2346
+	 *
2347
+	 */
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350 2350
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2376,12 +2376,12 @@  discard block
 block discarded – undo
2376 2376
 	}
2377 2377
 
2378 2378
 	/**
2379
-	* Gets the aircraft icao based on the aircraft name/type
2380
-	*
2381
-	* @param String $aircraft_type the aircraft type
2382
-	* @return String aircraft information
2383
-	*
2384
-	*/
2379
+	 * Gets the aircraft icao based on the aircraft name/type
2380
+	 *
2381
+	 * @param String $aircraft_type the aircraft type
2382
+	 * @return String aircraft information
2383
+	 *
2384
+	 */
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387 2387
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2406,12 +2406,12 @@  discard block
 block discarded – undo
2406 2406
 	}
2407 2407
 	
2408 2408
 	/**
2409
-	* Gets the aircraft info based on the aircraft modes
2410
-	*
2411
-	* @param String $aircraft_modes the aircraft ident (hex)
2412
-	* @return String aircraft type
2413
-	*
2414
-	*/
2409
+	 * Gets the aircraft info based on the aircraft modes
2410
+	 *
2411
+	 * @param String $aircraft_modes the aircraft ident (hex)
2412
+	 * @return String aircraft type
2413
+	 *
2414
+	 */
2415 2415
 	public function getAllAircraftType($aircraft_modes,$source_type = '')
2416 2416
 	{
2417 2417
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2438,12 +2438,12 @@  discard block
 block discarded – undo
2438 2438
 	}
2439 2439
 
2440 2440
 	/**
2441
-	* Gets the aircraft info based on the aircraft registration
2442
-	*
2443
-	* @param String $registration the aircraft registration
2444
-	* @return String aircraft type
2445
-	*
2446
-	*/
2441
+	 * Gets the aircraft info based on the aircraft registration
2442
+	 *
2443
+	 * @param String $registration the aircraft registration
2444
+	 * @return String aircraft type
2445
+	 *
2446
+	 */
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449 2449
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2461,12 +2461,12 @@  discard block
 block discarded – undo
2461 2461
 	}
2462 2462
 
2463 2463
 	/**
2464
-	* Gets the spotter_id and flightaware_id based on the aircraft registration
2465
-	*
2466
-	* @param String $registration the aircraft registration
2467
-	* @return Array spotter_id and flightaware_id
2468
-	*
2469
-	*/
2464
+	 * Gets the spotter_id and flightaware_id based on the aircraft registration
2465
+	 *
2466
+	 * @param String $registration the aircraft registration
2467
+	 * @return Array spotter_id and flightaware_id
2468
+	 *
2469
+	 */
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472 2472
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2485,12 +2485,12 @@  discard block
 block discarded – undo
2485 2485
 	}
2486 2486
 
2487 2487
 	/**
2488
-	* Gets correct aircraft operator code
2489
-	*
2490
-	* @param String $operator the aircraft operator code (callsign)
2491
-	* @return String aircraft operator code
2492
-	*
2493
-	*/
2488
+	 * Gets correct aircraft operator code
2489
+	 *
2490
+	 * @param String $operator the aircraft operator code (callsign)
2491
+	 * @return String aircraft operator code
2492
+	 *
2493
+	 */
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496 2496
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2507,16 +2507,16 @@  discard block
 block discarded – undo
2507 2507
 	}
2508 2508
 
2509 2509
 	/**
2510
-	* Gets the aircraft route based on the aircraft callsign
2511
-	*
2512
-	* @param String $callsign the aircraft callsign
2513
-	* @return Array aircraft type
2514
-	*
2515
-	*/
2510
+	 * Gets the aircraft route based on the aircraft callsign
2511
+	 *
2512
+	 * @param String $callsign the aircraft callsign
2513
+	 * @return Array aircraft type
2514
+	 *
2515
+	 */
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518 2518
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2519
+				if ($callsign == '') return array();
2520 2520
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2521 2521
 		
2522 2522
 		$sth = $this->db->prepare($query);
@@ -2530,12 +2530,12 @@  discard block
 block discarded – undo
2530 2530
 	}
2531 2531
 	
2532 2532
 	/**
2533
-	* Gets the aircraft info based on the aircraft registration
2534
-	*
2535
-	* @param String $registration the aircraft registration
2536
-	* @return Array aircraft information
2537
-	*
2538
-	*/
2533
+	 * Gets the aircraft info based on the aircraft registration
2534
+	 *
2535
+	 * @param String $registration the aircraft registration
2536
+	 * @return Array aircraft information
2537
+	 *
2538
+	 */
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541 2541
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2562,12 +2562,12 @@  discard block
 block discarded – undo
2562 2562
 	}
2563 2563
 	
2564 2564
 	/**
2565
-	* Gets the aircraft owner & base based on the aircraft registration
2566
-	*
2567
-	* @param String $registration the aircraft registration
2568
-	* @return Array aircraft information
2569
-	*
2570
-	*/
2565
+	 * Gets the aircraft owner & base based on the aircraft registration
2566
+	 *
2567
+	 * @param String $registration the aircraft registration
2568
+	 * @return Array aircraft information
2569
+	 *
2570
+	 */
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573 2573
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2584,11 +2584,11 @@  discard block
 block discarded – undo
2584 2584
 	
2585 2585
   
2586 2586
   /**
2587
-	* Gets all flights (but with only little info)
2588
-	*
2589
-	* @return Array basic flight information
2590
-	*
2591
-	*/
2587
+   * Gets all flights (but with only little info)
2588
+   *
2589
+   * @return Array basic flight information
2590
+   *
2591
+   */
2592 2592
 	public function getAllFlightsforSitemap()
2593 2593
 	{
2594 2594
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
2599
-                  /*
2599
+				  /*
2600 2600
 		$flight_array = array();
2601 2601
 		$temp_array = array();
2602 2602
 		
@@ -2618,11 +2618,11 @@  discard block
 block discarded – undo
2618 2618
 	}
2619 2619
   
2620 2620
 	/**
2621
-	* Gets a list of all aircraft manufacturers
2622
-	*
2623
-	* @return Array list of aircraft types
2624
-	*
2625
-	*/
2621
+	 * Gets a list of all aircraft manufacturers
2622
+	 *
2623
+	 * @return Array list of aircraft types
2624
+	 *
2625
+	 */
2626 2626
 	public function getAllManufacturers()
2627 2627
 	{
2628 2628
 		/*
@@ -2651,11 +2651,11 @@  discard block
 block discarded – undo
2651 2651
   
2652 2652
   
2653 2653
   /**
2654
-	* Gets a list of all aircraft types
2655
-	*
2656
-	* @return Array list of aircraft types
2657
-	*
2658
-	*/
2654
+   * Gets a list of all aircraft types
2655
+   *
2656
+   * @return Array list of aircraft types
2657
+   *
2658
+   */
2659 2659
 	public function getAllAircraftTypes($filters = array())
2660 2660
 	{
2661 2661
 		/*
@@ -2690,11 +2690,11 @@  discard block
 block discarded – undo
2690 2690
 	
2691 2691
 	
2692 2692
 	/**
2693
-	* Gets a list of all aircraft registrations
2694
-	*
2695
-	* @return Array list of aircraft registrations
2696
-	*
2697
-	*/
2693
+	 * Gets a list of all aircraft registrations
2694
+	 *
2695
+	 * @return Array list of aircraft registrations
2696
+	 *
2697
+	 */
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700 2700
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2719,12 +2719,12 @@  discard block
 block discarded – undo
2719 2719
 	}
2720 2720
 
2721 2721
 	/**
2722
-	* Gets all source name
2723
-	*
2724
-	* @param String type format of source
2725
-	* @return Array list of source name
2726
-	*
2727
-	*/
2722
+	 * Gets all source name
2723
+	 *
2724
+	 * @param String type format of source
2725
+	 * @return Array list of source name
2726
+	 *
2727
+	 */
2728 2728
 	public function getAllSourceName($type = '',$filters = array())
2729 2729
 	{
2730 2730
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2755,11 +2755,11 @@  discard block
 block discarded – undo
2755 2755
 
2756 2756
 
2757 2757
 	/**
2758
-	* Gets a list of all airline names
2759
-	*
2760
-	* @return Array list of airline names
2761
-	*
2762
-	*/
2758
+	 * Gets a list of all airline names
2759
+	 *
2760
+	 * @return Array list of airline names
2761
+	 *
2762
+	 */
2763 2763
 	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2764 2764
 	{
2765 2765
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2808,11 +2808,11 @@  discard block
 block discarded – undo
2808 2808
 	}
2809 2809
 	
2810 2810
 	/**
2811
-	* Gets a list of all alliance names
2812
-	*
2813
-	* @return Array list of alliance names
2814
-	*
2815
-	*/
2811
+	 * Gets a list of all alliance names
2812
+	 *
2813
+	 * @return Array list of alliance names
2814
+	 *
2815
+	 */
2816 2816
 	public function getAllAllianceNames($forsource = NULL,$filters = array())
2817 2817
 	{
2818 2818
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2837,11 +2837,11 @@  discard block
 block discarded – undo
2837 2837
 	}
2838 2838
 	
2839 2839
 	/**
2840
-	* Gets a list of all airline countries
2841
-	*
2842
-	* @return Array list of airline countries
2843
-	*
2844
-	*/
2840
+	 * Gets a list of all airline countries
2841
+	 *
2842
+	 * @return Array list of airline countries
2843
+	 *
2844
+	 */
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847 2847
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2869,11 +2869,11 @@  discard block
 block discarded – undo
2869 2869
 	
2870 2870
 	
2871 2871
 	/**
2872
-	* Gets a list of all departure & arrival names
2873
-	*
2874
-	* @return Array list of airport names
2875
-	*
2876
-	*/
2872
+	 * Gets a list of all departure & arrival names
2873
+	 *
2874
+	 * @return Array list of airport names
2875
+	 *
2876
+	 */
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879 2879
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2921,11 +2921,11 @@  discard block
 block discarded – undo
2921 2921
 	} 
2922 2922
 
2923 2923
 	/**
2924
-	* Gets a list of all owner names
2925
-	*
2926
-	* @return Array list of owner names
2927
-	*
2928
-	*/
2924
+	 * Gets a list of all owner names
2925
+	 *
2926
+	 * @return Array list of owner names
2927
+	 *
2928
+	 */
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931 2931
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2939,11 +2939,11 @@  discard block
 block discarded – undo
2939 2939
 	} 
2940 2940
 
2941 2941
 	/**
2942
-	* Gets a list of all pilot names and pilot ids
2943
-	*
2944
-	* @return Array list of pilot names and pilot ids
2945
-	*
2946
-	*/
2942
+	 * Gets a list of all pilot names and pilot ids
2943
+	 *
2944
+	 * @return Array list of pilot names and pilot ids
2945
+	 *
2946
+	 */
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949 2949
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2958,11 +2958,11 @@  discard block
 block discarded – undo
2958 2958
 	
2959 2959
 	
2960 2960
 	/**
2961
-	* Gets a list of all departure & arrival airport countries
2962
-	*
2963
-	* @return Array list of airport countries
2964
-	*
2965
-	*/
2961
+	 * Gets a list of all departure & arrival airport countries
2962
+	 *
2963
+	 * @return Array list of airport countries
2964
+	 *
2965
+	 */
2966 2966
 	public function getAllAirportCountries($filters = array())
2967 2967
 	{
2968 2968
 		$airport_array = array();
@@ -3010,11 +3010,11 @@  discard block
 block discarded – undo
3010 3010
 	
3011 3011
 	
3012 3012
 	/**
3013
-	* Gets a list of all countries (airline, departure airport & arrival airport)
3014
-	*
3015
-	* @return Array list of countries
3016
-	*
3017
-	*/
3013
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
3014
+	 *
3015
+	 * @return Array list of countries
3016
+	 *
3017
+	 */
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020 3020
 		$Connection= new Connection($this->db);
@@ -3091,11 +3091,11 @@  discard block
 block discarded – undo
3091 3091
 	
3092 3092
 	
3093 3093
 	/**
3094
-	* Gets a list of all idents/callsigns
3095
-	*
3096
-	* @return Array list of ident/callsign names
3097
-	*
3098
-	*/
3094
+	 * Gets a list of all idents/callsigns
3095
+	 *
3096
+	 * @return Array list of ident/callsign names
3097
+	 *
3098
+	 */
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101 3101
 		$filter_query = $this->getFilter($filters,true,true);
@@ -3119,9 +3119,9 @@  discard block
 block discarded – undo
3119 3119
 	}
3120 3120
 
3121 3121
 	/**
3122
-	* Get a list of flights from airport since 7 days
3123
-	* @return Array number, icao, name and city of airports
3124
-	*/
3122
+	 * Get a list of flights from airport since 7 days
3123
+	 * @return Array number, icao, name and city of airports
3124
+	 */
3125 3125
 
3126 3126
 	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
@@ -3152,9 +3152,9 @@  discard block
 block discarded – undo
3152 3152
 	}
3153 3153
 
3154 3154
 	/**
3155
-	* Get a list of flights from airport since 7 days
3156
-	* @return Array number, icao, name and city of airports
3157
-	*/
3155
+	 * Get a list of flights from airport since 7 days
3156
+	 * @return Array number, icao, name and city of airports
3157
+	 */
3158 3158
 
3159 3159
 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') {
3160 3160
 		global $globalTimezone, $globalDBdriver;
@@ -3184,9 +3184,9 @@  discard block
 block discarded – undo
3184 3184
 	}
3185 3185
 
3186 3186
 	/**
3187
-	* Get a list of flights from detected airport since 7 days
3188
-	* @return Array number, icao, name and city of airports
3189
-	*/
3187
+	 * Get a list of flights from detected airport since 7 days
3188
+	 * @return Array number, icao, name and city of airports
3189
+	 */
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
@@ -3224,9 +3224,9 @@  discard block
 block discarded – undo
3224 3224
 	}
3225 3225
 
3226 3226
 	/**
3227
-	* Get a list of flights from detected airport since 7 days
3228
-	* @return Array number, icao, name and city of airports
3229
-	*/
3227
+	 * Get a list of flights from detected airport since 7 days
3228
+	 * @return Array number, icao, name and city of airports
3229
+	 */
3230 3230
 
3231 3231
 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') {
3232 3232
 		global $globalTimezone, $globalDBdriver;
@@ -3268,9 +3268,9 @@  discard block
 block discarded – undo
3268 3268
 
3269 3269
 
3270 3270
 	/**
3271
-	* Get a list of flights to airport since 7 days
3272
-	* @return Array number, icao, name and city of airports
3273
-	*/
3271
+	 * Get a list of flights to airport since 7 days
3272
+	 * @return Array number, icao, name and city of airports
3273
+	 */
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
@@ -3303,9 +3303,9 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
 
3305 3305
 	/**
3306
-	* Get a list of flights detected to airport since 7 days
3307
-	* @return Array number, icao, name and city of airports
3308
-	*/
3306
+	 * Get a list of flights detected to airport since 7 days
3307
+	 * @return Array number, icao, name and city of airports
3308
+	 */
3309 3309
 
3310 3310
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
@@ -3346,9 +3346,9 @@  discard block
 block discarded – undo
3346 3346
 
3347 3347
 
3348 3348
 	/**
3349
-	* Get a list of flights to airport since 7 days
3350
-	* @return Array number, icao, name and city of airports
3351
-	*/
3349
+	 * Get a list of flights to airport since 7 days
3350
+	 * @return Array number, icao, name and city of airports
3351
+	 */
3352 3352
 
3353 3353
 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') {
3354 3354
 		global $globalTimezone, $globalDBdriver;
@@ -3380,9 +3380,9 @@  discard block
 block discarded – undo
3380 3380
 
3381 3381
 
3382 3382
 	/**
3383
-	* Get a list of flights detected to airport since 7 days
3384
-	* @return Array number, icao, name and city of airports
3385
-	*/
3383
+	 * Get a list of flights detected to airport since 7 days
3384
+	 * @return Array number, icao, name and city of airports
3385
+	 */
3386 3386
 
3387 3387
 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') {
3388 3388
 		global $globalTimezone, $globalDBdriver;
@@ -3426,11 +3426,11 @@  discard block
 block discarded – undo
3426 3426
 
3427 3427
 
3428 3428
 	/**
3429
-	* Gets a list of all dates
3430
-	*
3431
-	* @return Array list of date names
3432
-	*
3433
-	*/
3429
+	 * Gets a list of all dates
3430
+	 *
3431
+	 * @return Array list of date names
3432
+	 *
3433
+	 */
3434 3434
 	public function getAllDates()
3435 3435
 	{
3436 3436
 		global $globalTimezone, $globalDBdriver;
@@ -3471,11 +3471,11 @@  discard block
 block discarded – undo
3471 3471
 	
3472 3472
 	
3473 3473
 	/**
3474
-	* Gets all route combinations
3475
-	*
3476
-	* @return Array the route list
3477
-	*
3478
-	*/
3474
+	 * Gets all route combinations
3475
+	 *
3476
+	 * @return Array the route list
3477
+	 *
3478
+	 */
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
3481 3481
 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
@@ -3501,13 +3501,13 @@  discard block
 block discarded – undo
3501 3501
 	}
3502 3502
 
3503 3503
 	/**
3504
-	* Update ident spotter data
3505
-	*
3506
-	* @param String $flightaware_id the ID from flightaware
3507
-	* @param String $ident the flight ident
3508
-	* @return String success or false
3509
-	*
3510
-	*/	
3504
+	 * Update ident spotter data
3505
+	 *
3506
+	 * @param String $flightaware_id the ID from flightaware
3507
+	 * @param String $ident the flight ident
3508
+	 * @return String success or false
3509
+	 *
3510
+	 */	
3511 3511
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -3528,14 +3528,14 @@  discard block
 block discarded – undo
3528 3528
 		} else {
3529 3529
 			$airline_array = $this->getAllAirlineInfo("NA");
3530 3530
 		}
3531
-                $airline_name = $airline_array[0]['name'];
3532
-                $airline_icao = $airline_array[0]['icao'];
3533
-                $airline_country = $airline_array[0]['country'];
3534
-                $airline_type = $airline_array[0]['type'];
3531
+				$airline_name = $airline_array[0]['name'];
3532
+				$airline_icao = $airline_array[0]['icao'];
3533
+				$airline_country = $airline_array[0]['country'];
3534
+				$airline_type = $airline_array[0]['type'];
3535 3535
 
3536 3536
 
3537 3537
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
3538
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3538
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3539 3539
 
3540 3540
 		try {
3541 3541
 			$sth = $this->db->prepare($query);
@@ -3548,19 +3548,19 @@  discard block
 block discarded – undo
3548 3548
 
3549 3549
 	}
3550 3550
 	/**
3551
-	* Update latest spotter data
3552
-	*
3553
-	* @param String $flightaware_id the ID from flightaware
3554
-	* @param String $ident the flight ident
3555
-	* @param String $arrival_airport_icao the arrival airport
3556
-	* @return String success or false
3557
-	*
3558
-	*/	
3551
+	 * Update latest spotter data
3552
+	 *
3553
+	 * @param String $flightaware_id the ID from flightaware
3554
+	 * @param String $ident the flight ident
3555
+	 * @param String $arrival_airport_icao the arrival airport
3556
+	 * @return String success or false
3557
+	 *
3558
+	 */	
3559 3559
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3560
 	{
3561 3561
 		if ($groundspeed == '') $groundspeed = NULL;
3562 3562
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3563
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3563
+				$query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3564 3564
 
3565 3565
 		try {
3566 3566
 			$sth = $this->db->prepare($query);
@@ -3574,32 +3574,32 @@  discard block
 block discarded – undo
3574 3574
 	}
3575 3575
 
3576 3576
 	/**
3577
-	* Adds a new spotter data
3578
-	*
3579
-	* @param String $flightaware_id the ID from flightaware
3580
-	* @param String $ident the flight ident
3581
-	* @param String $aircraft_icao the aircraft type
3582
-	* @param String $departure_airport_icao the departure airport
3583
-	* @param String $arrival_airport_icao the arrival airport
3584
-	* @param String $latitude latitude of flight
3585
-	* @param String $longitude latitude of flight
3586
-	* @param String $waypoints waypoints of flight
3587
-	* @param String $altitude altitude of flight
3588
-	* @param String $heading heading of flight
3589
-	* @param String $groundspeed speed of flight
3590
-	* @param String $date date of flight
3591
-	* @param String $departure_airport_time departure time of flight
3592
-	* @param String $arrival_airport_time arrival time of flight
3593
-	* @param String $squawk squawk code of flight
3594
-	* @param String $route_stop route stop of flight
3595
-	* @param String $highlight highlight or not
3596
-	* @param String $ModeS ModesS code of flight
3597
-	* @param String $registration registration code of flight
3598
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
3599
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
3600
-	* @param String $verticalrate vertival rate of flight
3601
-	* @return String success or false
3602
-	*/
3577
+	 * Adds a new spotter data
3578
+	 *
3579
+	 * @param String $flightaware_id the ID from flightaware
3580
+	 * @param String $ident the flight ident
3581
+	 * @param String $aircraft_icao the aircraft type
3582
+	 * @param String $departure_airport_icao the departure airport
3583
+	 * @param String $arrival_airport_icao the arrival airport
3584
+	 * @param String $latitude latitude of flight
3585
+	 * @param String $longitude latitude of flight
3586
+	 * @param String $waypoints waypoints of flight
3587
+	 * @param String $altitude altitude of flight
3588
+	 * @param String $heading heading of flight
3589
+	 * @param String $groundspeed speed of flight
3590
+	 * @param String $date date of flight
3591
+	 * @param String $departure_airport_time departure time of flight
3592
+	 * @param String $arrival_airport_time arrival time of flight
3593
+	 * @param String $squawk squawk code of flight
3594
+	 * @param String $route_stop route stop of flight
3595
+	 * @param String $highlight highlight or not
3596
+	 * @param String $ModeS ModesS code of flight
3597
+	 * @param String $registration registration code of flight
3598
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
3599
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
3600
+	 * @param String $verticalrate vertival rate of flight
3601
+	 * @return String success or false
3602
+	 */
3603 3603
 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '',$source_type = '')
3604 3604
 	{
3605 3605
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
@@ -3814,8 +3814,8 @@  discard block
 block discarded – undo
3814 3814
     
3815 3815
 		if ($globalIVAO && $aircraft_icao != '')
3816 3816
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
3817
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
+					else $airline_icao = '';
3819 3819
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
@@ -3846,53 +3846,53 @@  discard block
 block discarded – undo
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
3849
-                        $airline_array = $this->getAllAirlineInfo('NA');
3850
-                }
3851
-                if (count($aircraft_array) == 0) 
3852
-                {
3853
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3854
-                }
3855
-                if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
-                {
3857
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3858
-                }
3859
-                if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
-                {
3861
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3862
-                }
3863
-                if ($registration == '') $registration = 'NA';
3864
-                if ($latitude == '' && $longitude == '') {
3865
-            		$latitude = 0;
3866
-            		$longitude = 0;
3867
-            	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3849
+						$airline_array = $this->getAllAirlineInfo('NA');
3850
+				}
3851
+				if (count($aircraft_array) == 0) 
3852
+				{
3853
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3854
+				}
3855
+				if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
+				{
3857
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3858
+				}
3859
+				if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
+				{
3861
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3862
+				}
3863
+				if ($registration == '') $registration = 'NA';
3864
+				if ($latitude == '' && $longitude == '') {
3865
+					$latitude = 0;
3866
+					$longitude = 0;
3867
+				}
3868
+				if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
+				$query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3874 3874
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3875 3875
 
3876
-                $airline_name = $airline_array[0]['name'];
3877
-                $airline_icao = $airline_array[0]['icao'];
3878
-                $airline_country = $airline_array[0]['country'];
3879
-                $airline_type = $airline_array[0]['type'];
3876
+				$airline_name = $airline_array[0]['name'];
3877
+				$airline_icao = $airline_array[0]['icao'];
3878
+				$airline_country = $airline_array[0]['country'];
3879
+				$airline_type = $airline_array[0]['type'];
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883 3883
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3884 3884
 		}
3885 3885
 		if ($airline_type == null) $airline_type = '';
3886
-                $aircraft_type = $aircraft_array[0]['type'];
3887
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
-                $departure_airport_name = $departure_airport_array[0]['name'];
3889
-	        $departure_airport_city = $departure_airport_array[0]['city'];
3890
-            	$departure_airport_country = $departure_airport_array[0]['country'];
3886
+				$aircraft_type = $aircraft_array[0]['type'];
3887
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
+				$departure_airport_name = $departure_airport_array[0]['name'];
3889
+			$departure_airport_city = $departure_airport_array[0]['city'];
3890
+				$departure_airport_country = $departure_airport_array[0]['country'];
3891 3891
                 
3892
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3893
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3894
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3895
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3892
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3893
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3894
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3895
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3896 3896
 
3897 3897
 		try {
3898 3898
 		        
@@ -3900,7 +3900,7 @@  discard block
 block discarded – undo
3900 3900
 			$sth->execute($query_values);
3901 3901
 			$this->db = null;
3902 3902
 		} catch (PDOException $e) {
3903
-		    return "error : ".$e->getMessage();
3903
+			return "error : ".$e->getMessage();
3904 3904
 		}
3905 3905
 		
3906 3906
 		return "success";
@@ -3909,11 +3909,11 @@  discard block
 block discarded – undo
3909 3909
 	
3910 3910
   
3911 3911
 	/**
3912
-	* Gets the aircraft ident within the last hour
3913
-	*
3914
-	* @return String the ident
3915
-	*
3916
-	*/
3912
+	 * Gets the aircraft ident within the last hour
3913
+	 *
3914
+	 * @return String the ident
3915
+	 *
3916
+	 */
3917 3917
 	public function getIdentFromLastHour($ident)
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
@@ -3929,11 +3929,11 @@  discard block
 block discarded – undo
3929 3929
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3930 3930
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3931 3931
 			$query_data = array(':ident' => $ident);
3932
-    		}
3932
+			}
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3936
+			$ident_result='';
3937 3937
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
@@ -3944,11 +3944,11 @@  discard block
 block discarded – undo
3944 3944
 	
3945 3945
 	
3946 3946
 	/**
3947
-	* Gets the aircraft data from the last 20 seconds
3948
-	*
3949
-	* @return Array the spotter data
3950
-	*
3951
-	*/
3947
+	 * Gets the aircraft data from the last 20 seconds
3948
+	 *
3949
+	 * @return Array the spotter data
3950
+	 *
3951
+	 */
3952 3952
 	public function getRealTimeData($q = '')
3953 3953
 	{
3954 3954
 		global $globalDBdriver;
@@ -3992,11 +3992,11 @@  discard block
 block discarded – undo
3992 3992
 	
3993 3993
 	
3994 3994
 	 /**
3995
-	* Gets all airlines that have flown over
3996
-	*
3997
-	* @return Array the airline list
3998
-	*
3999
-	*/
3995
+	  * Gets all airlines that have flown over
3996
+	  *
3997
+	  * @return Array the airline list
3998
+	  *
3999
+	  */
4000 4000
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
@@ -4010,7 +4010,7 @@  discard block
 block discarded – undo
4010 4010
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4011 4011
 			}
4012 4012
 		}
4013
-                if ($sincedate != '') {
4013
+				if ($sincedate != '') {
4014 4014
 			if ($globalDBdriver == 'mysql') {
4015 4015
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4016 4016
 			} else {
@@ -4064,26 +4064,26 @@  discard block
 block discarded – undo
4064 4064
 	}
4065 4065
 
4066 4066
 	 /**
4067
-	* Gets all pilots that have flown over
4068
-	*
4069
-	* @return Array the pilots list
4070
-	*
4071
-	*/
4067
+	  * Gets all pilots that have flown over
4068
+	  *
4069
+	  * @return Array the pilots list
4070
+	  *
4071
+	  */
4072 4072
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075 4075
 		$filter_query = $this->getFilter($filters,true,true);
4076 4076
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4077 4077
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4078
-                if ($olderthanmonths > 0) {
4079
-            		if ($globalDBdriver == 'mysql') {
4078
+				if ($olderthanmonths > 0) {
4079
+					if ($globalDBdriver == 'mysql') {
4080 4080
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4081 4081
 			} else {
4082 4082
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4083 4083
 			}
4084 4084
 		}
4085
-                if ($sincedate != '') {
4086
-            		if ($globalDBdriver == 'mysql') {
4085
+				if ($sincedate != '') {
4086
+					if ($globalDBdriver == 'mysql') {
4087 4087
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4088 4088
 			} else {
4089 4089
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4138,25 +4138,25 @@  discard block
 block discarded – undo
4138 4138
 	}
4139 4139
 	
4140 4140
 	/**
4141
-	* Gets all pilots that have flown over
4142
-	*
4143
-	* @return Array the pilots list
4144
-	*
4145
-	*/
4141
+	 * Gets all pilots that have flown over
4142
+	 *
4143
+	 * @return Array the pilots list
4144
+	 *
4145
+	 */
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
4149 4149
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4150 4150
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4151
-                if ($olderthanmonths > 0) {
4152
-            		if ($globalDBdriver == 'mysql') {
4151
+				if ($olderthanmonths > 0) {
4152
+					if ($globalDBdriver == 'mysql') {
4153 4153
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4154 4154
 			} else {
4155 4155
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4156 4156
 			}
4157 4157
 		}
4158
-                if ($sincedate != '') {
4159
-            		if ($globalDBdriver == 'mysql') {
4158
+				if ($sincedate != '') {
4159
+					if ($globalDBdriver == 'mysql') {
4160 4160
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4161 4161
 			} else {
4162 4162
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4185,26 +4185,26 @@  discard block
 block discarded – undo
4185 4185
 	}
4186 4186
 	
4187 4187
 	 /**
4188
-	* Gets all owner that have flown over
4189
-	*
4190
-	* @return Array the pilots list
4191
-	*
4192
-	*/
4188
+	  * Gets all owner that have flown over
4189
+	  *
4190
+	  * @return Array the pilots list
4191
+	  *
4192
+	  */
4193 4193
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196 4196
 		$filter_query = $this->getFilter($filters,true,true);
4197 4197
 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4198 4198
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4199
-                if ($olderthanmonths > 0) {
4200
-            		if ($globalDBdriver == 'mysql') {
4199
+				if ($olderthanmonths > 0) {
4200
+					if ($globalDBdriver == 'mysql') {
4201 4201
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4202 4202
 			} else {
4203 4203
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4204 4204
 			}
4205 4205
 		}
4206
-                if ($sincedate != '') {
4207
-            		if ($globalDBdriver == 'mysql') {
4206
+				if ($sincedate != '') {
4207
+					if ($globalDBdriver == 'mysql') {
4208 4208
 				$query .= " AND spotter_output.date > '".$sincedate."' ";
4209 4209
 			} else {
4210 4210
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4255,26 +4255,26 @@  discard block
 block discarded – undo
4255 4255
 	}
4256 4256
 	
4257 4257
 	 /**
4258
-	* Gets all owner that have flown over
4259
-	*
4260
-	* @return Array the pilots list
4261
-	*
4262
-	*/
4258
+	  * Gets all owner that have flown over
4259
+	  *
4260
+	  * @return Array the pilots list
4261
+	  *
4262
+	  */
4263 4263
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266 4266
 		$filter_query = $this->getFilter($filters,true,true);
4267 4267
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4268 4268
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4269
-                if ($olderthanmonths > 0) {
4270
-            		if ($globalDBdriver == 'mysql') {
4269
+				if ($olderthanmonths > 0) {
4270
+					if ($globalDBdriver == 'mysql') {
4271 4271
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4272 4272
 			} else {
4273 4273
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4274 4274
 			}
4275 4275
 		}
4276
-                if ($sincedate != '') {
4277
-            		if ($globalDBdriver == 'mysql') {
4276
+				if ($sincedate != '') {
4277
+					if ($globalDBdriver == 'mysql') {
4278 4278
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4279 4279
 			} else {
4280 4280
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4301,11 +4301,11 @@  discard block
 block discarded – undo
4301 4301
 	}
4302 4302
 
4303 4303
 	/**
4304
-	* Gets all airlines that have flown over by aircraft
4305
-	*
4306
-	* @return Array the airline list
4307
-	*
4308
-	*/
4304
+	 * Gets all airlines that have flown over by aircraft
4305
+	 *
4306
+	 * @return Array the airline list
4307
+	 *
4308
+	 */
4309 4309
 	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4310 4310
 	{
4311 4311
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4337,11 +4337,11 @@  discard block
 block discarded – undo
4337 4337
 
4338 4338
 
4339 4339
 	/**
4340
-	* Gets all airline countries that have flown over by aircraft
4341
-	*
4342
-	* @return Array the airline country list
4343
-	*
4344
-	*/
4340
+	 * Gets all airline countries that have flown over by aircraft
4341
+	 *
4342
+	 * @return Array the airline country list
4343
+	 *
4344
+	 */
4345 4345
 	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4346 4346
 	{
4347 4347
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4373,11 +4373,11 @@  discard block
 block discarded – undo
4373 4373
 	
4374 4374
 	
4375 4375
 	/**
4376
-	* Gets all airlines that have flown over by airport
4377
-	*
4378
-	* @return Array the airline list
4379
-	*
4380
-	*/
4376
+	 * Gets all airlines that have flown over by airport
4377
+	 *
4378
+	 * @return Array the airline list
4379
+	 *
4380
+	 */
4381 4381
 	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4382 4382
 	{
4383 4383
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4408,11 +4408,11 @@  discard block
 block discarded – undo
4408 4408
 
4409 4409
 
4410 4410
 	/**
4411
-	* Gets all airline countries that have flown over by airport icao
4412
-	*
4413
-	* @return Array the airline country list
4414
-	*
4415
-	*/
4411
+	 * Gets all airline countries that have flown over by airport icao
4412
+	 *
4413
+	 * @return Array the airline country list
4414
+	 *
4415
+	 */
4416 4416
 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4417 4417
 	{
4418 4418
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4442,11 +4442,11 @@  discard block
 block discarded – undo
4442 4442
 
4443 4443
 
4444 4444
 	/**
4445
-	* Gets all airlines that have flown over by aircraft manufacturer
4446
-	*
4447
-	* @return Array the airline list
4448
-	*
4449
-	*/
4445
+	 * Gets all airlines that have flown over by aircraft manufacturer
4446
+	 *
4447
+	 * @return Array the airline list
4448
+	 *
4449
+	 */
4450 4450
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4451 4451
 	{
4452 4452
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4477,11 +4477,11 @@  discard block
 block discarded – undo
4477 4477
 
4478 4478
 
4479 4479
 	/**
4480
-	* Gets all airline countries that have flown over by aircraft manufacturer
4481
-	*
4482
-	* @return Array the airline country list
4483
-	*
4484
-	*/
4480
+	 * Gets all airline countries that have flown over by aircraft manufacturer
4481
+	 *
4482
+	 * @return Array the airline country list
4483
+	 *
4484
+	 */
4485 4485
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4486 4486
 	{
4487 4487
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4510,11 +4510,11 @@  discard block
 block discarded – undo
4510 4510
 
4511 4511
 
4512 4512
 	/**
4513
-	* Gets all airlines that have flown over by date
4514
-	*
4515
-	* @return Array the airline list
4516
-	*
4517
-	*/
4513
+	 * Gets all airlines that have flown over by date
4514
+	 *
4515
+	 * @return Array the airline list
4516
+	 *
4517
+	 */
4518 4518
 	public function countAllAirlinesByDate($date,$filters = array())
4519 4519
 	{
4520 4520
 		global $globalTimezone, $globalDBdriver;
@@ -4558,11 +4558,11 @@  discard block
 block discarded – undo
4558 4558
 	
4559 4559
 	
4560 4560
 	/**
4561
-	* Gets all airline countries that have flown over by date
4562
-	*
4563
-	* @return Array the airline country list
4564
-	*
4565
-	*/
4561
+	 * Gets all airline countries that have flown over by date
4562
+	 *
4563
+	 * @return Array the airline country list
4564
+	 *
4565
+	 */
4566 4566
 	public function countAllAirlineCountriesByDate($date,$filters = array())
4567 4567
 	{
4568 4568
 		global $globalTimezone, $globalDBdriver;
@@ -4605,11 +4605,11 @@  discard block
 block discarded – undo
4605 4605
 
4606 4606
 
4607 4607
 	/**
4608
-	* Gets all airlines that have flown over by ident/callsign
4609
-	*
4610
-	* @return Array the airline list
4611
-	*
4612
-	*/
4608
+	 * Gets all airlines that have flown over by ident/callsign
4609
+	 *
4610
+	 * @return Array the airline list
4611
+	 *
4612
+	 */
4613 4613
 	public function countAllAirlinesByIdent($ident,$filters = array())
4614 4614
 	{
4615 4615
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4626,11 +4626,11 @@  discard block
 block discarded – undo
4626 4626
 	}
4627 4627
 
4628 4628
 	/**
4629
-	* Gets all airlines by owner
4630
-	*
4631
-	* @return Array the airline list
4632
-	*
4633
-	*/
4629
+	 * Gets all airlines by owner
4630
+	 *
4631
+	 * @return Array the airline list
4632
+	 *
4633
+	 */
4634 4634
 	public function countAllAirlinesByOwner($owner,$filters = array())
4635 4635
 	{
4636 4636
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4647,11 +4647,11 @@  discard block
 block discarded – undo
4647 4647
 	}
4648 4648
 
4649 4649
 	/**
4650
-	* Gets flight duration by owner
4651
-	*
4652
-	* @return String Duration of all flights
4653
-	*
4654
-	*/
4650
+	 * Gets flight duration by owner
4651
+	 *
4652
+	 * @return String Duration of all flights
4653
+	 *
4654
+	 */
4655 4655
 	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4656 4656
 	{
4657 4657
 		global $globalDBdriver;
@@ -4698,11 +4698,11 @@  discard block
 block discarded – undo
4698 4698
 	}
4699 4699
 
4700 4700
 	/**
4701
-	* Count flights by owner
4702
-	*
4703
-	* @return String Duration of all flights
4704
-	*
4705
-	*/
4701
+	 * Count flights by owner
4702
+	 *
4703
+	 * @return String Duration of all flights
4704
+	 *
4705
+	 */
4706 4706
 	public function countFlightsByOwner($owner,$filters = array())
4707 4707
 	{
4708 4708
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4718,11 +4718,11 @@  discard block
 block discarded – undo
4718 4718
 	}
4719 4719
 
4720 4720
 	/**
4721
-	* Count flights by pilot
4722
-	*
4723
-	* @return String Duration of all flights
4724
-	*
4725
-	*/
4721
+	 * Count flights by pilot
4722
+	 *
4723
+	 * @return String Duration of all flights
4724
+	 *
4725
+	 */
4726 4726
 	public function countFlightsByPilot($pilot,$filters = array())
4727 4727
 	{
4728 4728
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4738,11 +4738,11 @@  discard block
 block discarded – undo
4738 4738
 	}
4739 4739
 
4740 4740
 	/**
4741
-	* Gets flight duration by pilot
4742
-	*
4743
-	* @return String Duration of all flights
4744
-	*
4745
-	*/
4741
+	 * Gets flight duration by pilot
4742
+	 *
4743
+	 * @return String Duration of all flights
4744
+	 *
4745
+	 */
4746 4746
 	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4747 4747
 	{
4748 4748
 		global $globalDBdriver;
@@ -4788,11 +4788,11 @@  discard block
 block discarded – undo
4788 4788
 	}
4789 4789
 
4790 4790
 	/**
4791
-	* Gets all airlines used by pilot
4792
-	*
4793
-	* @return Array the airline list
4794
-	*
4795
-	*/
4791
+	 * Gets all airlines used by pilot
4792
+	 *
4793
+	 * @return Array the airline list
4794
+	 *
4795
+	 */
4796 4796
 	public function countAllAirlinesByPilot($pilot,$filters = array())
4797 4797
 	{
4798 4798
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4809,11 +4809,11 @@  discard block
 block discarded – undo
4809 4809
 	}
4810 4810
 
4811 4811
 	/**
4812
-	* Gets all airlines that have flown over by route
4813
-	*
4814
-	* @return Array the airline list
4815
-	*
4816
-	*/
4812
+	 * Gets all airlines that have flown over by route
4813
+	 *
4814
+	 * @return Array the airline list
4815
+	 *
4816
+	 */
4817 4817
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4818 4818
 	{
4819 4819
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4845,11 +4845,11 @@  discard block
 block discarded – undo
4845 4845
 	}
4846 4846
 
4847 4847
 	/**
4848
-	* Gets all airline countries that have flown over by route
4849
-	*
4850
-	* @return Array the airline country list
4851
-	*
4852
-	*/
4848
+	 * Gets all airline countries that have flown over by route
4849
+	 *
4850
+	 * @return Array the airline country list
4851
+	 *
4852
+	 */
4853 4853
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4854 4854
 	{
4855 4855
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
 
4882 4882
 
4883 4883
 	/**
4884
-	* Gets all airlines that have flown over by country
4885
-	*
4886
-	* @return Array the airline list
4887
-	*
4888
-	*/
4884
+	 * Gets all airlines that have flown over by country
4885
+	 *
4886
+	 * @return Array the airline list
4887
+	 *
4888
+	 */
4889 4889
 	public function countAllAirlinesByCountry($country,$filters = array())
4890 4890
 	{
4891 4891
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4915,11 +4915,11 @@  discard block
 block discarded – undo
4915 4915
 
4916 4916
 
4917 4917
 	/**
4918
-	* Gets all airline countries that have flown over by country
4919
-	*
4920
-	* @return Array the airline country list
4921
-	*
4922
-	*/
4918
+	 * Gets all airline countries that have flown over by country
4919
+	 *
4920
+	 * @return Array the airline country list
4921
+	 *
4922
+	 */
4923 4923
 	public function countAllAirlineCountriesByCountry($country,$filters = array())
4924 4924
 	{
4925 4925
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4948,11 +4948,11 @@  discard block
 block discarded – undo
4948 4948
 
4949 4949
 
4950 4950
 	/**
4951
-	* Gets all airlines countries
4952
-	*
4953
-	* @return Array the airline country list
4954
-	*
4955
-	*/
4951
+	 * Gets all airlines countries
4952
+	 *
4953
+	 * @return Array the airline country list
4954
+	 *
4955
+	 */
4956 4956
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4957 4957
 	{
4958 4958
 		global $globalDBdriver;
@@ -5007,11 +5007,11 @@  discard block
 block discarded – undo
5007 5007
 	}
5008 5008
 
5009 5009
 	/**
5010
-	* Gets all number of flight over countries
5011
-	*
5012
-	* @return Array the airline country list
5013
-	*
5014
-	*/
5010
+	 * Gets all number of flight over countries
5011
+	 *
5012
+	 * @return Array the airline country list
5013
+	 *
5014
+	 */
5015 5015
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5016 5016
 	{
5017 5017
 		global $globalDBdriver;
@@ -5033,15 +5033,15 @@  discard block
 block discarded – undo
5033 5033
 		$SpotterLive = new SpotterLive();
5034 5034
 		$filter_query = $SpotterLive->getFilter($filters,true,true);
5035 5035
 		$filter_query .= ' over_country IS NOT NULL';
5036
-                if ($olderthanmonths > 0) {
5036
+				if ($olderthanmonths > 0) {
5037 5037
 			if ($globalDBdriver == 'mysql') {
5038 5038
 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5039 5039
 			} else {
5040 5040
 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5041 5041
 			}
5042 5042
 		}
5043
-                if ($sincedate != '') {
5044
-            		if ($globalDBdriver == 'mysql') {
5043
+				if ($sincedate != '') {
5044
+					if ($globalDBdriver == 'mysql') {
5045 5045
 				$filter_query .= " AND spotter_live.date > '".$sincedate."' ";
5046 5046
 			} else {
5047 5047
 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5071,11 +5071,11 @@  discard block
 block discarded – undo
5071 5071
 	
5072 5072
 	
5073 5073
 	/**
5074
-	* Gets all aircraft types that have flown over
5075
-	*
5076
-	* @return Array the aircraft list
5077
-	*
5078
-	*/
5074
+	 * Gets all aircraft types that have flown over
5075
+	 *
5076
+	 * @return Array the aircraft list
5077
+	 *
5078
+	 */
5079 5079
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5080 5080
 	{
5081 5081
 		global $globalDBdriver;
@@ -5145,11 +5145,11 @@  discard block
 block discarded – undo
5145 5145
 	}
5146 5146
 
5147 5147
 	/**
5148
-	* Gets all aircraft types that have flown over by airline
5149
-	*
5150
-	* @return Array the aircraft list
5151
-	*
5152
-	*/
5148
+	 * Gets all aircraft types that have flown over by airline
5149
+	 *
5150
+	 * @return Array the aircraft list
5151
+	 *
5152
+	 */
5153 5153
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5154 5154
 	{
5155 5155
 		global $globalDBdriver;
@@ -5220,11 +5220,11 @@  discard block
 block discarded – undo
5220 5220
 	}
5221 5221
 
5222 5222
 	/**
5223
-	* Gets all aircraft types that have flown over by months
5224
-	*
5225
-	* @return Array the aircraft list
5226
-	*
5227
-	*/
5223
+	 * Gets all aircraft types that have flown over by months
5224
+	 *
5225
+	 * @return Array the aircraft list
5226
+	 *
5227
+	 */
5228 5228
 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5229 5229
 	{
5230 5230
 		global $globalDBdriver;
@@ -5268,11 +5268,11 @@  discard block
 block discarded – undo
5268 5268
 
5269 5269
 
5270 5270
 	/**
5271
-	* Gets all aircraft registration that have flown over by aircaft icao
5272
-	*
5273
-	* @return Array the aircraft list
5274
-	*
5275
-	*/
5271
+	 * Gets all aircraft registration that have flown over by aircaft icao
5272
+	 *
5273
+	 * @return Array the aircraft list
5274
+	 *
5275
+	 */
5276 5276
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5277 5277
 	{
5278 5278
 		$Image = new Image($this->db);
@@ -5311,11 +5311,11 @@  discard block
 block discarded – undo
5311 5311
 
5312 5312
 
5313 5313
 	/**
5314
-	* Gets all aircraft types that have flown over by airline icao
5315
-	*
5316
-	* @return Array the aircraft list
5317
-	*
5318
-	*/
5314
+	 * Gets all aircraft types that have flown over by airline icao
5315
+	 *
5316
+	 * @return Array the aircraft list
5317
+	 *
5318
+	 */
5319 5319
 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5320 5320
 	{
5321 5321
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5344,11 +5344,11 @@  discard block
 block discarded – undo
5344 5344
 
5345 5345
 
5346 5346
 	/**
5347
-	* Gets all aircraft registration that have flown over by airline icao
5348
-	*
5349
-	* @return Array the aircraft list
5350
-	*
5351
-	*/
5347
+	 * Gets all aircraft registration that have flown over by airline icao
5348
+	 *
5349
+	 * @return Array the aircraft list
5350
+	 *
5351
+	 */
5352 5352
 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5353 5353
 	{
5354 5354
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5386,11 +5386,11 @@  discard block
 block discarded – undo
5386 5386
 
5387 5387
 
5388 5388
 	/**
5389
-	* Gets all aircraft manufacturer that have flown over by airline icao
5390
-	*
5391
-	* @return Array the aircraft list
5392
-	*
5393
-	*/
5389
+	 * Gets all aircraft manufacturer that have flown over by airline icao
5390
+	 *
5391
+	 * @return Array the aircraft list
5392
+	 *
5393
+	 */
5394 5394
 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5395 5395
 	{
5396 5396
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5418,11 +5418,11 @@  discard block
 block discarded – undo
5418 5418
 
5419 5419
 
5420 5420
 	/**
5421
-	* Gets all aircraft types that have flown over by airline icao
5422
-	*
5423
-	* @return Array the aircraft list
5424
-	*
5425
-	*/
5421
+	 * Gets all aircraft types that have flown over by airline icao
5422
+	 *
5423
+	 * @return Array the aircraft list
5424
+	 *
5425
+	 */
5426 5426
 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5427 5427
 	{
5428 5428
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5451,11 +5451,11 @@  discard block
 block discarded – undo
5451 5451
 
5452 5452
 
5453 5453
 	/**
5454
-	* Gets all aircraft registration that have flown over by airport icao
5455
-	*
5456
-	* @return Array the aircraft list
5457
-	*
5458
-	*/
5454
+	 * Gets all aircraft registration that have flown over by airport icao
5455
+	 *
5456
+	 * @return Array the aircraft list
5457
+	 *
5458
+	 */
5459 5459
 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5460 5460
 	{
5461 5461
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5492,11 +5492,11 @@  discard block
 block discarded – undo
5492 5492
 	
5493 5493
 	
5494 5494
 	/**
5495
-	* Gets all aircraft manufacturer that have flown over by airport icao
5496
-	*
5497
-	* @return Array the aircraft list
5498
-	*
5499
-	*/
5495
+	 * Gets all aircraft manufacturer that have flown over by airport icao
5496
+	 *
5497
+	 * @return Array the aircraft list
5498
+	 *
5499
+	 */
5500 5500
 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5501 5501
 	{
5502 5502
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5522,11 +5522,11 @@  discard block
 block discarded – undo
5522 5522
 	}
5523 5523
 
5524 5524
 	/**
5525
-	* Gets all aircraft types that have flown over by aircraft manufacturer
5526
-	*
5527
-	* @return Array the aircraft list
5528
-	*
5529
-	*/
5525
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
5526
+	 *
5527
+	 * @return Array the aircraft list
5528
+	 *
5529
+	 */
5530 5530
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5531 5531
 	{
5532 5532
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5553,11 +5553,11 @@  discard block
 block discarded – undo
5553 5553
 
5554 5554
 
5555 5555
 	/**
5556
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
5557
-	*
5558
-	* @return Array the aircraft list
5559
-	*
5560
-	*/
5556
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
5557
+	 *
5558
+	 * @return Array the aircraft list
5559
+	 *
5560
+	 */
5561 5561
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5562 5562
 	{
5563 5563
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5593,11 +5593,11 @@  discard block
 block discarded – undo
5593 5593
 	}
5594 5594
 
5595 5595
 	/**
5596
-	* Gets all aircraft types that have flown over by date
5597
-	*
5598
-	* @return Array the aircraft list
5599
-	*
5600
-	*/
5596
+	 * Gets all aircraft types that have flown over by date
5597
+	 *
5598
+	 * @return Array the aircraft list
5599
+	 *
5600
+	 */
5601 5601
 	public function countAllAircraftTypesByDate($date,$filters = array())
5602 5602
 	{
5603 5603
 		global $globalTimezone, $globalDBdriver;
@@ -5639,11 +5639,11 @@  discard block
 block discarded – undo
5639 5639
 
5640 5640
 
5641 5641
 	/**
5642
-	* Gets all aircraft registration that have flown over by date
5643
-	*
5644
-	* @return Array the aircraft list
5645
-	*
5646
-	*/
5642
+	 * Gets all aircraft registration that have flown over by date
5643
+	 *
5644
+	 * @return Array the aircraft list
5645
+	 *
5646
+	 */
5647 5647
 	public function countAllAircraftRegistrationByDate($date,$filters = array())
5648 5648
 	{
5649 5649
 		global $globalTimezone, $globalDBdriver;
@@ -5694,11 +5694,11 @@  discard block
 block discarded – undo
5694 5694
 
5695 5695
 
5696 5696
 	/**
5697
-	* Gets all aircraft manufacturer that have flown over by date
5698
-	*
5699
-	* @return Array the aircraft manufacturer list
5700
-	*
5701
-	*/
5697
+	 * Gets all aircraft manufacturer that have flown over by date
5698
+	 *
5699
+	 * @return Array the aircraft manufacturer list
5700
+	 *
5701
+	 */
5702 5702
 	public function countAllAircraftManufacturerByDate($date,$filters = array())
5703 5703
 	{
5704 5704
 		global $globalTimezone, $globalDBdriver;
@@ -5740,11 +5740,11 @@  discard block
 block discarded – undo
5740 5740
 
5741 5741
 
5742 5742
 	/**
5743
-	* Gets all aircraft types that have flown over by ident/callsign
5744
-	*
5745
-	* @return Array the aircraft list
5746
-	*
5747
-	*/
5743
+	 * Gets all aircraft types that have flown over by ident/callsign
5744
+	 *
5745
+	 * @return Array the aircraft list
5746
+	 *
5747
+	 */
5748 5748
 	public function countAllAircraftTypesByIdent($ident,$filters = array())
5749 5749
 	{
5750 5750
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5772,11 +5772,11 @@  discard block
 block discarded – undo
5772 5772
 	}
5773 5773
 
5774 5774
 	/**
5775
-	* Gets all aircraft types that have flown over by pilot
5776
-	*
5777
-	* @return Array the aircraft list
5778
-	*
5779
-	*/
5775
+	 * Gets all aircraft types that have flown over by pilot
5776
+	 *
5777
+	 * @return Array the aircraft list
5778
+	 *
5779
+	 */
5780 5780
 	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5781 5781
 	{
5782 5782
 		global $globalDBdriver;
@@ -5822,11 +5822,11 @@  discard block
 block discarded – undo
5822 5822
 	}
5823 5823
 
5824 5824
 	/**
5825
-	* Gets all aircraft types that have flown over by owner
5826
-	*
5827
-	* @return Array the aircraft list
5828
-	*
5829
-	*/
5825
+	 * Gets all aircraft types that have flown over by owner
5826
+	 *
5827
+	 * @return Array the aircraft list
5828
+	 *
5829
+	 */
5830 5830
 	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5831 5831
 	{
5832 5832
 		global $globalDBdriver;
@@ -5871,11 +5871,11 @@  discard block
 block discarded – undo
5871 5871
 	}
5872 5872
 
5873 5873
 	/**
5874
-	* Gets all aircraft registration that have flown over by ident/callsign
5875
-	*
5876
-	* @return Array the aircraft list
5877
-	*
5878
-	*/
5874
+	 * Gets all aircraft registration that have flown over by ident/callsign
5875
+	 *
5876
+	 * @return Array the aircraft list
5877
+	 *
5878
+	 */
5879 5879
 	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5880 5880
 	{
5881 5881
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5914,11 +5914,11 @@  discard block
 block discarded – undo
5914 5914
 	}
5915 5915
 
5916 5916
 	/**
5917
-	* Gets all aircraft registration that have flown over by owner
5918
-	*
5919
-	* @return Array the aircraft list
5920
-	*
5921
-	*/
5917
+	 * Gets all aircraft registration that have flown over by owner
5918
+	 *
5919
+	 * @return Array the aircraft list
5920
+	 *
5921
+	 */
5922 5922
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5923 5923
 	{
5924 5924
 		global $globalDBdriver;
@@ -5989,11 +5989,11 @@  discard block
 block discarded – undo
5989 5989
 	}
5990 5990
 
5991 5991
 	/**
5992
-	* Gets all aircraft registration that have flown over by pilot
5993
-	*
5994
-	* @return Array the aircraft list
5995
-	*
5996
-	*/
5992
+	 * Gets all aircraft registration that have flown over by pilot
5993
+	 *
5994
+	 * @return Array the aircraft list
5995
+	 *
5996
+	 */
5997 5997
 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5998 5998
 	{
5999 5999
 		global $globalDBdriver;
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
 
6066 6066
 
6067 6067
 	/**
6068
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
6069
-	*
6070
-	* @return Array the aircraft manufacturer list
6071
-	*
6072
-	*/
6068
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
6069
+	 *
6070
+	 * @return Array the aircraft manufacturer list
6071
+	 *
6072
+	 */
6073 6073
 	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6074 6074
 	{
6075 6075
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6094,11 +6094,11 @@  discard block
 block discarded – undo
6094 6094
 	}
6095 6095
 
6096 6096
 	/**
6097
-	* Gets all aircraft manufacturer that have flown over by owner
6098
-	*
6099
-	* @return Array the aircraft manufacturer list
6100
-	*
6101
-	*/
6097
+	 * Gets all aircraft manufacturer that have flown over by owner
6098
+	 *
6099
+	 * @return Array the aircraft manufacturer list
6100
+	 *
6101
+	 */
6102 6102
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6103 6103
 	{
6104 6104
 		global $globalDBdriver;
@@ -6146,11 +6146,11 @@  discard block
 block discarded – undo
6146 6146
 	}
6147 6147
 
6148 6148
 	/**
6149
-	* Gets all aircraft manufacturer that have flown over by pilot
6150
-	*
6151
-	* @return Array the aircraft manufacturer list
6152
-	*
6153
-	*/
6149
+	 * Gets all aircraft manufacturer that have flown over by pilot
6150
+	 *
6151
+	 * @return Array the aircraft manufacturer list
6152
+	 *
6153
+	 */
6154 6154
 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6155 6155
 	{
6156 6156
 		global $globalDBdriver;
@@ -6199,11 +6199,11 @@  discard block
 block discarded – undo
6199 6199
 
6200 6200
 
6201 6201
 	/**
6202
-	* Gets all aircraft types that have flown over by route
6203
-	*
6204
-	* @return Array the aircraft list
6205
-	*
6206
-	*/
6202
+	 * Gets all aircraft types that have flown over by route
6203
+	 *
6204
+	 * @return Array the aircraft list
6205
+	 *
6206
+	 */
6207 6207
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6208 6208
 	{
6209 6209
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6232,11 +6232,11 @@  discard block
 block discarded – undo
6232 6232
 	}
6233 6233
 
6234 6234
 	/**
6235
-	* Gets all aircraft registration that have flown over by route
6236
-	*
6237
-	* @return Array the aircraft list
6238
-	*
6239
-	*/
6235
+	 * Gets all aircraft registration that have flown over by route
6236
+	 *
6237
+	 * @return Array the aircraft list
6238
+	 *
6239
+	 */
6240 6240
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6241 6241
 	{
6242 6242
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6278,11 +6278,11 @@  discard block
 block discarded – undo
6278 6278
 	
6279 6279
 	
6280 6280
 	/**
6281
-	* Gets all aircraft manufacturer that have flown over by route
6282
-	*
6283
-	* @return Array the aircraft manufacturer list
6284
-	*
6285
-	*/
6281
+	 * Gets all aircraft manufacturer that have flown over by route
6282
+	 *
6283
+	 * @return Array the aircraft manufacturer list
6284
+	 *
6285
+	 */
6286 6286
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6287 6287
 	{
6288 6288
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6316,11 +6316,11 @@  discard block
 block discarded – undo
6316 6316
 	
6317 6317
 	
6318 6318
 	/**
6319
-	* Gets all aircraft types that have flown over by country
6320
-	*
6321
-	* @return Array the aircraft list
6322
-	*
6323
-	*/
6319
+	 * Gets all aircraft types that have flown over by country
6320
+	 *
6321
+	 * @return Array the aircraft list
6322
+	 *
6323
+	 */
6324 6324
 	public function countAllAircraftTypesByCountry($country,$filters = array())
6325 6325
 	{
6326 6326
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6351,11 +6351,11 @@  discard block
 block discarded – undo
6351 6351
 
6352 6352
 
6353 6353
 	/**
6354
-	* Gets all aircraft registration that have flown over by country
6355
-	*
6356
-	* @return Array the aircraft list
6357
-	*
6358
-	*/
6354
+	 * Gets all aircraft registration that have flown over by country
6355
+	 *
6356
+	 * @return Array the aircraft list
6357
+	 *
6358
+	 */
6359 6359
 	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6360 6360
 	{
6361 6361
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6395,11 +6395,11 @@  discard block
 block discarded – undo
6395 6395
 	
6396 6396
 	
6397 6397
 	/**
6398
-	* Gets all aircraft manufacturer that have flown over by country
6399
-	*
6400
-	* @return Array the aircraft manufacturer list
6401
-	*
6402
-	*/
6398
+	 * Gets all aircraft manufacturer that have flown over by country
6399
+	 *
6400
+	 * @return Array the aircraft manufacturer list
6401
+	 *
6402
+	 */
6403 6403
 	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6404 6404
 	{
6405 6405
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6430,18 +6430,18 @@  discard block
 block discarded – undo
6430 6430
 	
6431 6431
 	
6432 6432
 	/**
6433
-	* Gets all aircraft manufacturers that have flown over
6434
-	*
6435
-	* @return Array the aircraft list
6436
-	*
6437
-	*/
6433
+	 * Gets all aircraft manufacturers that have flown over
6434
+	 *
6435
+	 * @return Array the aircraft list
6436
+	 *
6437
+	 */
6438 6438
 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6439 6439
 	{
6440 6440
 		global $globalDBdriver;
6441 6441
 		$filter_query = $this->getFilter($filters,true,true);
6442 6442
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443 6443
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6444
-                $query_values = array();
6444
+				$query_values = array();
6445 6445
 		if ($year != '') {
6446 6446
 			if ($globalDBdriver == 'mysql') {
6447 6447
 				$query .= " AND YEAR(spotter_output.date) = :year";
@@ -6494,11 +6494,11 @@  discard block
 block discarded – undo
6494 6494
 	
6495 6495
 	
6496 6496
 	/**
6497
-	* Gets all aircraft registrations that have flown over
6498
-	*
6499
-	* @return Array the aircraft list
6500
-	*
6501
-	*/
6497
+	 * Gets all aircraft registrations that have flown over
6498
+	 *
6499
+	 * @return Array the aircraft list
6500
+	 *
6501
+	 */
6502 6502
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6503 6503
 	{
6504 6504
 		global $globalDBdriver;
@@ -6506,15 +6506,15 @@  discard block
 block discarded – undo
6506 6506
 		$filter_query = $this->getFilter($filters,true,true);
6507 6507
 		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6508 6508
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6509
-                if ($olderthanmonths > 0) {
6510
-            		if ($globalDBdriver == 'mysql') {
6509
+				if ($olderthanmonths > 0) {
6510
+					if ($globalDBdriver == 'mysql') {
6511 6511
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6512 6512
 			} else {
6513 6513
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6514 6514
 			}
6515 6515
 		}
6516
-                if ($sincedate != '') {
6517
-            		if ($globalDBdriver == 'mysql') {
6516
+				if ($sincedate != '') {
6517
+					if ($globalDBdriver == 'mysql') {
6518 6518
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6519 6519
 			} else {
6520 6520
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6579,11 +6579,11 @@  discard block
 block discarded – undo
6579 6579
 
6580 6580
 
6581 6581
 	/**
6582
-	* Gets all aircraft registrations that have flown over
6583
-	*
6584
-	* @return Array the aircraft list
6585
-	*
6586
-	*/
6582
+	 * Gets all aircraft registrations that have flown over
6583
+	 *
6584
+	 * @return Array the aircraft list
6585
+	 *
6586
+	 */
6587 6587
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6588 6588
 	{
6589 6589
 		global $globalDBdriver;
@@ -6591,15 +6591,15 @@  discard block
 block discarded – undo
6591 6591
 		$Image = new Image($this->db);
6592 6592
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6593 6593
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6594
-                if ($olderthanmonths > 0) {
6595
-            		if ($globalDBdriver == 'mysql') {
6594
+				if ($olderthanmonths > 0) {
6595
+					if ($globalDBdriver == 'mysql') {
6596 6596
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6597 6597
 			} else {
6598 6598
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6599 6599
 			}
6600 6600
 		}
6601
-                if ($sincedate != '') {
6602
-            		if ($globalDBdriver == 'mysql') {
6601
+				if ($sincedate != '') {
6602
+					if ($globalDBdriver == 'mysql') {
6603 6603
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6604 6604
 			} else {
6605 6605
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6608,7 +6608,7 @@  discard block
 block discarded – undo
6608 6608
 
6609 6609
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6610
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6611
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6612 6612
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6613 6613
 		
6614 6614
 		$sth = $this->db->prepare($query);
@@ -6640,26 +6640,26 @@  discard block
 block discarded – undo
6640 6640
 	
6641 6641
 	
6642 6642
 	/**
6643
-	* Gets all departure airports of the airplanes that have flown over
6644
-	*
6645
-	* @return Array the airport list
6646
-	*
6647
-	*/
6643
+	 * Gets all departure airports of the airplanes that have flown over
6644
+	 *
6645
+	 * @return Array the airport list
6646
+	 *
6647
+	 */
6648 6648
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6649 6649
 	{
6650 6650
 		global $globalDBdriver;
6651 6651
 		$filter_query = $this->getFilter($filters,true,true);
6652 6652
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6653 6653
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6654
-                if ($olderthanmonths > 0) {
6655
-            		if ($globalDBdriver == 'mysql') {
6654
+				if ($olderthanmonths > 0) {
6655
+					if ($globalDBdriver == 'mysql') {
6656 6656
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6657 6657
 			} else {
6658 6658
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6659 6659
 			}
6660
-                }
6661
-                if ($sincedate != '') {
6662
-            		if ($globalDBdriver == 'mysql') {
6660
+				}
6661
+				if ($sincedate != '') {
6662
+					if ($globalDBdriver == 'mysql') {
6663 6663
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6664 6664
 			} else {
6665 6665
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
 				$query_values = array_merge($query_values,array(':day' => $day));
6694 6694
 			}
6695 6695
 		}
6696
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6696
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 6697
 				ORDER BY airport_departure_icao_count DESC";
6698 6698
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6699 6699
 
@@ -6716,35 +6716,35 @@  discard block
 block discarded – undo
6716 6716
 	}
6717 6717
 
6718 6718
 	/**
6719
-	* Gets all departure airports of the airplanes that have flown over
6720
-	*
6721
-	* @return Array the airport list
6722
-	*
6723
-	*/
6719
+	 * Gets all departure airports of the airplanes that have flown over
6720
+	 *
6721
+	 * @return Array the airport list
6722
+	 *
6723
+	 */
6724 6724
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6725 6725
 	{
6726 6726
 		global $globalDBdriver;
6727 6727
 		$filter_query = $this->getFilter($filters,true,true);
6728 6728
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6729 6729
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6730
-                if ($olderthanmonths > 0) {
6731
-            		if ($globalDBdriver == 'mysql') {
6730
+				if ($olderthanmonths > 0) {
6731
+					if ($globalDBdriver == 'mysql') {
6732 6732
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6733 6733
 			} else {
6734 6734
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6735 6735
 			}
6736
-                }
6737
-                if ($sincedate != '') {
6738
-            		if ($globalDBdriver == 'mysql') {
6736
+				}
6737
+				if ($sincedate != '') {
6738
+					if ($globalDBdriver == 'mysql') {
6739 6739
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6740 6740
 			} else {
6741 6741
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6742 6742
 			}
6743 6743
 		}
6744 6744
 
6745
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6745
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6748 6748
 				ORDER BY airport_departure_icao_count DESC";
6749 6749
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6750 6750
       
@@ -6769,26 +6769,26 @@  discard block
 block discarded – undo
6769 6769
 	}
6770 6770
 
6771 6771
 	/**
6772
-	* Gets all detected departure airports of the airplanes that have flown over
6773
-	*
6774
-	* @return Array the airport list
6775
-	*
6776
-	*/
6772
+	 * Gets all detected departure airports of the airplanes that have flown over
6773
+	 *
6774
+	 * @return Array the airport list
6775
+	 *
6776
+	 */
6777 6777
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6778 6778
 	{
6779 6779
 		global $globalDBdriver;
6780 6780
 		$filter_query = $this->getFilter($filters,true,true);
6781 6781
 		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6782 6782
 				FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao";
6783
-                if ($olderthanmonths > 0) {
6784
-            		if ($globalDBdriver == 'mysql') {
6783
+				if ($olderthanmonths > 0) {
6784
+					if ($globalDBdriver == 'mysql') {
6785 6785
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6786 6786
 			} else {
6787 6787
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6788 6788
 			}
6789
-                }
6790
-                if ($sincedate != '') {
6791
-            		if ($globalDBdriver == 'mysql') {
6789
+				}
6790
+				if ($sincedate != '') {
6791
+					if ($globalDBdriver == 'mysql') {
6792 6792
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6793 6793
 			} else {
6794 6794
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6822,10 +6822,10 @@  discard block
 block discarded – undo
6822 6822
 				$query_values = array_merge($query_values,array(':day' => $day));
6823 6823
 			}
6824 6824
 		}
6825
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6825
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 6826
 				ORDER BY airport_departure_icao_count DESC";
6827 6827
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6828
-    		//echo $query;
6828
+			//echo $query;
6829 6829
 		$sth = $this->db->prepare($query);
6830 6830
 		$sth->execute($query_values);
6831 6831
       
@@ -6846,35 +6846,35 @@  discard block
 block discarded – undo
6846 6846
 	}
6847 6847
 	
6848 6848
 	/**
6849
-	* Gets all detected departure airports of the airplanes that have flown over
6850
-	*
6851
-	* @return Array the airport list
6852
-	*
6853
-	*/
6849
+	 * Gets all detected departure airports of the airplanes that have flown over
6850
+	 *
6851
+	 * @return Array the airport list
6852
+	 *
6853
+	 */
6854 6854
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6855 6855
 	{
6856 6856
 		global $globalDBdriver;
6857 6857
 		$filter_query = $this->getFilter($filters,true,true);
6858 6858
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6859 6859
 				FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
6860
-                if ($olderthanmonths > 0) {
6861
-            		if ($globalDBdriver == 'mysql') {
6860
+				if ($olderthanmonths > 0) {
6861
+					if ($globalDBdriver == 'mysql') {
6862 6862
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6863 6863
 			} else {
6864 6864
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6865 6865
 			}
6866
-                }
6867
-                if ($sincedate != '') {
6868
-            		if ($globalDBdriver == 'mysql') {
6866
+				}
6867
+				if ($sincedate != '') {
6868
+					if ($globalDBdriver == 'mysql') {
6869 6869
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6870 6870
 			} else {
6871 6871
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
6872 6872
 			}
6873 6873
 		}
6874 6874
 
6875
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6875
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 6878
 				ORDER BY airport_departure_icao_count DESC";
6879 6879
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6880 6880
       
@@ -6899,11 +6899,11 @@  discard block
 block discarded – undo
6899 6899
 	}	
6900 6900
 	
6901 6901
 	/**
6902
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
-	*
6904
-	* @return Array the airport list
6905
-	*
6906
-	*/
6902
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
+	 *
6904
+	 * @return Array the airport list
6905
+	 *
6906
+	 */
6907 6907
 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6908 6908
 	{
6909 6909
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6937,11 +6937,11 @@  discard block
 block discarded – undo
6937 6937
 	
6938 6938
 	
6939 6939
 	/**
6940
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
-	*
6942
-	* @return Array the airport list
6943
-	*
6944
-	*/
6940
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
+	 *
6942
+	 * @return Array the airport list
6943
+	 *
6944
+	 */
6945 6945
 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6946 6946
 	{
6947 6947
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6972,11 +6972,11 @@  discard block
 block discarded – undo
6972 6972
 	
6973 6973
 	
6974 6974
 	/**
6975
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
-	*
6977
-	* @return Array the airport list
6978
-	*
6979
-	*/
6975
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
+	 *
6977
+	 * @return Array the airport list
6978
+	 *
6979
+	 */
6980 6980
 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6981 6981
 	{
6982 6982
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7009,11 +7009,11 @@  discard block
 block discarded – undo
7009 7009
 	
7010 7010
 	
7011 7011
 	/**
7012
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
-	*
7014
-	* @return Array the airport list
7015
-	*
7016
-	*/
7012
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
+	 *
7014
+	 * @return Array the airport list
7015
+	 *
7016
+	 */
7017 7017
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7018 7018
 	{
7019 7019
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7043,11 +7043,11 @@  discard block
 block discarded – undo
7043 7043
 	
7044 7044
 	
7045 7045
 	/**
7046
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
-	*
7048
-	* @return Array the airport list
7049
-	*
7050
-	*/
7046
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
+	 *
7048
+	 * @return Array the airport list
7049
+	 *
7050
+	 */
7051 7051
 	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7052 7052
 	{
7053 7053
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7080,11 +7080,11 @@  discard block
 block discarded – undo
7080 7080
 	
7081 7081
 	
7082 7082
 	/**
7083
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
-	*
7085
-	* @return Array the airport list
7086
-	*
7087
-	*/
7083
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
+	 *
7085
+	 * @return Array the airport list
7086
+	 *
7087
+	 */
7088 7088
 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7089 7089
 	{
7090 7090
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7114,11 +7114,11 @@  discard block
 block discarded – undo
7114 7114
 	
7115 7115
 	
7116 7116
 	/**
7117
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
-	*
7119
-	* @return Array the airport list
7120
-	*
7121
-	*/
7117
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
+	 *
7119
+	 * @return Array the airport list
7120
+	 *
7121
+	 */
7122 7122
 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7123 7123
 	{
7124 7124
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7151,11 +7151,11 @@  discard block
 block discarded – undo
7151 7151
 	
7152 7152
 	
7153 7153
 	/**
7154
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
-	*
7156
-	* @return Array the airport list
7157
-	*
7158
-	*/
7154
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
+	 *
7156
+	 * @return Array the airport list
7157
+	 *
7158
+	 */
7159 7159
 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7160 7160
 	{
7161 7161
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7186,11 +7186,11 @@  discard block
 block discarded – undo
7186 7186
 	
7187 7187
 	
7188 7188
 	/**
7189
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
-	*
7191
-	* @return Array the airport list
7192
-	*
7193
-	*/
7189
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
+	 *
7191
+	 * @return Array the airport list
7192
+	 *
7193
+	 */
7194 7194
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7195 7195
 	{
7196 7196
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7223,11 +7223,11 @@  discard block
 block discarded – undo
7223 7223
 	
7224 7224
 	
7225 7225
 	/**
7226
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
-	*
7228
-	* @return Array the airport list
7229
-	*
7230
-	*/
7226
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
+	 *
7228
+	 * @return Array the airport list
7229
+	 *
7230
+	 */
7231 7231
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7232 7232
 	{
7233 7233
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7257,11 +7257,11 @@  discard block
 block discarded – undo
7257 7257
 	
7258 7258
 	
7259 7259
 	/**
7260
-	* Gets all departure airports of the airplanes that have flown over based on a date
7261
-	*
7262
-	* @return Array the airport list
7263
-	*
7264
-	*/
7260
+	 * Gets all departure airports of the airplanes that have flown over based on a date
7261
+	 *
7262
+	 * @return Array the airport list
7263
+	 *
7264
+	 */
7265 7265
 	public function countAllDepartureAirportsByDate($date,$filters = array())
7266 7266
 	{
7267 7267
 		global $globalTimezone, $globalDBdriver;
@@ -7307,11 +7307,11 @@  discard block
 block discarded – undo
7307 7307
 	
7308 7308
 	
7309 7309
 	/**
7310
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
7311
-	*
7312
-	* @return Array the airport list
7313
-	*
7314
-	*/
7310
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
7311
+	 *
7312
+	 * @return Array the airport list
7313
+	 *
7314
+	 */
7315 7315
 	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7316 7316
 	{
7317 7317
 		global $globalTimezone, $globalDBdriver;
@@ -7354,11 +7354,11 @@  discard block
 block discarded – undo
7354 7354
 	
7355 7355
 	
7356 7356
 	/**
7357
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
-	*
7359
-	* @return Array the airport list
7360
-	*
7361
-	*/
7357
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
+	 *
7359
+	 * @return Array the airport list
7360
+	 *
7361
+	 */
7362 7362
 	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7363 7363
 	{
7364 7364
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7390,11 +7390,11 @@  discard block
 block discarded – undo
7390 7390
 	}
7391 7391
 	
7392 7392
 	/**
7393
-	* Gets all departure airports of the airplanes that have flown over based on a owner
7394
-	*
7395
-	* @return Array the airport list
7396
-	*
7397
-	*/
7393
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
7394
+	 *
7395
+	 * @return Array the airport list
7396
+	 *
7397
+	 */
7398 7398
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7399 7399
 	{
7400 7400
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7426,11 +7426,11 @@  discard block
 block discarded – undo
7426 7426
 	}
7427 7427
 	
7428 7428
 	/**
7429
-	* Gets all departure airports of the airplanes that have flown over based on a pilot
7430
-	*
7431
-	* @return Array the airport list
7432
-	*
7433
-	*/
7429
+	 * Gets all departure airports of the airplanes that have flown over based on a pilot
7430
+	 *
7431
+	 * @return Array the airport list
7432
+	 *
7433
+	 */
7434 7434
 	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7435 7435
 	{
7436 7436
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7463,11 +7463,11 @@  discard block
 block discarded – undo
7463 7463
 	
7464 7464
 	
7465 7465
 	/**
7466
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
-	*
7468
-	* @return Array the airport list
7469
-	*
7470
-	*/
7466
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
+	 *
7468
+	 * @return Array the airport list
7469
+	 *
7470
+	 */
7471 7471
 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7472 7472
 	{
7473 7473
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7496,11 +7496,11 @@  discard block
 block discarded – undo
7496 7496
 	}
7497 7497
 	
7498 7498
 	/**
7499
-	* Gets all departure airports by country of the airplanes that have flown over based on owner
7500
-	*
7501
-	* @return Array the airport list
7502
-	*
7503
-	*/
7499
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
7500
+	 *
7501
+	 * @return Array the airport list
7502
+	 *
7503
+	 */
7504 7504
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7505 7505
 	{
7506 7506
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7516,11 +7516,11 @@  discard block
 block discarded – undo
7516 7516
 	}
7517 7517
 	
7518 7518
 	/**
7519
-	* Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
-	*
7521
-	* @return Array the airport list
7522
-	*
7523
-	*/
7519
+	 * Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
+	 *
7521
+	 * @return Array the airport list
7522
+	 *
7523
+	 */
7524 7524
 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7525 7525
 	{
7526 7526
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7538,11 +7538,11 @@  discard block
 block discarded – undo
7538 7538
 	
7539 7539
 	
7540 7540
 	/**
7541
-	* Gets all departure airports of the airplanes that have flown over based on a country
7542
-	*
7543
-	* @return Array the airport list
7544
-	*
7545
-	*/
7541
+	 * Gets all departure airports of the airplanes that have flown over based on a country
7542
+	 *
7543
+	 * @return Array the airport list
7544
+	 *
7545
+	 */
7546 7546
 	public function countAllDepartureAirportsByCountry($country,$filters = array())
7547 7547
 	{
7548 7548
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7576,11 +7576,11 @@  discard block
 block discarded – undo
7576 7576
 
7577 7577
 
7578 7578
 	/**
7579
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
-	*
7581
-	* @return Array the airport list
7582
-	*
7583
-	*/
7579
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
+	 *
7581
+	 * @return Array the airport list
7582
+	 *
7583
+	 */
7584 7584
 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7585 7585
 	{
7586 7586
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7610,31 +7610,31 @@  discard block
 block discarded – undo
7610 7610
 	
7611 7611
 
7612 7612
 	/**
7613
-	* Gets all arrival airports of the airplanes that have flown over
7614
-	*
7615
-	* @param Boolean $limit Limit result to 10 or not
7616
-	* @param Integer $olderthanmonths Only show result older than x months
7617
-	* @param String $sincedate Only show result since x date
7618
-	* @param Boolean $icaoaskey Show result by ICAO
7619
-	* @param Array $filters Filter used here
7620
-	* @return Array the airport list
7621
-	*
7622
-	*/
7613
+	 * Gets all arrival airports of the airplanes that have flown over
7614
+	 *
7615
+	 * @param Boolean $limit Limit result to 10 or not
7616
+	 * @param Integer $olderthanmonths Only show result older than x months
7617
+	 * @param String $sincedate Only show result since x date
7618
+	 * @param Boolean $icaoaskey Show result by ICAO
7619
+	 * @param Array $filters Filter used here
7620
+	 * @return Array the airport list
7621
+	 *
7622
+	 */
7623 7623
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7624 7624
 	{
7625 7625
 		global $globalDBdriver;
7626 7626
 		$filter_query = $this->getFilter($filters,true,true);
7627 7627
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7628 7628
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7629
-                if ($olderthanmonths > 0) {
7630
-            		if ($globalDBdriver == 'mysql') {
7629
+				if ($olderthanmonths > 0) {
7630
+					if ($globalDBdriver == 'mysql') {
7631 7631
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7632 7632
 			} else {
7633 7633
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7634 7634
 			}
7635 7635
 		}
7636
-                if ($sincedate != '') {
7637
-            		if ($globalDBdriver == 'mysql') {
7636
+				if ($sincedate != '') {
7637
+					if ($globalDBdriver == 'mysql') {
7638 7638
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7639 7639
 			} else {
7640 7640
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7668,7 +7668,7 @@  discard block
 block discarded – undo
7668 7668
 				$query_values = array_merge($query_values,array(':day' => $day));
7669 7669
 			}
7670 7670
 		}
7671
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7671
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7672
 					ORDER BY airport_arrival_icao_count DESC";
7673 7673
 		if ($limit) $query .= " LIMIT 10";
7674 7674
       
@@ -7697,35 +7697,35 @@  discard block
 block discarded – undo
7697 7697
 	}
7698 7698
 
7699 7699
 	/**
7700
-	* Gets all arrival airports of the airplanes that have flown over
7701
-	*
7702
-	* @return Array the airport list
7703
-	*
7704
-	*/
7700
+	 * Gets all arrival airports of the airplanes that have flown over
7701
+	 *
7702
+	 * @return Array the airport list
7703
+	 *
7704
+	 */
7705 7705
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7706 7706
 	{
7707 7707
 		global $globalDBdriver;
7708 7708
 		$filter_query = $this->getFilter($filters,true,true);
7709 7709
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7710 7710
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7711
-                if ($olderthanmonths > 0) {
7712
-            		if ($globalDBdriver == 'mysql') {
7711
+				if ($olderthanmonths > 0) {
7712
+					if ($globalDBdriver == 'mysql') {
7713 7713
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7714 7714
 			} else {
7715 7715
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7716 7716
 			}
7717 7717
 		}
7718
-                if ($sincedate != '') {
7719
-            		if ($globalDBdriver == 'mysql') {
7718
+				if ($sincedate != '') {
7719
+					if ($globalDBdriver == 'mysql') {
7720 7720
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7721 7721
 			} else {
7722 7722
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7723 7723
 			}
7724 7724
 		}
7725 7725
 
7726
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
-                $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7726
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
+				$query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7729 7729
 					ORDER BY airport_arrival_icao_count DESC";
7730 7730
 		if ($limit) $query .= " LIMIT 10";
7731 7731
       
@@ -7756,26 +7756,26 @@  discard block
 block discarded – undo
7756 7756
 
7757 7757
 
7758 7758
 	/**
7759
-	* Gets all detected arrival airports of the airplanes that have flown over
7760
-	*
7761
-	* @return Array the airport list
7762
-	*
7763
-	*/
7759
+	 * Gets all detected arrival airports of the airplanes that have flown over
7760
+	 *
7761
+	 * @return Array the airport list
7762
+	 *
7763
+	 */
7764 7764
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7765 7765
 	{
7766 7766
 		global $globalDBdriver;
7767 7767
 		$filter_query = $this->getFilter($filters,true,true);
7768 7768
 		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7769 7769
 			FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao";
7770
-                if ($olderthanmonths > 0) {
7771
-            		if ($globalDBdriver == 'mysql') {
7770
+				if ($olderthanmonths > 0) {
7771
+					if ($globalDBdriver == 'mysql') {
7772 7772
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7773 7773
 			} else {
7774 7774
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7775 7775
 			}
7776 7776
 		}
7777
-                if ($sincedate != '') {
7778
-            		if ($globalDBdriver == 'mysql') {
7777
+				if ($sincedate != '') {
7778
+					if ($globalDBdriver == 'mysql') {
7779 7779
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7780 7780
 			} else {
7781 7781
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7809,7 +7809,7 @@  discard block
 block discarded – undo
7809 7809
 				$query_values = array_merge($query_values,array(':day' => $day));
7810 7810
 			}
7811 7811
 		}
7812
-                $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7812
+				$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 7813
 					ORDER BY airport_arrival_icao_count DESC";
7814 7814
 		if ($limit) $query .= " LIMIT 10";
7815 7815
       
@@ -7837,35 +7837,35 @@  discard block
 block discarded – undo
7837 7837
 	}
7838 7838
 	
7839 7839
 	/**
7840
-	* Gets all detected arrival airports of the airplanes that have flown over
7841
-	*
7842
-	* @return Array the airport list
7843
-	*
7844
-	*/
7840
+	 * Gets all detected arrival airports of the airplanes that have flown over
7841
+	 *
7842
+	 * @return Array the airport list
7843
+	 *
7844
+	 */
7845 7845
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7846 7846
 	{
7847 7847
 		global $globalDBdriver;
7848 7848
 		$filter_query = $this->getFilter($filters,true,true);
7849 7849
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7850 7850
 			FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
7851
-                if ($olderthanmonths > 0) {
7852
-            		if ($globalDBdriver == 'mysql') {
7851
+				if ($olderthanmonths > 0) {
7852
+					if ($globalDBdriver == 'mysql') {
7853 7853
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7854 7854
 			} else {
7855 7855
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7856 7856
 			}
7857 7857
 		}
7858
-                if ($sincedate != '') {
7859
-            		if ($globalDBdriver == 'mysql') {
7858
+				if ($sincedate != '') {
7859
+					if ($globalDBdriver == 'mysql') {
7860 7860
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7861 7861
 			} else {
7862 7862
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7863 7863
 			}
7864 7864
 		}
7865 7865
 
7866
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7866
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 7869
 					ORDER BY airport_arrival_icao_count DESC";
7870 7870
 		if ($limit) $query .= " LIMIT 10";
7871 7871
       
@@ -7895,11 +7895,11 @@  discard block
 block discarded – undo
7895 7895
 	}	
7896 7896
 	
7897 7897
 	/**
7898
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
-	*
7900
-	* @return Array the airport list
7901
-	*
7902
-	*/
7898
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
+	 *
7900
+	 * @return Array the airport list
7901
+	 *
7902
+	 */
7903 7903
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7904 7904
 	{
7905 7905
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7931,11 +7931,11 @@  discard block
 block discarded – undo
7931 7931
 	
7932 7932
 	
7933 7933
 	/**
7934
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
-	*
7936
-	* @return Array the airport list
7937
-	*
7938
-	*/
7934
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
+	 *
7936
+	 * @return Array the airport list
7937
+	 *
7938
+	 */
7939 7939
 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7940 7940
 	{
7941 7941
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7966,11 +7966,11 @@  discard block
 block discarded – undo
7966 7966
 	
7967 7967
 	
7968 7968
 	/**
7969
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
-	*
7971
-	* @return Array the airport list
7972
-	*
7973
-	*/
7969
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
+	 *
7971
+	 * @return Array the airport list
7972
+	 *
7973
+	 */
7974 7974
 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7975 7975
 	{
7976 7976
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8004,11 +8004,11 @@  discard block
 block discarded – undo
8004 8004
 	
8005 8005
 	
8006 8006
 	/**
8007
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
-	*
8009
-	* @return Array the airport list
8010
-	*
8011
-	*/
8007
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
+	 *
8009
+	 * @return Array the airport list
8010
+	 *
8011
+	 */
8012 8012
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8013 8013
 	{
8014 8014
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8038,11 +8038,11 @@  discard block
 block discarded – undo
8038 8038
 	
8039 8039
 	
8040 8040
 	/**
8041
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
-	*
8043
-	* @return Array the airport list
8044
-	*
8045
-	*/
8041
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
+	 *
8043
+	 * @return Array the airport list
8044
+	 *
8045
+	 */
8046 8046
 	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8047 8047
 	{
8048 8048
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8076,11 +8076,11 @@  discard block
 block discarded – undo
8076 8076
 	
8077 8077
 	
8078 8078
 	/**
8079
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
-	*
8081
-	* @return Array the airport list
8082
-	*
8083
-	*/
8079
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
+	 *
8081
+	 * @return Array the airport list
8082
+	 *
8083
+	 */
8084 8084
 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8085 8085
 	{
8086 8086
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8111,11 +8111,11 @@  discard block
 block discarded – undo
8111 8111
 	
8112 8112
 	
8113 8113
 	/**
8114
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
-	*
8116
-	* @return Array the airport list
8117
-	*
8118
-	*/
8114
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
+	 *
8116
+	 * @return Array the airport list
8117
+	 *
8118
+	 */
8119 8119
 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8120 8120
 	{
8121 8121
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8148,11 +8148,11 @@  discard block
 block discarded – undo
8148 8148
 	
8149 8149
 	
8150 8150
 	/**
8151
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
-	*
8153
-	* @return Array the airport list
8154
-	*
8155
-	*/
8151
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
+	 *
8153
+	 * @return Array the airport list
8154
+	 *
8155
+	 */
8156 8156
 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8157 8157
 	{
8158 8158
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8182,11 +8182,11 @@  discard block
 block discarded – undo
8182 8182
 	
8183 8183
 	
8184 8184
 	/**
8185
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
-	*
8187
-	* @return Array the airport list
8188
-	*
8189
-	*/
8185
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
+	 *
8187
+	 * @return Array the airport list
8188
+	 *
8189
+	 */
8190 8190
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8191 8191
 	{
8192 8192
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8220,11 +8220,11 @@  discard block
 block discarded – undo
8220 8220
 	
8221 8221
 	
8222 8222
 	/**
8223
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
-	*
8225
-	* @return Array the airport list
8226
-	*
8227
-	*/
8223
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
+	 *
8225
+	 * @return Array the airport list
8226
+	 *
8227
+	 */
8228 8228
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8229 8229
 	{
8230 8230
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8255,11 +8255,11 @@  discard block
 block discarded – undo
8255 8255
 	
8256 8256
 	
8257 8257
 	/**
8258
-	* Gets all arrival airports of the airplanes that have flown over based on a date
8259
-	*
8260
-	* @return Array the airport list
8261
-	*
8262
-	*/
8258
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
8259
+	 *
8260
+	 * @return Array the airport list
8261
+	 *
8262
+	 */
8263 8263
 	public function countAllArrivalAirportsByDate($date,$filters = array())
8264 8264
 	{
8265 8265
 		global $globalTimezone, $globalDBdriver;
@@ -8305,11 +8305,11 @@  discard block
 block discarded – undo
8305 8305
 	
8306 8306
 	
8307 8307
 	/**
8308
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
-	*
8310
-	* @return Array the airport list
8311
-	*
8312
-	*/
8308
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
+	 *
8310
+	 * @return Array the airport list
8311
+	 *
8312
+	 */
8313 8313
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8314 8314
 	{
8315 8315
 		global $globalTimezone, $globalDBdriver;
@@ -8352,11 +8352,11 @@  discard block
 block discarded – undo
8352 8352
 	
8353 8353
 	
8354 8354
 	/**
8355
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
-	*
8357
-	* @return Array the airport list
8358
-	*
8359
-	*/
8355
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
+	 *
8357
+	 * @return Array the airport list
8358
+	 *
8359
+	 */
8360 8360
 	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8361 8361
 	{
8362 8362
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8388,11 +8388,11 @@  discard block
 block discarded – undo
8388 8388
 	}
8389 8389
 	
8390 8390
 	/**
8391
-	* Gets all arrival airports of the airplanes that have flown over based on a owner
8392
-	*
8393
-	* @return Array the airport list
8394
-	*
8395
-	*/
8391
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
8392
+	 *
8393
+	 * @return Array the airport list
8394
+	 *
8395
+	 */
8396 8396
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8397 8397
 	{
8398 8398
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8423,11 +8423,11 @@  discard block
 block discarded – undo
8423 8423
 	}
8424 8424
 
8425 8425
 	/**
8426
-	* Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
-	*
8428
-	* @return Array the airport list
8429
-	*
8430
-	*/
8426
+	 * Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
+	 *
8428
+	 * @return Array the airport list
8429
+	 *
8430
+	 */
8431 8431
 	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8432 8432
 	{
8433 8433
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8458,11 +8458,11 @@  discard block
 block discarded – undo
8458 8458
 	}
8459 8459
 	
8460 8460
 	/**
8461
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
-	*
8463
-	* @return Array the airport list
8464
-	*
8465
-	*/
8461
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
+	 *
8463
+	 * @return Array the airport list
8464
+	 *
8465
+	 */
8466 8466
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8467 8467
 	{
8468 8468
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8491,11 +8491,11 @@  discard block
 block discarded – undo
8491 8491
 	}
8492 8492
 	
8493 8493
 	/**
8494
-	* Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
-	*
8496
-	* @return Array the airport list
8497
-	*
8498
-	*/
8494
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
+	 *
8496
+	 * @return Array the airport list
8497
+	 *
8498
+	 */
8499 8499
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8500 8500
 	{
8501 8501
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8511,11 +8511,11 @@  discard block
 block discarded – undo
8511 8511
 	}
8512 8512
 	
8513 8513
 	/**
8514
-	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
-	*
8516
-	* @return Array the airport list
8517
-	*
8518
-	*/
8514
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
+	 *
8516
+	 * @return Array the airport list
8517
+	 *
8518
+	 */
8519 8519
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8520 8520
 	{
8521 8521
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8533,11 +8533,11 @@  discard block
 block discarded – undo
8533 8533
 	
8534 8534
 	
8535 8535
 	/**
8536
-	* Gets all arrival airports of the airplanes that have flown over based on a country
8537
-	*
8538
-	* @return Array the airport list
8539
-	*
8540
-	*/
8536
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
8537
+	 *
8538
+	 * @return Array the airport list
8539
+	 *
8540
+	 */
8541 8541
 	public function countAllArrivalAirportsByCountry($country,$filters = array())
8542 8542
 	{
8543 8543
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8570,11 +8570,11 @@  discard block
 block discarded – undo
8570 8570
 	
8571 8571
 	
8572 8572
 	/**
8573
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
-	*
8575
-	* @return Array the airport list
8576
-	*
8577
-	*/
8573
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
+	 *
8575
+	 * @return Array the airport list
8576
+	 *
8577
+	 */
8578 8578
 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8579 8579
 	{
8580 8580
 		global $globalDBdriver;
@@ -8606,11 +8606,11 @@  discard block
 block discarded – undo
8606 8606
 
8607 8607
 
8608 8608
 	/**
8609
-	* Counts all airport departure countries
8610
-	*
8611
-	* @return Array the airport departure list
8612
-	*
8613
-	*/
8609
+	 * Counts all airport departure countries
8610
+	 *
8611
+	 * @return Array the airport departure list
8612
+	 *
8613
+	 */
8614 8614
 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8615 8615
 	{
8616 8616
 		global $globalDBdriver;
@@ -8669,11 +8669,11 @@  discard block
 block discarded – undo
8669 8669
 	
8670 8670
 	
8671 8671
 	/**
8672
-	* Counts all airport arrival countries
8673
-	*
8674
-	* @return Array the airport arrival list
8675
-	*
8676
-	*/
8672
+	 * Counts all airport arrival countries
8673
+	 *
8674
+	 * @return Array the airport arrival list
8675
+	 *
8676
+	 */
8677 8677
 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8678 8678
 	{
8679 8679
 		global $globalDBdriver;
@@ -8735,11 +8735,11 @@  discard block
 block discarded – undo
8735 8735
 
8736 8736
 
8737 8737
 	/**
8738
-	* Gets all route combinations
8739
-	*
8740
-	* @return Array the route list
8741
-	*
8742
-	*/
8738
+	 * Gets all route combinations
8739
+	 *
8740
+	 * @return Array the route list
8741
+	 *
8742
+	 */
8743 8743
 	public function countAllRoutes($filters = array())
8744 8744
 	{
8745 8745
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8778,11 +8778,11 @@  discard block
 block discarded – undo
8778 8778
 	
8779 8779
 	
8780 8780
 	/**
8781
-	* Gets all route combinations based on an aircraft
8782
-	*
8783
-	* @return Array the route list
8784
-	*
8785
-	*/
8781
+	 * Gets all route combinations based on an aircraft
8782
+	 *
8783
+	 * @return Array the route list
8784
+	 *
8785
+	 */
8786 8786
 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8787 8787
 	{
8788 8788
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8818,11 +8818,11 @@  discard block
 block discarded – undo
8818 8818
 	
8819 8819
 	
8820 8820
 	/**
8821
-	* Gets all route combinations based on an aircraft registration
8822
-	*
8823
-	* @return Array the route list
8824
-	*
8825
-	*/
8821
+	 * Gets all route combinations based on an aircraft registration
8822
+	 *
8823
+	 * @return Array the route list
8824
+	 *
8825
+	 */
8826 8826
 	public function countAllRoutesByRegistration($registration, $filters = array())
8827 8827
 	{
8828 8828
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8860,11 +8860,11 @@  discard block
 block discarded – undo
8860 8860
 	
8861 8861
 	
8862 8862
 	/**
8863
-	* Gets all route combinations based on an airline
8864
-	*
8865
-	* @return Array the route list
8866
-	*
8867
-	*/
8863
+	 * Gets all route combinations based on an airline
8864
+	 *
8865
+	 * @return Array the route list
8866
+	 *
8867
+	 */
8868 8868
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8869 8869
 	{
8870 8870
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8902,11 +8902,11 @@  discard block
 block discarded – undo
8902 8902
 	
8903 8903
 	
8904 8904
 	/**
8905
-	* Gets all route combinations based on an airport
8906
-	*
8907
-	* @return Array the route list
8908
-	*
8909
-	*/
8905
+	 * Gets all route combinations based on an airport
8906
+	 *
8907
+	 * @return Array the route list
8908
+	 *
8909
+	 */
8910 8910
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8911 8911
 	{
8912 8912
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8943,11 +8943,11 @@  discard block
 block discarded – undo
8943 8943
 	
8944 8944
 	
8945 8945
 	/**
8946
-	* Gets all route combinations based on an country
8947
-	*
8948
-	* @return Array the route list
8949
-	*
8950
-	*/
8946
+	 * Gets all route combinations based on an country
8947
+	 *
8948
+	 * @return Array the route list
8949
+	 *
8950
+	 */
8951 8951
 	public function countAllRoutesByCountry($country, $filters = array())
8952 8952
 	{
8953 8953
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8983,11 +8983,11 @@  discard block
 block discarded – undo
8983 8983
 
8984 8984
 
8985 8985
 	/**
8986
-	* Gets all route combinations based on an date
8987
-	*
8988
-	* @return Array the route list
8989
-	*
8990
-	*/
8986
+	 * Gets all route combinations based on an date
8987
+	 *
8988
+	 * @return Array the route list
8989
+	 *
8990
+	 */
8991 8991
 	public function countAllRoutesByDate($date, $filters = array())
8992 8992
 	{
8993 8993
 		global $globalTimezone, $globalDBdriver;
@@ -9037,11 +9037,11 @@  discard block
 block discarded – undo
9037 9037
 	
9038 9038
 	
9039 9039
 	/**
9040
-	* Gets all route combinations based on an ident/callsign
9041
-	*
9042
-	* @return Array the route list
9043
-	*
9044
-	*/
9040
+	 * Gets all route combinations based on an ident/callsign
9041
+	 *
9042
+	 * @return Array the route list
9043
+	 *
9044
+	 */
9045 9045
 	public function countAllRoutesByIdent($ident, $filters = array())
9046 9046
 	{
9047 9047
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9077,11 +9077,11 @@  discard block
 block discarded – undo
9077 9077
 	}
9078 9078
 	
9079 9079
 	/**
9080
-	* Gets all route combinations based on an owner
9081
-	*
9082
-	* @return Array the route list
9083
-	*
9084
-	*/
9080
+	 * Gets all route combinations based on an owner
9081
+	 *
9082
+	 * @return Array the route list
9083
+	 *
9084
+	 */
9085 9085
 	public function countAllRoutesByOwner($owner,$filters = array())
9086 9086
 	{
9087 9087
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9117,11 +9117,11 @@  discard block
 block discarded – undo
9117 9117
 	}
9118 9118
 	
9119 9119
 	/**
9120
-	* Gets all route combinations based on a pilot
9121
-	*
9122
-	* @return Array the route list
9123
-	*
9124
-	*/
9120
+	 * Gets all route combinations based on a pilot
9121
+	 *
9122
+	 * @return Array the route list
9123
+	 *
9124
+	 */
9125 9125
 	public function countAllRoutesByPilot($pilot,$filters = array())
9126 9126
 	{
9127 9127
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9158,11 +9158,11 @@  discard block
 block discarded – undo
9158 9158
 	
9159 9159
 	
9160 9160
 	/**
9161
-	* Gets all route combinations based on an manufacturer
9162
-	*
9163
-	* @return Array the route list
9164
-	*
9165
-	*/
9161
+	 * Gets all route combinations based on an manufacturer
9162
+	 *
9163
+	 * @return Array the route list
9164
+	 *
9165
+	 */
9166 9166
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9167 9167
 	{
9168 9168
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9200,11 +9200,11 @@  discard block
 block discarded – undo
9200 9200
 	
9201 9201
 	
9202 9202
 	/**
9203
-	* Gets all route combinations with waypoints
9204
-	*
9205
-	* @return Array the route list
9206
-	*
9207
-	*/
9203
+	 * Gets all route combinations with waypoints
9204
+	 *
9205
+	 * @return Array the route list
9206
+	 *
9207
+	 */
9208 9208
 	public function countAllRoutesWithWaypoints($filters = array())
9209 9209
 	{
9210 9210
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9241,11 +9241,11 @@  discard block
 block discarded – undo
9241 9241
 	}
9242 9242
 	
9243 9243
 	/**
9244
-	* Gets all callsigns that have flown over
9245
-	*
9246
-	* @return Array the callsign list
9247
-	*
9248
-	*/
9244
+	 * Gets all callsigns that have flown over
9245
+	 *
9246
+	 * @return Array the callsign list
9247
+	 *
9248
+	 */
9249 9249
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9250 9250
 	{
9251 9251
 		global $globalDBdriver;
@@ -9311,11 +9311,11 @@  discard block
 block discarded – undo
9311 9311
 	}
9312 9312
 
9313 9313
 	/**
9314
-	* Gets all callsigns that have flown over
9315
-	*
9316
-	* @return Array the callsign list
9317
-	*
9318
-	*/
9314
+	 * Gets all callsigns that have flown over
9315
+	 *
9316
+	 * @return Array the callsign list
9317
+	 *
9318
+	 */
9319 9319
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9320 9320
 	{
9321 9321
 		global $globalDBdriver;
@@ -9356,11 +9356,11 @@  discard block
 block discarded – undo
9356 9356
 
9357 9357
 
9358 9358
 	/**
9359
-	* Counts all dates
9360
-	*
9361
-	* @return Array the date list
9362
-	*
9363
-	*/
9359
+	 * Counts all dates
9360
+	 *
9361
+	 * @return Array the date list
9362
+	 *
9363
+	 */
9364 9364
 	public function countAllDates($filters = array())
9365 9365
 	{
9366 9366
 		global $globalTimezone, $globalDBdriver;
@@ -9405,11 +9405,11 @@  discard block
 block discarded – undo
9405 9405
 	}
9406 9406
 	
9407 9407
 	/**
9408
-	* Counts all dates
9409
-	*
9410
-	* @return Array the date list
9411
-	*
9412
-	*/
9408
+	 * Counts all dates
9409
+	 *
9410
+	 * @return Array the date list
9411
+	 *
9412
+	 */
9413 9413
 	public function countAllDatesByAirlines($filters = array())
9414 9414
 	{
9415 9415
 		global $globalTimezone, $globalDBdriver;
@@ -9454,11 +9454,11 @@  discard block
 block discarded – undo
9454 9454
 	}	
9455 9455
 	
9456 9456
 	/**
9457
-	* Counts all dates during the last 7 days
9458
-	*
9459
-	* @return Array the date list
9460
-	*
9461
-	*/
9457
+	 * Counts all dates during the last 7 days
9458
+	 *
9459
+	 * @return Array the date list
9460
+	 *
9461
+	 */
9462 9462
 	public function countAllDatesLast7Days($filters = array())
9463 9463
 	{
9464 9464
 		global $globalTimezone, $globalDBdriver;
@@ -9480,7 +9480,7 @@  discard block
 block discarded – undo
9480 9480
 			$query .= " GROUP BY date_name 
9481 9481
 								ORDER BY date_name ASC";
9482 9482
 			$query_data = array(':offset' => $offset);
9483
-    		}
9483
+			}
9484 9484
 		
9485 9485
 		$sth = $this->db->prepare($query);
9486 9486
 		$sth->execute($query_data);
@@ -9500,11 +9500,11 @@  discard block
 block discarded – undo
9500 9500
 	}
9501 9501
 
9502 9502
 	/**
9503
-	* Counts all dates during the last month
9504
-	*
9505
-	* @return Array the date list
9506
-	*
9507
-	*/
9503
+	 * Counts all dates during the last month
9504
+	 *
9505
+	 * @return Array the date list
9506
+	 *
9507
+	 */
9508 9508
 	public function countAllDatesLastMonth($filters = array())
9509 9509
 	{
9510 9510
 		global $globalTimezone, $globalDBdriver;
@@ -9526,7 +9526,7 @@  discard block
 block discarded – undo
9526 9526
 			$query .= " GROUP BY date_name 
9527 9527
 								ORDER BY date_name ASC";
9528 9528
 			$query_data = array(':offset' => $offset);
9529
-    		}
9529
+			}
9530 9530
 		
9531 9531
 		$sth = $this->db->prepare($query);
9532 9532
 		$sth->execute($query_data);
@@ -9547,11 +9547,11 @@  discard block
 block discarded – undo
9547 9547
 
9548 9548
 
9549 9549
 	/**
9550
-	* Counts all dates during the last month
9551
-	*
9552
-	* @return Array the date list
9553
-	*
9554
-	*/
9550
+	 * Counts all dates during the last month
9551
+	 *
9552
+	 * @return Array the date list
9553
+	 *
9554
+	 */
9555 9555
 	public function countAllDatesLastMonthByAirlines($filters = array())
9556 9556
 	{
9557 9557
 		global $globalTimezone, $globalDBdriver;
@@ -9574,7 +9574,7 @@  discard block
 block discarded – undo
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY date_name ASC";
9576 9576
 			$query_data = array(':offset' => $offset);
9577
-    		}
9577
+			}
9578 9578
 		
9579 9579
 		$sth = $this->db->prepare($query);
9580 9580
 		$sth->execute($query_data);
@@ -9596,11 +9596,11 @@  discard block
 block discarded – undo
9596 9596
 	
9597 9597
 
9598 9598
 	/**
9599
-	* Counts all month
9600
-	*
9601
-	* @return Array the month list
9602
-	*
9603
-	*/
9599
+	 * Counts all month
9600
+	 *
9601
+	 * @return Array the month list
9602
+	 *
9603
+	 */
9604 9604
 	public function countAllMonths($filters = array())
9605 9605
 	{
9606 9606
 		global $globalTimezone, $globalDBdriver;
@@ -9642,11 +9642,11 @@  discard block
 block discarded – undo
9642 9642
 	}
9643 9643
 
9644 9644
 	/**
9645
-	* Counts all month
9646
-	*
9647
-	* @return Array the month list
9648
-	*
9649
-	*/
9645
+	 * Counts all month
9646
+	 *
9647
+	 * @return Array the month list
9648
+	 *
9649
+	 */
9650 9650
 	public function countAllMonthsByAirlines($filters = array())
9651 9651
 	{
9652 9652
 		global $globalTimezone, $globalDBdriver;
@@ -9691,11 +9691,11 @@  discard block
 block discarded – undo
9691 9691
 	}
9692 9692
 
9693 9693
 	/**
9694
-	* Counts all military month
9695
-	*
9696
-	* @return Array the month list
9697
-	*
9698
-	*/
9694
+	 * Counts all military month
9695
+	 *
9696
+	 * @return Array the month list
9697
+	 *
9698
+	 */
9699 9699
 	public function countAllMilitaryMonths($filters = array())
9700 9700
 	{
9701 9701
 		global $globalTimezone, $globalDBdriver;
@@ -9736,11 +9736,11 @@  discard block
 block discarded – undo
9736 9736
 	}
9737 9737
 	
9738 9738
 	/**
9739
-	* Counts all month owners
9740
-	*
9741
-	* @return Array the month list
9742
-	*
9743
-	*/
9739
+	 * Counts all month owners
9740
+	 *
9741
+	 * @return Array the month list
9742
+	 *
9743
+	 */
9744 9744
 	public function countAllMonthsOwners($filters = array())
9745 9745
 	{
9746 9746
 		global $globalTimezone, $globalDBdriver;
@@ -9782,11 +9782,11 @@  discard block
 block discarded – undo
9782 9782
 	}
9783 9783
 	
9784 9784
 	/**
9785
-	* Counts all month owners
9786
-	*
9787
-	* @return Array the month list
9788
-	*
9789
-	*/
9785
+	 * Counts all month owners
9786
+	 *
9787
+	 * @return Array the month list
9788
+	 *
9789
+	 */
9790 9790
 	public function countAllMonthsOwnersByAirlines($filters = array())
9791 9791
 	{
9792 9792
 		global $globalTimezone, $globalDBdriver;
@@ -9829,11 +9829,11 @@  discard block
 block discarded – undo
9829 9829
 	}
9830 9830
 
9831 9831
 	/**
9832
-	* Counts all month pilot
9833
-	*
9834
-	* @return Array the month list
9835
-	*
9836
-	*/
9832
+	 * Counts all month pilot
9833
+	 *
9834
+	 * @return Array the month list
9835
+	 *
9836
+	 */
9837 9837
 	public function countAllMonthsPilots($filters = array())
9838 9838
 	{
9839 9839
 		global $globalTimezone, $globalDBdriver;
@@ -9875,11 +9875,11 @@  discard block
 block discarded – undo
9875 9875
 	}
9876 9876
 	
9877 9877
 	/**
9878
-	* Counts all month pilot
9879
-	*
9880
-	* @return Array the month list
9881
-	*
9882
-	*/
9878
+	 * Counts all month pilot
9879
+	 *
9880
+	 * @return Array the month list
9881
+	 *
9882
+	 */
9883 9883
 	public function countAllMonthsPilotsByAirlines($filters = array())
9884 9884
 	{
9885 9885
 		global $globalTimezone, $globalDBdriver;
@@ -9922,11 +9922,11 @@  discard block
 block discarded – undo
9922 9922
 	}
9923 9923
 
9924 9924
 	/**
9925
-	* Counts all month airline
9926
-	*
9927
-	* @return Array the month list
9928
-	*
9929
-	*/
9925
+	 * Counts all month airline
9926
+	 *
9927
+	 * @return Array the month list
9928
+	 *
9929
+	 */
9930 9930
 	public function countAllMonthsAirlines($filters = array())
9931 9931
 	{
9932 9932
 		global $globalTimezone, $globalDBdriver;
@@ -9968,11 +9968,11 @@  discard block
 block discarded – undo
9968 9968
 	}
9969 9969
 	
9970 9970
 	/**
9971
-	* Counts all month aircraft
9972
-	*
9973
-	* @return Array the month list
9974
-	*
9975
-	*/
9971
+	 * Counts all month aircraft
9972
+	 *
9973
+	 * @return Array the month list
9974
+	 *
9975
+	 */
9976 9976
 	public function countAllMonthsAircrafts($filters = array())
9977 9977
 	{
9978 9978
 		global $globalTimezone, $globalDBdriver;
@@ -10015,11 +10015,11 @@  discard block
 block discarded – undo
10015 10015
 	
10016 10016
 
10017 10017
 	/**
10018
-	* Counts all month aircraft
10019
-	*
10020
-	* @return Array the month list
10021
-	*
10022
-	*/
10018
+	 * Counts all month aircraft
10019
+	 *
10020
+	 * @return Array the month list
10021
+	 *
10022
+	 */
10023 10023
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10024 10024
 	{
10025 10025
 		global $globalTimezone, $globalDBdriver;
@@ -10062,11 +10062,11 @@  discard block
 block discarded – undo
10062 10062
 	}
10063 10063
 
10064 10064
 	/**
10065
-	* Counts all month real arrival
10066
-	*
10067
-	* @return Array the month list
10068
-	*
10069
-	*/
10065
+	 * Counts all month real arrival
10066
+	 *
10067
+	 * @return Array the month list
10068
+	 *
10069
+	 */
10070 10070
 	public function countAllMonthsRealArrivals($filters = array())
10071 10071
 	{
10072 10072
 		global $globalTimezone, $globalDBdriver;
@@ -10109,11 +10109,11 @@  discard block
 block discarded – undo
10109 10109
 	
10110 10110
 
10111 10111
 	/**
10112
-	* Counts all month real arrival
10113
-	*
10114
-	* @return Array the month list
10115
-	*
10116
-	*/
10112
+	 * Counts all month real arrival
10113
+	 *
10114
+	 * @return Array the month list
10115
+	 *
10116
+	 */
10117 10117
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10118 10118
 	{
10119 10119
 		global $globalTimezone, $globalDBdriver;
@@ -10157,11 +10157,11 @@  discard block
 block discarded – undo
10157 10157
 	
10158 10158
 
10159 10159
 	/**
10160
-	* Counts all dates during the last year
10161
-	*
10162
-	* @return Array the date list
10163
-	*
10164
-	*/
10160
+	 * Counts all dates during the last year
10161
+	 *
10162
+	 * @return Array the date list
10163
+	 *
10164
+	 */
10165 10165
 	public function countAllMonthsLastYear($filters)
10166 10166
 	{
10167 10167
 		global $globalTimezone, $globalDBdriver;
@@ -10183,7 +10183,7 @@  discard block
 block discarded – undo
10183 10183
 			$query .= " GROUP BY year_name, month_name
10184 10184
 								ORDER BY year_name, month_name ASC";
10185 10185
 			$query_data = array(':offset' => $offset);
10186
-    		}
10186
+			}
10187 10187
 		
10188 10188
 		$sth = $this->db->prepare($query);
10189 10189
 		$sth->execute($query_data);
@@ -10206,11 +10206,11 @@  discard block
 block discarded – undo
10206 10206
 	
10207 10207
 	
10208 10208
 	/**
10209
-	* Counts all hours
10210
-	*
10211
-	* @return Array the hour list
10212
-	*
10213
-	*/
10209
+	 * Counts all hours
10210
+	 *
10211
+	 * @return Array the hour list
10212
+	 *
10213
+	 */
10214 10214
 	public function countAllHours($orderby,$filters = array())
10215 10215
 	{
10216 10216
 		global $globalTimezone, $globalDBdriver;
@@ -10271,11 +10271,11 @@  discard block
 block discarded – undo
10271 10271
 	}
10272 10272
 	
10273 10273
 	/**
10274
-	* Counts all hours
10275
-	*
10276
-	* @return Array the hour list
10277
-	*
10278
-	*/
10274
+	 * Counts all hours
10275
+	 *
10276
+	 * @return Array the hour list
10277
+	 *
10278
+	 */
10279 10279
 	public function countAllHoursByAirlines($orderby, $filters = array())
10280 10280
 	{
10281 10281
 		global $globalTimezone, $globalDBdriver;
@@ -10338,11 +10338,11 @@  discard block
 block discarded – undo
10338 10338
 
10339 10339
 
10340 10340
 	/**
10341
-	* Counts all hours by airline
10342
-	*
10343
-	* @return Array the hour list
10344
-	*
10345
-	*/
10341
+	 * Counts all hours by airline
10342
+	 *
10343
+	 * @return Array the hour list
10344
+	 *
10345
+	 */
10346 10346
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10347 10347
 	{
10348 10348
 		global $globalTimezone, $globalDBdriver;
@@ -10388,11 +10388,11 @@  discard block
 block discarded – undo
10388 10388
 	
10389 10389
 	
10390 10390
 	/**
10391
-	* Counts all hours by aircraft
10392
-	*
10393
-	* @return Array the hour list
10394
-	*
10395
-	*/
10391
+	 * Counts all hours by aircraft
10392
+	 *
10393
+	 * @return Array the hour list
10394
+	 *
10395
+	 */
10396 10396
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10397 10397
 	{
10398 10398
 		global $globalTimezone, $globalDBdriver;
@@ -10435,11 +10435,11 @@  discard block
 block discarded – undo
10435 10435
 	
10436 10436
 	
10437 10437
 	/**
10438
-	* Counts all hours by aircraft registration
10439
-	*
10440
-	* @return Array the hour list
10441
-	*
10442
-	*/
10438
+	 * Counts all hours by aircraft registration
10439
+	 *
10440
+	 * @return Array the hour list
10441
+	 *
10442
+	 */
10443 10443
 	public function countAllHoursByRegistration($registration, $filters = array())
10444 10444
 	{
10445 10445
 		global $globalTimezone, $globalDBdriver;
@@ -10482,11 +10482,11 @@  discard block
 block discarded – undo
10482 10482
 	
10483 10483
 	
10484 10484
 	/**
10485
-	* Counts all hours by airport
10486
-	*
10487
-	* @return Array the hour list
10488
-	*
10489
-	*/
10485
+	 * Counts all hours by airport
10486
+	 *
10487
+	 * @return Array the hour list
10488
+	 *
10489
+	 */
10490 10490
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10491 10491
 	{
10492 10492
 		global $globalTimezone, $globalDBdriver;
@@ -10530,11 +10530,11 @@  discard block
 block discarded – undo
10530 10530
 	
10531 10531
 	
10532 10532
 	/**
10533
-	* Counts all hours by manufacturer
10534
-	*
10535
-	* @return Array the hour list
10536
-	*
10537
-	*/
10533
+	 * Counts all hours by manufacturer
10534
+	 *
10535
+	 * @return Array the hour list
10536
+	 *
10537
+	 */
10538 10538
 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10539 10539
 	{
10540 10540
 		global $globalTimezone, $globalDBdriver;
@@ -10578,11 +10578,11 @@  discard block
 block discarded – undo
10578 10578
 	
10579 10579
 	
10580 10580
 	/**
10581
-	* Counts all hours by date
10582
-	*
10583
-	* @return Array the hour list
10584
-	*
10585
-	*/
10581
+	 * Counts all hours by date
10582
+	 *
10583
+	 * @return Array the hour list
10584
+	 *
10585
+	 */
10586 10586
 	public function countAllHoursByDate($date, $filters = array())
10587 10587
 	{
10588 10588
 		global $globalTimezone, $globalDBdriver;
@@ -10626,11 +10626,11 @@  discard block
 block discarded – undo
10626 10626
 	
10627 10627
 	
10628 10628
 	/**
10629
-	* Counts all hours by a ident/callsign
10630
-	*
10631
-	* @return Array the hour list
10632
-	*
10633
-	*/
10629
+	 * Counts all hours by a ident/callsign
10630
+	 *
10631
+	 * @return Array the hour list
10632
+	 *
10633
+	 */
10634 10634
 	public function countAllHoursByIdent($ident, $filters = array())
10635 10635
 	{
10636 10636
 		global $globalTimezone, $globalDBdriver;
@@ -10673,11 +10673,11 @@  discard block
 block discarded – undo
10673 10673
 	}
10674 10674
 	
10675 10675
 	/**
10676
-	* Counts all hours by a owner
10677
-	*
10678
-	* @return Array the hour list
10679
-	*
10680
-	*/
10676
+	 * Counts all hours by a owner
10677
+	 *
10678
+	 * @return Array the hour list
10679
+	 *
10680
+	 */
10681 10681
 	public function countAllHoursByOwner($owner, $filters = array())
10682 10682
 	{
10683 10683
 		global $globalTimezone, $globalDBdriver;
@@ -10720,11 +10720,11 @@  discard block
 block discarded – undo
10720 10720
 	}
10721 10721
 	
10722 10722
 	/**
10723
-	* Counts all hours by a pilot
10724
-	*
10725
-	* @return Array the hour list
10726
-	*
10727
-	*/
10723
+	 * Counts all hours by a pilot
10724
+	 *
10725
+	 * @return Array the hour list
10726
+	 *
10727
+	 */
10728 10728
 	public function countAllHoursByPilot($pilot, $filters = array())
10729 10729
 	{
10730 10730
 		global $globalTimezone, $globalDBdriver;
@@ -10769,11 +10769,11 @@  discard block
 block discarded – undo
10769 10769
 	
10770 10770
 	
10771 10771
 	/**
10772
-	* Counts all hours by route
10773
-	*
10774
-	* @return Array the hour list
10775
-	*
10776
-	*/
10772
+	 * Counts all hours by route
10773
+	 *
10774
+	 * @return Array the hour list
10775
+	 *
10776
+	 */
10777 10777
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10778 10778
 	{
10779 10779
 		global $globalTimezone, $globalDBdriver;
@@ -10817,11 +10817,11 @@  discard block
 block discarded – undo
10817 10817
 	
10818 10818
 	
10819 10819
 	/**
10820
-	* Counts all hours by country
10821
-	*
10822
-	* @return Array the hour list
10823
-	*
10824
-	*/
10820
+	 * Counts all hours by country
10821
+	 *
10822
+	 * @return Array the hour list
10823
+	 *
10824
+	 */
10825 10825
 	public function countAllHoursByCountry($country, $filters = array())
10826 10826
 	{
10827 10827
 		global $globalTimezone, $globalDBdriver;
@@ -10866,11 +10866,11 @@  discard block
 block discarded – undo
10866 10866
 
10867 10867
 
10868 10868
 	/**
10869
-	* Counts all aircraft that have flown over
10870
-	*
10871
-	* @return Integer the number of aircrafts
10872
-	*
10873
-	*/
10869
+	 * Counts all aircraft that have flown over
10870
+	 *
10871
+	 * @return Integer the number of aircrafts
10872
+	 *
10873
+	 */
10874 10874
 	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10875 10875
 	{
10876 10876
 		global $globalDBdriver;
@@ -10903,11 +10903,11 @@  discard block
 block discarded – undo
10903 10903
 	}
10904 10904
 
10905 10905
 	/**
10906
-	* Counts all flight that really arrival
10907
-	*
10908
-	* @return Integer the number of aircrafts
10909
-	*
10910
-	*/
10906
+	 * Counts all flight that really arrival
10907
+	 *
10908
+	 * @return Integer the number of aircrafts
10909
+	 *
10910
+	 */
10911 10911
 	public function countOverallArrival($filters = array(),$year = '',$month = '')
10912 10912
 	{
10913 10913
 		global $globalDBdriver;
@@ -10940,11 +10940,11 @@  discard block
 block discarded – undo
10940 10940
 	}
10941 10941
 
10942 10942
 	/**
10943
-	* Counts all pilots that have flown over
10944
-	*
10945
-	* @return Integer the number of pilots
10946
-	*
10947
-	*/
10943
+	 * Counts all pilots that have flown over
10944
+	 *
10945
+	 * @return Integer the number of pilots
10946
+	 *
10947
+	 */
10948 10948
 	public function countOverallPilots($filters = array(),$year = '',$month = '')
10949 10949
 	{
10950 10950
 		global $globalDBdriver;
@@ -10976,11 +10976,11 @@  discard block
 block discarded – undo
10976 10976
 	}
10977 10977
 
10978 10978
 	/**
10979
-	* Counts all owners that have flown over
10980
-	*
10981
-	* @return Integer the number of owners
10982
-	*
10983
-	*/
10979
+	 * Counts all owners that have flown over
10980
+	 *
10981
+	 * @return Integer the number of owners
10982
+	 *
10983
+	 */
10984 10984
 	public function countOverallOwners($filters = array(),$year = '',$month = '')
10985 10985
 	{
10986 10986
 		global $globalDBdriver;
@@ -11013,11 +11013,11 @@  discard block
 block discarded – undo
11013 11013
 	
11014 11014
 	
11015 11015
 	/**
11016
-	* Counts all flights that have flown over
11017
-	*
11018
-	* @return Integer the number of flights
11019
-	*
11020
-	*/
11016
+	 * Counts all flights that have flown over
11017
+	 *
11018
+	 * @return Integer the number of flights
11019
+	 *
11020
+	 */
11021 11021
 	public function countOverallFlights($filters = array(),$year = '',$month = '')
11022 11022
 	{
11023 11023
 		global $globalDBdriver;
@@ -11051,11 +11051,11 @@  discard block
 block discarded – undo
11051 11051
 	}
11052 11052
 	
11053 11053
 	/**
11054
-	* Counts all military flights that have flown over
11055
-	*
11056
-	* @return Integer the number of flights
11057
-	*
11058
-	*/
11054
+	 * Counts all military flights that have flown over
11055
+	 *
11056
+	 * @return Integer the number of flights
11057
+	 *
11058
+	 */
11059 11059
 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11060 11060
 	{
11061 11061
 		global $globalDBdriver;
@@ -11090,11 +11090,11 @@  discard block
 block discarded – undo
11090 11090
 	
11091 11091
 	
11092 11092
 	/**
11093
-	* Counts all airlines that have flown over
11094
-	*
11095
-	* @return Integer the number of airlines
11096
-	*
11097
-	*/
11093
+	 * Counts all airlines that have flown over
11094
+	 *
11095
+	 * @return Integer the number of airlines
11096
+	 *
11097
+	 */
11098 11098
 	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11099 11099
 	{
11100 11100
 		global $globalDBdriver;
@@ -11121,8 +11121,8 @@  discard block
 block discarded – undo
11121 11121
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11122
 			}
11123 11123
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11124
+				if ($query == '') $queryi .= $this->getFilter($filters);
11125
+				else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11126 11126
 
11127 11127
 
11128 11128
 		$sth = $this->db->prepare($queryi);
@@ -11132,11 +11132,11 @@  discard block
 block discarded – undo
11132 11132
 
11133 11133
   
11134 11134
 	/**
11135
-	* Counts all hours of today
11136
-	*
11137
-	* @return Array the hour list
11138
-	*
11139
-	*/
11135
+	 * Counts all hours of today
11136
+	 *
11137
+	 * @return Array the hour list
11138
+	 *
11139
+	 */
11140 11140
 	public function countAllHoursFromToday($filters = array())
11141 11141
 	{
11142 11142
 		global $globalTimezone, $globalDBdriver;
@@ -11176,11 +11176,11 @@  discard block
 block discarded – undo
11176 11176
 	}
11177 11177
     
11178 11178
 	/**
11179
-	* Gets all the spotter information based on calculated upcoming flights
11180
-	*
11181
-	* @return Array the spotter information
11182
-	*
11183
-	*/
11179
+	 * Gets all the spotter information based on calculated upcoming flights
11180
+	 *
11181
+	 * @return Array the spotter information
11182
+	 *
11183
+	 */
11184 11184
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11185 11185
 	{
11186 11186
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -11255,12 +11255,12 @@  discard block
 block discarded – undo
11255 11255
 	}
11256 11256
     
11257 11257
     
11258
-     /**
11259
-	* Gets the Barrie Spotter ID based on the FlightAware ID
11260
-	*
11261
-	* @return Integer the Barrie Spotter ID
11258
+	 /**
11259
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
11260
+	  *
11261
+	  * @return Integer the Barrie Spotter ID
11262 11262
 q	*
11263
-	*/
11263
+	  */
11264 11264
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11265 11265
 	{
11266 11266
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -11281,13 +11281,13 @@  discard block
 block discarded – undo
11281 11281
   
11282 11282
  
11283 11283
 	/**
11284
-	* Parses a date string
11285
-	*
11286
-	* @param String $dateString the date string
11287
-	* @param String $timezone the timezone of a user
11288
-	* @return Array the time information
11289
-	*
11290
-	*/
11284
+	 * Parses a date string
11285
+	 *
11286
+	 * @param String $dateString the date string
11287
+	 * @param String $timezone the timezone of a user
11288
+	 * @return Array the time information
11289
+	 *
11290
+	 */
11291 11291
 	public function parseDateString($dateString, $timezone = '')
11292 11292
 	{
11293 11293
 		$time_array = array();
@@ -11323,12 +11323,12 @@  discard block
 block discarded – undo
11323 11323
 	
11324 11324
 	
11325 11325
 	/**
11326
-	* Parses the direction degrees to working
11327
-	*
11328
-	* @param Float $direction the direction in degrees
11329
-	* @return Array the direction information
11330
-	*
11331
-	*/
11326
+	 * Parses the direction degrees to working
11327
+	 *
11328
+	 * @param Float $direction the direction in degrees
11329
+	 * @return Array the direction information
11330
+	 *
11331
+	 */
11332 11332
 	public function parseDirection($direction = 0)
11333 11333
 	{
11334 11334
 		if ($direction == '') $direction = 0;
@@ -11407,12 +11407,12 @@  discard block
 block discarded – undo
11407 11407
 	
11408 11408
 	
11409 11409
 	/**
11410
-	* Gets the aircraft registration
11411
-	*
11412
-	* @param String $flightaware_id the flight aware id
11413
-	* @return String the aircraft registration
11414
-	*
11415
-	*/
11410
+	 * Gets the aircraft registration
11411
+	 *
11412
+	 * @param String $flightaware_id the flight aware id
11413
+	 * @return String the aircraft registration
11414
+	 *
11415
+	 */
11416 11416
 	
11417 11417
 	public function getAircraftRegistration($flightaware_id)
11418 11418
 	{
@@ -11441,12 +11441,12 @@  discard block
 block discarded – undo
11441 11441
 
11442 11442
 
11443 11443
 	/**
11444
-	* Gets the aircraft registration from ModeS
11445
-	*
11446
-	* @param String $aircraft_modes the flight ModeS in hex
11447
-	* @return String the aircraft registration
11448
-	*
11449
-	*/
11444
+	 * Gets the aircraft registration from ModeS
11445
+	 *
11446
+	 * @param String $aircraft_modes the flight ModeS in hex
11447
+	 * @return String the aircraft registration
11448
+	 *
11449
+	 */
11450 11450
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11451 11451
 	{
11452 11452
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11462,8 +11462,8 @@  discard block
 block discarded – undo
11462 11462
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11463 11463
 		$sth->closeCursor();
11464 11464
 		if (count($row) > 0) {
11465
-		    //return $row['Registration'];
11466
-		    return $row['registration'];
11465
+			//return $row['Registration'];
11466
+			return $row['registration'];
11467 11467
 		} elseif ($source_type == 'flarm') {
11468 11468
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469 11469
 		} else return '';
@@ -11471,12 +11471,12 @@  discard block
 block discarded – undo
11471 11471
 	}
11472 11472
 
11473 11473
 	/**
11474
-	* Gets the aircraft type from ModeS
11475
-	*
11476
-	* @param String $aircraft_modes the flight ModeS in hex
11477
-	* @return String the aircraft type
11478
-	*
11479
-	*/
11474
+	 * Gets the aircraft type from ModeS
11475
+	 *
11476
+	 * @param String $aircraft_modes the flight ModeS in hex
11477
+	 * @return String the aircraft type
11478
+	 *
11479
+	 */
11480 11480
 	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11481 11481
 	{
11482 11482
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11502,12 +11502,12 @@  discard block
 block discarded – undo
11502 11502
 	}
11503 11503
 
11504 11504
 	/**
11505
-	* Gets Country from latitude/longitude
11506
-	*
11507
-	* @param Float $latitude latitute of the flight
11508
-	* @param Float $longitude longitute of the flight
11509
-	* @return String the countrie
11510
-	*/
11505
+	 * Gets Country from latitude/longitude
11506
+	 *
11507
+	 * @param Float $latitude latitute of the flight
11508
+	 * @param Float $longitude longitute of the flight
11509
+	 * @return String the countrie
11510
+	 */
11511 11511
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11512 11512
 	{
11513 11513
 		global $globalDBdriver, $globalDebug;
@@ -11544,11 +11544,11 @@  discard block
 block discarded – undo
11544 11544
 	}
11545 11545
 
11546 11546
 	/**
11547
-	* Gets Country from iso2
11548
-	*
11549
-	* @param String $iso2 ISO2 country code
11550
-	* @return String the countrie
11551
-	*/
11547
+	 * Gets Country from iso2
11548
+	 *
11549
+	 * @param String $iso2 ISO2 country code
11550
+	 * @return String the countrie
11551
+	 */
11552 11552
 	public function getCountryFromISO2($iso2)
11553 11553
 	{
11554 11554
 		global $globalDBdriver, $globalDebug;
@@ -11576,12 +11576,12 @@  discard block
 block discarded – undo
11576 11576
 	}
11577 11577
 
11578 11578
 	/**
11579
-	* converts the registration code using the country prefix
11580
-	*
11581
-	* @param String $registration the aircraft registration
11582
-	* @return String the aircraft registration
11583
-	*
11584
-	*/
11579
+	 * converts the registration code using the country prefix
11580
+	 *
11581
+	 * @param String $registration the aircraft registration
11582
+	 * @return String the aircraft registration
11583
+	 *
11584
+	 */
11585 11585
 	public function convertAircraftRegistration($registration)
11586 11586
 	{
11587 11587
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11633,12 +11633,12 @@  discard block
 block discarded – undo
11633 11633
 	}
11634 11634
 
11635 11635
 	/**
11636
-	* Country from the registration code
11637
-	*
11638
-	* @param String $registration the aircraft registration
11639
-	* @return String the country
11640
-	*
11641
-	*/
11636
+	 * Country from the registration code
11637
+	 *
11638
+	 * @param String $registration the aircraft registration
11639
+	 * @return String the country
11640
+	 *
11641
+	 */
11642 11642
 	public function countryFromAircraftRegistration($registration)
11643 11643
 	{
11644 11644
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11657,8 +11657,8 @@  discard block
 block discarded – undo
11657 11657
 				$country = $row['country'];
11658 11658
 			}
11659 11659
 		} else {
11660
-    			$registration_1 = substr($registration, 0, 1);
11661
-		        $registration_2 = substr($registration, 0, 2);
11660
+				$registration_1 = substr($registration, 0, 1);
11661
+				$registration_2 = substr($registration, 0, 2);
11662 11662
 
11663 11663
 			$country = '';
11664 11664
 			//first get the prefix based on two characters
@@ -11694,12 +11694,12 @@  discard block
 block discarded – undo
11694 11694
 	}
11695 11695
 
11696 11696
 	/**
11697
-	* Registration prefix from the registration code
11698
-	*
11699
-	* @param String $registration the aircraft registration
11700
-	* @return String the registration prefix
11701
-	*
11702
-	*/
11697
+	 * Registration prefix from the registration code
11698
+	 *
11699
+	 * @param String $registration the aircraft registration
11700
+	 * @return String the registration prefix
11701
+	 *
11702
+	 */
11703 11703
 	public function registrationPrefixFromAircraftRegistration($registration)
11704 11704
 	{
11705 11705
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11718,8 +11718,8 @@  discard block
 block discarded – undo
11718 11718
 				//$country = $row['country'];
11719 11719
 			}
11720 11720
 		} else {
11721
-    			$registration_1 = substr($registration, 0, 1);
11722
-		        $registration_2 = substr($registration, 0, 2);
11721
+				$registration_1 = substr($registration, 0, 1);
11722
+				$registration_2 = substr($registration, 0, 2);
11723 11723
 
11724 11724
 			//first get the prefix based on two characters
11725 11725
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
@@ -11755,12 +11755,12 @@  discard block
 block discarded – undo
11755 11755
 
11756 11756
 
11757 11757
 	/**
11758
-	* Country from the registration code
11759
-	*
11760
-	* @param String $registration the aircraft registration
11761
-	* @return String the country
11762
-	*
11763
-	*/
11758
+	 * Country from the registration code
11759
+	 *
11760
+	 * @param String $registration the aircraft registration
11761
+	 * @return String the country
11762
+	 *
11763
+	 */
11764 11764
 	public function countryFromAircraftRegistrationCode($registration)
11765 11765
 	{
11766 11766
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11777,11 +11777,11 @@  discard block
 block discarded – undo
11777 11777
 	}
11778 11778
 	
11779 11779
 	/**
11780
-	* Set a new highlight value for a flight
11781
-	*
11782
-	* @param String $flightaware_id flightaware_id from spotter_output table
11783
-	* @param String $highlight New highlight value
11784
-	*/
11780
+	 * Set a new highlight value for a flight
11781
+	 *
11782
+	 * @param String $flightaware_id flightaware_id from spotter_output table
11783
+	 * @param String $highlight New highlight value
11784
+	 */
11785 11785
 	public function setHighlightFlight($flightaware_id,$highlight) {
11786 11786
 		
11787 11787
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -11790,12 +11790,12 @@  discard block
 block discarded – undo
11790 11790
 	}
11791 11791
 
11792 11792
 	/**
11793
-	* Set a new highlight value for a flight by Registration
11794
-	*
11795
-	* @param String $registration Registration of the aircraft
11796
-	* @param String $date Date of spotted aircraft
11797
-	* @param String $highlight New highlight value
11798
-	*/
11793
+	 * Set a new highlight value for a flight by Registration
11794
+	 *
11795
+	 * @param String $registration Registration of the aircraft
11796
+	 * @param String $date Date of spotted aircraft
11797
+	 * @param String $highlight New highlight value
11798
+	 */
11799 11799
 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11800 11800
 		if ($date == '') {
11801 11801
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
@@ -11809,12 +11809,12 @@  discard block
 block discarded – undo
11809 11809
 	}
11810 11810
 	
11811 11811
 	/**
11812
-	* Gets the short url from bit.ly
11813
-	*
11814
-	* @param String $url the full url
11815
-	* @return String the bit.ly url
11816
-	*
11817
-	*/
11812
+	 * Gets the short url from bit.ly
11813
+	 *
11814
+	 * @param String $url the full url
11815
+	 * @return String the bit.ly url
11816
+	 *
11817
+	 */
11818 11818
 	public function getBitlyURL($url)
11819 11819
 	{
11820 11820
 		global $globalBitlyAccessToken;
@@ -12103,11 +12103,11 @@  discard block
 block discarded – undo
12103 12103
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12104 12104
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12105 12105
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12106
-                } else {
12106
+				} else {
12107 12107
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
12108 12108
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12109 12109
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12110
-    		}
12110
+			}
12111 12111
 		$sth = $this->db->prepare($query);
12112 12112
 		$sth->execute();
12113 12113
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Spacing   +1353 added lines, -1353 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $aircraft_correct_icaotype = array('CL64' => 'CL60',
9 9
 					'F9LX' => 'F900',
10 10
 					'K35T' => 'K35R',
@@ -59,62 +59,62 @@  discard block
 block discarded – undo
59 59
 	* @param Array $filter the filter
60 60
 	* @return Array the SQL part
61 61
 	*/
62
-	public function getFilter($filter = array(),$where = false,$and = false) {
62
+	public function getFilter($filter = array(), $where = false, $and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
65 65
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
66 66
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
67 67
 				$filters = $globalStatsFilters[$globalFilterName];
68 68
 			} else {
69
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
69
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter[0]['source'])) {
73
-			$filters = array_merge($filters,$filter);
73
+			$filters = array_merge($filters, $filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
76 76
 		$filter_query_join = '';
77 77
 		$filter_query_where = '';
78
-		foreach($filters as $flt) {
78
+		foreach ($filters as $flt) {
79 79
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
80 80
 				if ($flt['airlines'][0] != '') {
81 81
 					if (isset($flt['source'])) {
82
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
82
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
83 83
 					} else {
84
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
84
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
85 85
 					}
86 86
 				}
87 87
 			}
88 88
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
89 89
 				if (isset($flt['source'])) {
90
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
90
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
91 91
 				} else {
92
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
92
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
93 93
 				}
94 94
 			}
95 95
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
96 96
 				if (isset($flt['source'])) {
97
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
97
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
98 98
 				} else {
99
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
99
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
100 100
 				}
101 101
 			}
102 102
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
103 103
 				if (isset($flt['source'])) {
104
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
104
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
105 105
 				} else {
106
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
106
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
107 107
 				}
108 108
 			}
109 109
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
110 110
 				if (isset($flt['source'])) {
111
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
111
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
112 112
 				}
113 113
 			}
114 114
 		}
115 115
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
116 116
 			if ($filter['airlines'][0] != '') {
117
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
117
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
118 118
 			}
119 119
 		}
120 120
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 			$filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao ";
125 125
 		}
126 126
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
127
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
127
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
128 128
 			}
129 129
 		if (isset($filter['source']) && !empty($filter['source'])) {
130
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
130
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
131 131
 		}
132 132
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
133 133
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
134 134
 		}
135 135
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
136
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
136
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
137 137
 		}
138 138
 		if (isset($filter['year']) && $filter['year'] != '') {
139 139
 			if ($globalDBdriver == 'mysql') {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160 160
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161 161
 		if ($filter_query_where != '') {
162
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
162
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
163 163
 		}
164 164
 		$filter_query = $filter_query_join.$filter_query_where;
165 165
 		return $filter_query;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	* @return Array the spotter information
175 175
 	*
176 176
 	*/
177
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
177
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
180 180
 		$Image = new Image($this->db);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			$sth = $this->db->prepare($query.$limitQuery);
205 205
 			$sth->execute($params);
206 206
 		} catch (PDOException $e) {
207
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
207
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
208 208
 			exit();
209 209
 		}
210 210
 		
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		$spotter_array = array();
215 215
 		
216 216
 
217
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
217
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
218 218
 		{
219 219
 			$num_rows++;
220 220
 			$temp_array = array();
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
259 259
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 260
 				$temp_array['route_stop'] = $row['route_stop'];
261
-				$allroute = explode(' ',$row['route_stop']);
261
+				$allroute = explode(' ', $row['route_stop']);
262 262
 				foreach ($allroute as $route) {
263 263
 					$route_airport_array = $this->getAllAirportInfo($route);
264 264
 					if (isset($route_airport_array[0]['name'])) {
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
 				{
312 312
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
313 313
 				} else {
314
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
314
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
315 315
 				}
316 316
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
317
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
318
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
317
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
318
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
319 319
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
320 320
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
321 321
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
322 322
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
323
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
324
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
323
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
324
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
325 325
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
326 326
 					}
327 327
 				}
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 358
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 359
 					if (is_numeric(substr($row['ident'], 2, 1))) {
360
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
360
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
361 361
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
362
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
362
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
363 363
 					} else {
364 364
 						$airline_array = $this->getAllAirlineInfo('NA');
365 365
 					}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 				}
397 397
 			}
398 398
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
399
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
399
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
400 400
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
401 401
 				if (count($acars_array) > 0) {
402 402
 					$temp_array['acars'] = $acars_array;
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 414
 			}
415 415
 
416
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
416
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 417
 			{
418 418
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
419
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
420
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
421 421
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
422 422
 				if (count($image_array) > 0) {
423 423
 					$temp_array['image'] = $image_array[0]['image'];
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
442 442
 			}
443 443
 			
444
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
444
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
445 445
 				if ($schedules === true) {
446 446
 					$schedule_array = $Schedule->getSchedule($temp_array['ident']);
447 447
 					//print_r($schedule_array);
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 			if (isset($row['squawk'])) {
524 524
 				$temp_array['squawk'] = $row['squawk'];
525 525
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
526
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
527
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
528 528
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
529
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
530
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
531
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
532 532
 			}
533 533
     			
534 534
 			$temp_array['query_number_rows'] = $num_rows;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	* @return Array the spotter information
548 548
 	*
549 549
 	*/
550
-	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
550
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
551 551
 	{
552 552
 		global $globalTimezone, $globalDBdriver;
553 553
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$query_values = array();
559 559
 		$additional_query = '';
560
-		$filter_query = $this->getFilter($filters,true,true);
560
+		$filter_query = $this->getFilter($filters, true, true);
561 561
 		if ($q != "")
562 562
 		{
563 563
 			if (!is_string($q))
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
 				return false;
566 566
 			} else {
567 567
 				$q_array = explode(" ", $q);
568
-				foreach ($q_array as $q_item){
569
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
568
+				foreach ($q_array as $q_item) {
569
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
570 570
 					$additional_query .= " AND (";
571 571
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
572 572
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -598,37 +598,37 @@  discard block
 block discarded – undo
598 598
 
599 599
 		if ($registration != "")
600 600
 		{
601
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
601
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
602 602
 			if (!is_string($registration))
603 603
 			{
604 604
 				return false;
605 605
 			} else {
606 606
 				$additional_query .= " AND spotter_output.registration = :registration";
607
-				$query_values = array_merge($query_values,array(':registration' => $registration));
607
+				$query_values = array_merge($query_values, array(':registration' => $registration));
608 608
 			}
609 609
 		}
610 610
 
611 611
 		if ($aircraft_icao != "")
612 612
 		{
613
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
613
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
614 614
 			if (!is_string($aircraft_icao))
615 615
 			{
616 616
 				return false;
617 617
 			} else {
618 618
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
619
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
619
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
620 620
 			}
621 621
 		}
622 622
 
623 623
 		if ($aircraft_manufacturer != "")
624 624
 		{
625
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
625
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
626 626
 			if (!is_string($aircraft_manufacturer))
627 627
 			{
628 628
 				return false;
629 629
 			} else {
630 630
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
631
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
631
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
632 632
 			}
633 633
 		}
634 634
 
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
 
645 645
 		if ($airline_icao != "")
646 646
 		{
647
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
648 648
 			if (!is_string($airline_icao))
649 649
 			{
650 650
 				return false;
651 651
 			} else {
652 652
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
653
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
653
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
654 654
 			}
655 655
 		}
656 656
 
657 657
 		if ($airline_country != "")
658 658
 		{
659
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 			if (!is_string($airline_country))
661 661
 			{
662 662
 				return false;
663 663
 			} else {
664 664
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
665
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
665
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
666 666
 			}
667 667
 		}
668 668
 
@@ -689,31 +689,31 @@  discard block
 block discarded – undo
689 689
 
690 690
 		if ($airport != "")
691 691
 		{
692
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 			if (!is_string($airport))
694 694
 			{
695 695
 				return false;
696 696
 			} else {
697 697
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
698
-				$query_values = array_merge($query_values,array(':airport' => $airport));
698
+				$query_values = array_merge($query_values, array(':airport' => $airport));
699 699
 			}
700 700
 		}
701 701
 
702 702
 		if ($airport_country != "")
703 703
 		{
704
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
705 705
 			if (!is_string($airport_country))
706 706
 			{
707 707
 				return false;
708 708
 			} else {
709 709
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
710
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
710
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
711 711
 			}
712 712
 		}
713 713
     
714 714
 		if ($callsign != "")
715 715
 		{
716
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
716
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
717 717
 			if (!is_string($callsign))
718 718
 			{
719 719
 				return false;
@@ -721,79 +721,79 @@  discard block
 block discarded – undo
721 721
 				$translate = $Translation->ident2icao($callsign);
722 722
 				if ($translate != $callsign) {
723 723
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
724
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
724
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
725 725
 				} else {
726 726
 					$additional_query .= " AND spotter_output.ident = :callsign";
727
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
727
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
728 728
 				}
729 729
 			}
730 730
 		}
731 731
 
732 732
 		if ($owner != "")
733 733
 		{
734
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
734
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
735 735
 			if (!is_string($owner))
736 736
 			{
737 737
 				return false;
738 738
 			} else {
739 739
 				$additional_query .= " AND spotter_output.owner_name = :owner";
740
-				$query_values = array_merge($query_values,array(':owner' => $owner));
740
+				$query_values = array_merge($query_values, array(':owner' => $owner));
741 741
 			}
742 742
 		}
743 743
 
744 744
 		if ($pilot_name != "")
745 745
 		{
746
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
746
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
747 747
 			if (!is_string($pilot_name))
748 748
 			{
749 749
 				return false;
750 750
 			} else {
751 751
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
752
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
752
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
753 753
 			}
754 754
 		}
755 755
 
756 756
 		if ($pilot_id != "")
757 757
 		{
758
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
758
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
759 759
 			if (!is_string($pilot_id))
760 760
 			{
761 761
 				return false;
762 762
 			} else {
763 763
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
764
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
764
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
765 765
 			}
766 766
 		}
767 767
 
768 768
 		if ($departure_airport_route != "")
769 769
 		{
770
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
771 771
 			if (!is_string($departure_airport_route))
772 772
 			{
773 773
 				return false;
774 774
 			} else {
775 775
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
776
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
776
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
777 777
 			}
778 778
 		}
779 779
 
780 780
 		if ($arrival_airport_route != "")
781 781
 		{
782
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
782
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
783 783
 			if (!is_string($arrival_airport_route))
784 784
 			{
785 785
 				return false;
786 786
 			} else {
787 787
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
788
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
788
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
789 789
 			}
790 790
 		}
791 791
 
792 792
 		if ($altitude != "")
793 793
 		{
794 794
 			$altitude_array = explode(",", $altitude);
795
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
796
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
796
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
797 797
 
798 798
 			if ($altitude_array[1] != "")
799 799
 			{                
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 		if ($date_posted != "")
810 810
 		{
811 811
 			$date_array = explode(",", $date_posted);
812
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
813
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
814 814
 
815 815
 			if ($globalTimezone != '') {
816 816
 				date_default_timezone_set($globalTimezone);
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 		{
842 842
 			$limit_array = explode(",", $limit);
843 843
 			
844
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
845
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
844
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
845
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
846 846
 			
847 847
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
848 848
 			{
@@ -871,23 +871,23 @@  discard block
 block discarded – undo
871 871
 
872 872
 
873 873
 		if ($origLat != "" && $origLon != "" && $dist != "") {
874
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
874
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
875 875
 
876 876
 			if ($globalDBdriver == 'mysql') {
877
-				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
877
+				$query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
878 878
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
879 879
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
880 880
 			} else {
881
-				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
881
+				$query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
882 882
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
883 883
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
884 884
 			}
885 885
 		} else {		
886
-			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
886
+			$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
887 887
 					".$additional_query."
888 888
 					".$orderby_query;
889 889
 		}
890
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
890
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
891 891
 		return $spotter_array;
892 892
 	}
893 893
 	
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		{
911 911
 			$limit_array = explode(",", $limit);
912 912
 			
913
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
914
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
913
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
914
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
915 915
 			
916 916
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
917 917
 			{
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
 			$orderby_query = " ORDER BY spotter_output.date DESC";
929 929
 		}
930 930
 
931
-		$query  = $global_query.$filter_query." ".$orderby_query;
931
+		$query = $global_query.$filter_query." ".$orderby_query;
932 932
 
933
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
933
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
934 934
 
935 935
 		return $spotter_array;
936 936
 	}
@@ -976,34 +976,34 @@  discard block
 block discarded – undo
976 976
 			{
977 977
 				return false;
978 978
 			} else {
979
-				if ($interval == "30m"){
979
+				if ($interval == "30m") {
980 980
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
981
-				} else if ($interval == "1h"){
981
+				} else if ($interval == "1h") {
982 982
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
983
-				} else if ($interval == "3h"){
983
+				} else if ($interval == "3h") {
984 984
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
985
-				} else if ($interval == "6h"){
985
+				} else if ($interval == "6h") {
986 986
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
987
-				} else if ($interval == "12h"){
987
+				} else if ($interval == "12h") {
988 988
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
989
-				} else if ($interval == "24h"){
989
+				} else if ($interval == "24h") {
990 990
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
991
-				} else if ($interval == "7d"){
991
+				} else if ($interval == "7d") {
992 992
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
993
-				} else if ($interval == "30d"){
993
+				} else if ($interval == "30d") {
994 994
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
995 995
 				} 
996 996
 			}
997 997
 		}
998 998
 
999
-		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
999
+		$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
1000 1000
                    WHERE spotter_output.latitude <> '' 
1001 1001
 				   AND spotter_output.longitude <> '' 
1002 1002
                    ".$additional_query."
1003 1003
                    HAVING distance < :radius  
1004 1004
 				   ORDER BY distance";
1005 1005
 
1006
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
1006
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
1007 1007
 
1008 1008
 		return $spotter_array;
1009 1009
 	}
@@ -1015,21 +1015,21 @@  discard block
 block discarded – undo
1015 1015
 	* @return Array the spotter information
1016 1016
 	*
1017 1017
 	*/
1018
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1018
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
1021 1021
 		
1022 1022
 		date_default_timezone_set('UTC');
1023 1023
 
1024
-		$filter_query = $this->getFilter($filter,true,true);
1024
+		$filter_query = $this->getFilter($filter, true, true);
1025 1025
 
1026 1026
 		$limit_query = '';
1027 1027
 		if ($limit != "")
1028 1028
 		{
1029 1029
 			$limit_array = explode(",", $limit);
1030 1030
 			
1031
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1032
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1031
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1032
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1033 1033
 			
1034 1034
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1035 1035
 			{
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1047 1047
 		}
1048 1048
 
1049
-		$query  = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1049
+		$query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1050 1050
 
1051 1051
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1052 1052
 
@@ -1065,15 +1065,15 @@  discard block
 block discarded – undo
1065 1065
 		global $global_query;
1066 1066
 		
1067 1067
 		date_default_timezone_set('UTC');
1068
-		$filter_query = $this->getFilter($filter,true,true);
1068
+		$filter_query = $this->getFilter($filter, true, true);
1069 1069
 
1070 1070
 		$limit_query = '';
1071 1071
 		if ($limit != "")
1072 1072
 		{
1073 1073
 			$limit_array = explode(",", $limit);
1074 1074
 			
1075
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1076
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1075
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1076
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1077 1077
 			
1078 1078
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1079 1079
 			{
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1091 1091
 		}
1092 1092
 
1093
-		$query  = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1093
+		$query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1094 1094
 
1095 1095
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1096 1096
 
@@ -1104,20 +1104,20 @@  discard block
 block discarded – undo
1104 1104
 	* @return Array the spotter information
1105 1105
 	*
1106 1106
 	*/
1107
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1107
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
1110 1110
 		
1111 1111
 		date_default_timezone_set('UTC');
1112
-		$filter_query = $this->getFilter($filter,true,true);
1112
+		$filter_query = $this->getFilter($filter, true, true);
1113 1113
 		
1114 1114
 		$limit_query = '';
1115 1115
 		if ($limit != "")
1116 1116
 		{
1117 1117
 			$limit_array = explode(",", $limit);
1118 1118
 			
1119
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1120
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1119
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1120
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1121 1121
 			
1122 1122
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1123 1123
 			{
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1135 1135
 		}
1136 1136
 
1137
-		$query  = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1137
+		$query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1138 1138
 
1139 1139
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1140 1140
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 		
1155 1155
 		date_default_timezone_set('UTC');
1156 1156
 		
1157
-		$filter_query = $this->getFilter($filter,true,true);
1157
+		$filter_query = $this->getFilter($filter, true, true);
1158 1158
 		
1159 1159
 		$limit_query = '';
1160 1160
 		
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 		{
1163 1163
 			$limit_array = explode(",", $limit);
1164 1164
 			
1165
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1166
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1165
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1166
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1167 1167
 			
1168 1168
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1169 1169
 			{
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1181 1181
 		}
1182 1182
 
1183
-		$query  = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1183
+		$query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1184 1184
 
1185 1185
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1186 1186
 
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 		global $global_query;
1200 1200
 		
1201 1201
 		date_default_timezone_set('UTC');
1202
-		$filter_query = $this->getFilter($filter,true,true);
1202
+		$filter_query = $this->getFilter($filter, true, true);
1203 1203
 		$limit_query = '';
1204 1204
 		if ($limit != "")
1205 1205
 		{
1206 1206
 			$limit_array = explode(",", $limit);
1207 1207
 			
1208
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1209
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1208
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1209
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1210 1210
 			
1211 1211
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1212 1212
 			{
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1224 1224
 		}
1225 1225
 
1226
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1226
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1227 1227
 
1228 1228
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1229 1229
 
@@ -1247,9 +1247,9 @@  discard block
 block discarded – undo
1247 1247
 		$query_values = array(':id' => $id);
1248 1248
 
1249 1249
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1250
-		$query  = $global_query." WHERE ".$additional_query." ";
1250
+		$query = $global_query." WHERE ".$additional_query." ";
1251 1251
 
1252
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1252
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1253 1253
 
1254 1254
 		return $spotter_array;
1255 1255
 	}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 		$query_values = array();
1273 1273
 		$limit_query = '';
1274 1274
 		$additional_query = '';
1275
-		$filter_query = $this->getFilter($filter,true,true);
1275
+		$filter_query = $this->getFilter($filter, true, true);
1276 1276
 		if ($ident != "")
1277 1277
 		{
1278 1278
 			if (!is_string($ident))
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		{
1289 1289
 			$limit_array = explode(",", $limit);
1290 1290
 			
1291
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1292
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1291
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1292
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1293 1293
 			
1294 1294
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1295 1295
 			{
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 		$query_values = array();
1329 1329
 		$limit_query = '';
1330 1330
 		$additional_query = '';
1331
-		$filter_query = $this->getFilter($filter,true,true);
1331
+		$filter_query = $this->getFilter($filter, true, true);
1332 1332
 		if ($owner != "")
1333 1333
 		{
1334 1334
 			if (!is_string($owner))
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 		{
1345 1345
 			$limit_array = explode(",", $limit);
1346 1346
 			
1347
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1348
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1347
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1348
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1349 1349
 			
1350 1350
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1351 1351
 			{
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		$query_values = array();
1386 1386
 		$limit_query = '';
1387 1387
 		$additional_query = '';
1388
-		$filter_query = $this->getFilter($filter,true,true);
1388
+		$filter_query = $this->getFilter($filter, true, true);
1389 1389
 		if ($pilot != "")
1390 1390
 		{
1391 1391
 			$additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
 		{
1397 1397
 			$limit_array = explode(",", $limit);
1398 1398
 			
1399
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1400
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1399
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1400
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1401 1401
 			
1402 1402
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1403 1403
 			{
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		$query_values = array();
1439 1439
 		$limit_query = '';
1440 1440
 		$additional_query = '';
1441
-		$filter_query = $this->getFilter($filter,true,true);
1441
+		$filter_query = $this->getFilter($filter, true, true);
1442 1442
 		
1443 1443
 		if ($aircraft_type != "")
1444 1444
 		{
@@ -1455,8 +1455,8 @@  discard block
 block discarded – undo
1455 1455
 		{
1456 1456
 			$limit_array = explode(",", $limit);
1457 1457
 			
1458
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1459
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1458
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1459
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1460 1460
 			
1461 1461
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1462 1462
 			{
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
 		{
1513 1513
 			$limit_array = explode(",", $limit);
1514 1514
 			
1515
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1516
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1515
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1516
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1517 1517
 			
1518 1518
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1519 1519
 			{
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		} else {
1530 1530
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1531 1531
 		}
1532
-		$filter_query = $this->getFilter($filter,true,true);
1532
+		$filter_query = $this->getFilter($filter, true, true);
1533 1533
 
1534 1534
 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1535 1535
 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query;
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	* @return Array the spotter information
1549 1549
 	*
1550 1550
 	*/
1551
-	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1551
+	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
1554 1554
 		
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 		$query_values = array();
1558 1558
 		$limit_query = '';
1559 1559
 		$additional_query = '';
1560
-		$filter_query = $this->getFilter($filters,true,true);
1560
+		$filter_query = $this->getFilter($filters, true, true);
1561 1561
 		
1562 1562
 		if ($airline != "")
1563 1563
 		{
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 		{
1575 1575
 			$limit_array = explode(",", $limit);
1576 1576
 			
1577
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1578
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1577
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1578
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1579 1579
 			
1580 1580
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1581 1581
 			{
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 	* @return Array the spotter information
1606 1606
 	*
1607 1607
 	*/
1608
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1608
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
1611 1611
 		
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		$query_values = array();
1614 1614
 		$limit_query = '';
1615 1615
 		$additional_query = '';
1616
-		$filter_query = $this->getFilter($filters,true,true);
1616
+		$filter_query = $this->getFilter($filters, true, true);
1617 1617
 		
1618 1618
 		if ($airport != "")
1619 1619
 		{
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 		{
1631 1631
 			$limit_array = explode(",", $limit);
1632 1632
 			
1633
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1634
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1633
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1634
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1635 1635
 			
1636 1636
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1637 1637
 			{
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 	* @return Array the spotter information
1664 1664
 	*
1665 1665
 	*/
1666
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1666
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
1669 1669
 		
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 		$limit_query = '';
1672 1672
 		$additional_query = '';
1673 1673
 
1674
-		$filter_query = $this->getFilter($filter,true,true);
1674
+		$filter_query = $this->getFilter($filter, true, true);
1675 1675
 		
1676 1676
 		if ($date != "")
1677 1677
 		{
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 		{
1701 1701
 			$limit_array = explode(",", $limit);
1702 1702
 			
1703
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1704
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1703
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1704
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1705 1705
 			
1706 1706
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1707 1707
 			{
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	* @return Array the spotter information
1732 1732
 	*
1733 1733
 	*/
1734
-	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1734
+	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
1737 1737
 		
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 		$query_values = array();
1741 1741
 		$limit_query = '';
1742 1742
 		$additional_query = '';
1743
-		$filter_query = $this->getFilter($filters,true,true);
1743
+		$filter_query = $this->getFilter($filters, true, true);
1744 1744
 		if ($country != "")
1745 1745
 		{
1746 1746
 			if (!is_string($country))
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 		{
1758 1758
 			$limit_array = explode(",", $limit);
1759 1759
 			
1760
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1761
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1760
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1761
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1762 1762
 			
1763 1763
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1764 1764
 			{
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
 		$query_values = array();
1799 1799
 		$additional_query = '';
1800 1800
 		$limit_query = '';
1801
-		$filter_query = $this->getFilter($filters,true,true);
1801
+		$filter_query = $this->getFilter($filters, true, true);
1802 1802
 		
1803 1803
 		if ($aircraft_manufacturer != "")
1804 1804
 		{
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 		{
1816 1816
 			$limit_array = explode(",", $limit);
1817 1817
 			
1818
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1819
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1818
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1819
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1820 1820
 			
1821 1821
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1822 1822
 			{
@@ -1858,14 +1858,14 @@  discard block
 block discarded – undo
1858 1858
 		$query_values = array();
1859 1859
 		$additional_query = '';
1860 1860
 		$limit_query = '';
1861
-		$filter_query = $this->getFilter($filters,true,true);
1861
+		$filter_query = $this->getFilter($filters, true, true);
1862 1862
 		if ($departure_airport_icao != "")
1863 1863
 		{
1864 1864
 			if (!is_string($departure_airport_icao))
1865 1865
 			{
1866 1866
 				return false;
1867 1867
 			} else {
1868
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1868
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1869 1869
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1870 1870
 				//$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao";
1871 1871
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
@@ -1878,10 +1878,10 @@  discard block
 block discarded – undo
1878 1878
 			{
1879 1879
 				return false;
1880 1880
 			} else {
1881
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1881
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1882 1882
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1883 1883
 				//$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)";
1884
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1884
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1885 1885
 			}
1886 1886
 		}
1887 1887
 		
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 		{
1890 1890
 			$limit_array = explode(",", $limit);
1891 1891
 			
1892
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1893
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1892
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1893
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1894 1894
 			
1895 1895
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1896 1896
 			{
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
 		global $global_query;
1930 1930
 		
1931 1931
 		date_default_timezone_set('UTC');
1932
-		$filter_query = $this->getFilter($filter,true,true);
1932
+		$filter_query = $this->getFilter($filter, true, true);
1933 1933
 		$limit_query = '';
1934 1934
 		
1935 1935
 		if ($limit != "")
1936 1936
 		{
1937 1937
 			$limit_array = explode(",", $limit);
1938 1938
 			
1939
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1940
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1939
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1940
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1941 1941
 			
1942 1942
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1943 1943
 			{
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1955 1955
 		}
1956 1956
 
1957
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1957
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1958 1958
 
1959 1959
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1960 1960
 
@@ -1967,19 +1967,19 @@  discard block
 block discarded – undo
1967 1967
 	* @return String the highlight text
1968 1968
 	*
1969 1969
 	*/
1970
-	public function getHighlightByRegistration($registration,$filter = array())
1970
+	public function getHighlightByRegistration($registration, $filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
1973 1973
 		
1974 1974
 		date_default_timezone_set('UTC');
1975
-		$filter_query = $this->getFilter($filter,true,true);
1976
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1975
+		$filter_query = $this->getFilter($filter, true, true);
1976
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1977 1977
 		
1978
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1978
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1979 1979
 		$sth = $this->db->prepare($query);
1980 1980
 		$sth->execute(array(':registration' => $registration));
1981 1981
 
1982
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1982
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1983 1983
 		{
1984 1984
 			$highlight = $row['highlight'];
1985 1985
 		}
@@ -1995,14 +1995,14 @@  discard block
 block discarded – undo
1995 1995
 	* @return String usage
1996 1996
 	*
1997 1997
 	*/
1998
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1998
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1999 1999
 	{
2000 2000
 		
2001
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
2002
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
2001
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
2002
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
2003 2003
 
2004 2004
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
2005
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
2005
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
2006 2006
 		
2007 2007
 		$sth = $this->db->prepare($query);
2008 2008
 		$sth->execute($query_values);
@@ -2024,9 +2024,9 @@  discard block
 block discarded – undo
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
2027
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
2027
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
2028 2028
 
2029
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2029
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2030 2030
 		$query_values = array(':airport' => $airport_iata);
2031 2031
 		
2032 2032
 		$sth = $this->db->prepare($query);
@@ -2048,12 +2048,12 @@  discard block
 block discarded – undo
2048 2048
 	* @return Float distance to the airport
2049 2049
 	*
2050 2050
 	*/
2051
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
2051
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
2052 2052
 	{
2053 2053
 		
2054
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
2054
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
2055 2055
 
2056
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2056
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2057 2057
 		$query_values = array(':airport' => $airport_icao);
2058 2058
 		$sth = $this->db->prepare($query);
2059 2059
 		$sth->execute($query_values);
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 			$airport_latitude = $row['latitude'];
2064 2064
 			$airport_longitude = $row['longitude'];
2065 2065
 			$Common = new Common();
2066
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2066
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
2067 2067
 		} else return '';
2068 2068
 	}
2069 2069
 	
@@ -2077,11 +2077,11 @@  discard block
 block discarded – undo
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
2080
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
2080
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
2081 2081
 
2082 2082
 		$query_values = array();
2083 2083
 		if ($airport == 'NA') {
2084
-			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => ''));
2084
+			return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => ''));
2085 2085
 		} elseif ($airport == '') {
2086 2086
 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport";
2087 2087
 		} else {
@@ -2129,14 +2129,14 @@  discard block
 block discarded – undo
2129 2129
 	{
2130 2130
 		$lst_countries = '';
2131 2131
 		foreach ($countries as $country) {
2132
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
2132
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
2133 2133
 			if ($lst_countries == '') {
2134 2134
 				$lst_countries = "'".$country."'";
2135 2135
 			} else {
2136 2136
 				$lst_countries .= ",'".$country."'";
2137 2137
 			}
2138 2138
 		}
2139
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2139
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2140 2140
 		
2141 2141
 		$sth = $this->db->prepare($query);
2142 2142
 		$sth->execute();
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		$airport_array = array();
2145 2145
 		$temp_array = array();
2146 2146
 		
2147
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2147
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2148 2148
 		{
2149 2149
 			$temp_array['name'] = $row['name'];
2150 2150
 			$temp_array['city'] = $row['city'];
@@ -2172,10 +2172,10 @@  discard block
 block discarded – undo
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
2174 2174
 		if (is_array($coord)) {
2175
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2176
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2175
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2176
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2177
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2178
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2179 2179
 		} else return array();
2180 2180
 		if ($globalDBdriver == 'mysql') {
2181 2181
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
     
2188 2188
 		$airport_array = array();
2189 2189
 		
2190
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2190
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2191 2191
 		{
2192 2192
 			$temp_array = $row;
2193 2193
 
@@ -2207,13 +2207,13 @@  discard block
 block discarded – undo
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
2210
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2211
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2210
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2211
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2212
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2213
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2214 2214
 		} else return array();
2215 2215
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216
-		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2216
+		$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2217 2217
 		//$query  = "SELECT waypoints.* FROM waypoints";
2218 2218
 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end";
2219 2219
 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
     
2226 2226
 		$waypoints_array = array();
2227 2227
 		
2228
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2228
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2229 2229
 		{
2230 2230
 			$temp_array = $row;
2231 2231
 
@@ -2247,10 +2247,10 @@  discard block
 block discarded – undo
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
2249 2249
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2250
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2250
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2251 2251
 		if ($airline_icao == 'NA') {
2252 2252
 			$airline_array = array();
2253
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2253
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2254 2254
 			return $airline_array;
2255 2255
 		} else {
2256 2256
 			if (strlen($airline_icao) == 2) {
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
 			if ($fromsource === NULL) {
2272 2272
 				$sth->execute(array(':airline_icao' => $airline_icao));
2273 2273
 			} else {
2274
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2274
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2275 2275
 			}
2276 2276
                         /*
2277 2277
 			$airline_array = array();
@@ -2316,13 +2316,13 @@  discard block
 block discarded – undo
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
2318 2318
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2319
-		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320
-		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2319
+		$airline_name = strtolower(filter_var($airline_name, FILTER_SANITIZE_STRING));
2320
+		$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2321
 		$sth = $this->db->prepare($query);
2322 2322
 		if ($fromsource === NULL) {
2323 2323
 			$sth->execute(array(':airline_name' => $airline_name));
2324 2324
 		} else {
2325
-			$sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource));
2325
+			$sth->execute(array(':airline_name' => $airline_name, ':fromsource' => $fromsource));
2326 2326
 		}
2327 2327
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2328 2328
 		if (empty($result) && $fromsource !== NULL) {
@@ -2347,12 +2347,12 @@  discard block
 block discarded – undo
2347 2347
 	*/
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2350
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2351 2351
 
2352 2352
 		if ($aircraft_type == 'NA') {
2353
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2353
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2354 2354
 		}
2355
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2355
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2356 2356
 		
2357 2357
 		$sth = $this->db->prepare($query);
2358 2358
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 	*/
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2387
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2388 2388
 		$all_aircraft = array('737-300' => 'B733',
2389 2389
 				'777-200' => 'B772',
2390 2390
 				'777-200ER' => 'B772',
@@ -2396,10 +2396,10 @@  discard block
 block discarded – undo
2396 2396
 				'A380' => 'A388');
2397 2397
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2398 2398
 
2399
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2399
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2400
 		$aircraft_type = strtoupper($aircraft_type);
2401 2401
 		$sth = $this->db->prepare($query);
2402
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2402
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2403 2403
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404 2404
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405 2405
 		else return '';
@@ -2412,10 +2412,10 @@  discard block
 block discarded – undo
2412 2412
 	* @return String aircraft type
2413 2413
 	*
2414 2414
 	*/
2415
-	public function getAllAircraftType($aircraft_modes,$source_type = '')
2415
+	public function getAllAircraftType($aircraft_modes, $source_type = '')
2416 2416
 	{
2417
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2418
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
2417
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2418
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
2419 2419
 
2420 2420
 		if ($source_type == '' || $source_type == 'modes') {
2421 2421
 			$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
@@ -2446,9 +2446,9 @@  discard block
 block discarded – undo
2446 2446
 	*/
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2449
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2450 2450
 
2451
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2451
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2452 2452
 		
2453 2453
 		$sth = $this->db->prepare($query);
2454 2454
 		$sth->execute(array(':registration' => $registration));
@@ -2469,9 +2469,9 @@  discard block
 block discarded – undo
2469 2469
 	*/
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2472
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2473 2473
 
2474
-		$query  = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2474
+		$query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2475 2475
 		
2476 2476
 		$sth = $this->db->prepare($query);
2477 2477
 		$sth->execute(array(':registration' => $registration));
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 		$idarray = array();
2480 2480
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
2481 2481
 			$date = $row['date'];
2482
-			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']);
2482
+			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'], 'spotter_id' => $row['spotter_id']);
2483 2483
 		}
2484 2484
 		return $idarray;
2485 2485
 	}
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	*/
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2497
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2496
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2497
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2498 2498
 		
2499 2499
 		$sth = $this->db->prepare($query);
2500 2500
 		$sth->execute(array(':operator' => $operator));
@@ -2515,9 +2515,9 @@  discard block
 block discarded – undo
2515 2515
 	*/
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2518
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2519 2519
                 if ($callsign == '') return array();
2520
-		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2520
+		$query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2521 2521
 		
2522 2522
 		$sth = $this->db->prepare($query);
2523 2523
 		$sth->execute(array(':callsign' => $callsign));
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 	*/
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2541
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2542 2542
 
2543
-		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2543
+		$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2544 2544
 		
2545 2545
 		$sth = $this->db->prepare($query);
2546 2546
 		$sth->execute(array(':registration' => $registration));
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 		$aircraft_array = array();
2549 2549
 		$temp_array = array();
2550 2550
 		
2551
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2551
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2552 2552
 		{
2553 2553
 			$temp_array['airline_icao'] = $row['airline_icao'];
2554 2554
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
 	*/
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2573
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2574 2574
 		$Connection = new Connection($this->db);
2575 2575
 		if ($Connection->tableExists('aircraft_owner')) {
2576 2576
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 	public function getAllFlightsforSitemap()
2593 2593
 	{
2594 2594
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
2595
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2595
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
@@ -2639,7 +2639,7 @@  discard block
 block discarded – undo
2639 2639
 		$manufacturer_array = array();
2640 2640
 		$temp_array = array();
2641 2641
 		
2642
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2642
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2643 2643
 		{
2644 2644
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2645 2645
 
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 		$aircraft_array = array();
2677 2677
 		$temp_array = array();
2678 2678
 		
2679
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2679
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2680 2680
 		{
2681 2681
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2682 2682
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2697,8 +2697,8 @@  discard block
 block discarded – undo
2697 2697
 	*/
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700
-		$filter_query = $this->getFilter($filters,true,true);
2701
-		$query  = "SELECT DISTINCT spotter_output.registration 
2700
+		$filter_query = $this->getFilter($filters, true, true);
2701
+		$query = "SELECT DISTINCT spotter_output.registration 
2702 2702
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' 
2703 2703
 				ORDER BY spotter_output.registration ASC";
2704 2704
 
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
 		$aircraft_array = array();
2709 2709
 		$temp_array = array();
2710 2710
 		
2711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2712 2712
 		{
2713 2713
 			$temp_array['registration'] = $row['registration'];
2714 2714
 
@@ -2725,11 +2725,11 @@  discard block
 block discarded – undo
2725 2725
 	* @return Array list of source name
2726 2726
 	*
2727 2727
 	*/
2728
-	public function getAllSourceName($type = '',$filters = array())
2728
+	public function getAllSourceName($type = '', $filters = array())
2729 2729
 	{
2730
-		$filter_query = $this->getFilter($filters,true,true);
2730
+		$filter_query = $this->getFilter($filters, true, true);
2731 2731
 		$query_values = array();
2732
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2732
+		$query = "SELECT DISTINCT spotter_output.source_name 
2733 2733
 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''";
2734 2734
 		if ($type != '') {
2735 2735
 			$query_values = array(':type' => $type);
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
 		$source_array = array();
2745 2745
 		$temp_array = array();
2746 2746
 		
2747
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2747
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2748 2748
 		{
2749 2749
 			$temp_array['source_name'] = $row['source_name'];
2750 2750
 			$source_array[] = $temp_array;
@@ -2760,11 +2760,11 @@  discard block
 block discarded – undo
2760 2760
 	* @return Array list of airline names
2761 2761
 	*
2762 2762
 	*/
2763
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2763
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array())
2764 2764
 	{
2765
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2766
-		$filter_query = $this->getFilter($filters,true,true);
2767
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2765
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2766
+		$filter_query = $this->getFilter($filters, true, true);
2767
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2768 2768
 		if ($airline_type == '' || $airline_type == 'all') {
2769 2769
 			/*
2770 2770
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 				$query_data = array(':forsource' => $forsource);
2784 2784
 			}
2785 2785
 		} else {
2786
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2786
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2787 2787
 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
2788 2788
 					AND spotter_output.airline_type = :airline_type 
2789 2789
 					ORDER BY spotter_output.airline_icao ASC";
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
 		$airline_array = array();
2797 2797
 		$temp_array = array();
2798 2798
 		
2799
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2799
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2800 2800
 		{
2801 2801
 			$temp_array['airline_icao'] = $row['airline_icao'];
2802 2802
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2813,10 +2813,10 @@  discard block
 block discarded – undo
2813 2813
 	* @return Array list of alliance names
2814 2814
 	*
2815 2815
 	*/
2816
-	public function getAllAllianceNames($forsource = NULL,$filters = array())
2816
+	public function getAllAllianceNames($forsource = NULL, $filters = array())
2817 2817
 	{
2818
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819
-		$filter_query = $this->getFilter($filters,true,true);
2818
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2819
+		$filter_query = $this->getFilter($filters, true, true);
2820 2820
 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821 2821
 		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822 2822
 		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	*/
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847
-		$filter_query = $this->getFilter($filters,true,true);
2848
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2847
+		$filter_query = $this->getFilter($filters, true, true);
2848
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2849 2849
 				FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2850 2850
 				ORDER BY spotter_output.airline_country ASC";
2851 2851
 		
@@ -2856,7 +2856,7 @@  discard block
 block discarded – undo
2856 2856
 		$airline_array = array();
2857 2857
 		$temp_array = array();
2858 2858
 		
2859
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2859
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2860 2860
 		{
2861 2861
 			$temp_array['airline_country'] = $row['airline_country'];
2862 2862
 
@@ -2876,9 +2876,9 @@  discard block
 block discarded – undo
2876 2876
 	*/
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879
-		$filter_query = $this->getFilter($filters,true,true);
2879
+		$filter_query = $this->getFilter($filters, true, true);
2880 2880
 		$airport_array = array();
2881
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2881
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2882 2882
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2883 2883
 				ORDER BY spotter_output.departure_airport_city ASC";
2884 2884
 		
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
 		$sth->execute();
2888 2888
 
2889 2889
 		$temp_array = array();
2890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2891 2891
 		{
2892 2892
 			$temp_array['airport_icao'] = $row['airport_icao'];
2893 2893
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2897,14 +2897,14 @@  discard block
 block discarded – undo
2897 2897
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2898 2898
 		}
2899 2899
 
2900
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2900
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2901 2901
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2902 2902
 								ORDER BY spotter_output.arrival_airport_city ASC";
2903 2903
 					
2904 2904
 		$sth = $this->db->prepare($query);
2905 2905
 		$sth->execute();
2906 2906
 
2907
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2907
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2908 2908
 			{
2909 2909
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2910 2910
 		//	{
@@ -2928,8 +2928,8 @@  discard block
 block discarded – undo
2928 2928
 	*/
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931
-		$filter_query = $this->getFilter($filters,true,true);
2932
-		$query  = "SELECT DISTINCT spotter_output.owner_name
2931
+		$filter_query = $this->getFilter($filters, true, true);
2932
+		$query = "SELECT DISTINCT spotter_output.owner_name
2933 2933
 				FROM spotter_output".$filter_query." spotter_output.owner_name <> '' 
2934 2934
 				ORDER BY spotter_output.owner_name ASC";
2935 2935
 		
@@ -2946,8 +2946,8 @@  discard block
 block discarded – undo
2946 2946
 	*/
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949
-		$filter_query = $this->getFilter($filters,true,true);
2950
-		$query  = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2949
+		$filter_query = $this->getFilter($filters, true, true);
2950
+		$query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2951 2951
 				FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' 
2952 2952
 				ORDER BY spotter_output.pilot_name ASC";
2953 2953
 		
@@ -2980,21 +2980,21 @@  discard block
 block discarded – undo
2980 2980
    
2981 2981
 		$temp_array = array();
2982 2982
 		
2983
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2983
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2984 2984
 		{
2985 2985
 			$temp_array['airport_country'] = $row['airport_country'];
2986 2986
 
2987 2987
 			$airport_array[$row['airport_country']] = $temp_array;
2988 2988
 		}
2989
-		$filter_query = $this->getFilter($filters,true,true);
2990
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2989
+		$filter_query = $this->getFilter($filters, true, true);
2990
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2991 2991
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2992 2992
 								ORDER BY spotter_output.arrival_airport_country ASC";
2993 2993
 					
2994 2994
 		$sth = $this->db->prepare($query);
2995 2995
 		$sth->execute();
2996 2996
 		
2997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2998 2998
 		{
2999 2999
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
3000 3000
 			{
@@ -3017,9 +3017,9 @@  discard block
 block discarded – undo
3017 3017
 	*/
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020
-		$Connection= new Connection($this->db);
3020
+		$Connection = new Connection($this->db);
3021 3021
 		if ($Connection->tableExists('countries')) {
3022
-			$query  = "SELECT countries.name AS airport_country
3022
+			$query = "SELECT countries.name AS airport_country
3023 3023
 				FROM countries
3024 3024
 				ORDER BY countries.name ASC";
3025 3025
 			$sth = $this->db->prepare($query);
@@ -3028,14 +3028,14 @@  discard block
 block discarded – undo
3028 3028
 			$temp_array = array();
3029 3029
 			$country_array = array();
3030 3030
 		
3031
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3031
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3032 3032
 			{
3033 3033
 				$temp_array['country'] = $row['airport_country'];
3034 3034
 				$country_array[$row['airport_country']] = $temp_array;
3035 3035
 			}
3036 3036
 		} else {
3037
-			$filter_query = $this->getFilter($filters,true,true);
3038
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3037
+			$filter_query = $this->getFilter($filters, true, true);
3038
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3039 3039
 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' 
3040 3040
 								ORDER BY spotter_output.departure_airport_country ASC";
3041 3041
 
@@ -3044,20 +3044,20 @@  discard block
 block discarded – undo
3044 3044
    
3045 3045
 			$temp_array = array();
3046 3046
 			$country_array = array();
3047
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3047
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3048 3048
 			{
3049 3049
 				$temp_array['country'] = $row['airport_country'];
3050 3050
 				$country_array[$row['airport_country']] = $temp_array;
3051 3051
 			}
3052 3052
 
3053
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3053
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3054 3054
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
3055 3055
 								ORDER BY spotter_output.arrival_airport_country ASC";
3056 3056
 					
3057 3057
 		$sth = $this->db->prepare($query);
3058 3058
 		$sth->execute();
3059 3059
 		
3060
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3060
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3061 3061
 		{
3062 3062
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
3063 3063
 			{
@@ -3067,14 +3067,14 @@  discard block
 block discarded – undo
3067 3067
 			}
3068 3068
 		}
3069 3069
 		
3070
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3070
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3071 3071
 								FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
3072 3072
 								ORDER BY spotter_output.airline_country ASC";
3073 3073
 					
3074 3074
 		$sth = $this->db->prepare($query);
3075 3075
 		$sth->execute();
3076 3076
 		
3077
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3077
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3078 3078
 		{
3079 3079
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
3080 3080
 			{
@@ -3098,8 +3098,8 @@  discard block
 block discarded – undo
3098 3098
 	*/
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101
-		$filter_query = $this->getFilter($filters,true,true);
3102
-		$query  = "SELECT DISTINCT spotter_output.ident
3101
+		$filter_query = $this->getFilter($filters, true, true);
3102
+		$query = "SELECT DISTINCT spotter_output.ident
3103 3103
 								FROM spotter_output".$filter_query." spotter_output.ident <> '' 
3104 3104
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
3105 3105
 
@@ -3109,7 +3109,7 @@  discard block
 block discarded – undo
3109 3109
 		$ident_array = array();
3110 3110
 		$temp_array = array();
3111 3111
 		
3112
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3112
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3113 3113
 		{
3114 3114
 			$temp_array['ident'] = $row['ident'];
3115 3115
 			$ident_array[] = $temp_array;
@@ -3123,9 +3123,9 @@  discard block
 block discarded – undo
3123 3123
 	* @return Array number, icao, name and city of airports
3124 3124
 	*/
3125 3125
 
3126
-	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3126
+	public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
3128
-		$filter_query = $this->getFilter($filters,true,true);
3128
+		$filter_query = $this->getFilter($filters, true, true);
3129 3129
 		if ($globalTimezone != '') {
3130 3130
 			date_default_timezone_set($globalTimezone);
3131 3131
 			$datetime = new DateTime();
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
3193
-		$filter_query = $this->getFilter($filters,true,true);
3193
+		$filter_query = $this->getFilter($filters, true, true);
3194 3194
 		if ($globalTimezone != '') {
3195 3195
 			date_default_timezone_set($globalTimezone);
3196 3196
 			$datetime = new DateTime();
@@ -3274,7 +3274,7 @@  discard block
 block discarded – undo
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
3277
-		$filter_query = $this->getFilter($filters,true,true);
3277
+		$filter_query = $this->getFilter($filters, true, true);
3278 3278
 		if ($globalTimezone != '') {
3279 3279
 			date_default_timezone_set($globalTimezone);
3280 3280
 			$datetime = new DateTime();
@@ -3307,9 +3307,9 @@  discard block
 block discarded – undo
3307 3307
 	* @return Array number, icao, name and city of airports
3308 3308
 	*/
3309 3309
 
3310
-	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3310
+	public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
3312
-		$filter_query = $this->getFilter($filters,true,true);
3312
+		$filter_query = $this->getFilter($filters, true, true);
3313 3313
 		if ($globalTimezone != '') {
3314 3314
 			date_default_timezone_set($globalTimezone);
3315 3315
 			$datetime = new DateTime();
@@ -3441,12 +3441,12 @@  discard block
 block discarded – undo
3441 3441
 		} else $offset = '+00:00';
3442 3442
 
3443 3443
 		if ($globalDBdriver == 'mysql') {
3444
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3444
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3445 3445
 								FROM spotter_output
3446 3446
 								WHERE spotter_output.date <> '' 
3447 3447
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3448 3448
 		} else {
3449
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3449
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3450 3450
 								FROM spotter_output
3451 3451
 								WHERE spotter_output.date <> '' 
3452 3452
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3458,7 +3458,7 @@  discard block
 block discarded – undo
3458 3458
 		$date_array = array();
3459 3459
 		$temp_array = array();
3460 3460
 		
3461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3462 3462
 		{
3463 3463
 			$temp_array['date'] = $row['date'];
3464 3464
 
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 	*/
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
3481
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3481
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3482 3482
 				FROM spotter_output
3483 3483
 				WHERE spotter_output.ident <> '' 
3484 3484
 				GROUP BY route
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
 
3490 3490
 		$routes_array = array();
3491 3491
 		$temp_array = array();
3492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3493 3493
 		{
3494 3494
 			$temp_array['route'] = $row['route'];
3495 3495
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3508,21 +3508,21 @@  discard block
 block discarded – undo
3508 3508
 	* @return String success or false
3509 3509
 	*
3510 3510
 	*/	
3511
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3511
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
3514 3514
 		{
3515 3515
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3516
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3516
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3517 3517
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3518
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3518
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3519 3519
 			} else {
3520 3520
 				$airline_array = $this->getAllAirlineInfo("NA");
3521 3521
 			}
3522 3522
 			if (count($airline_array) == 0) {
3523 3523
 				$airline_array = $this->getAllAirlineInfo("NA");
3524 3524
 			}
3525
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3525
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3526 3526
 				$airline_array = $this->getAllAirlineInfo("NA");
3527 3527
 			}
3528 3528
 		} else {
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
3535 3535
 
3536 3536
 
3537 3537
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
3538
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3538
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type);
3539 3539
 
3540 3540
 		try {
3541 3541
 			$sth = $this->db->prepare($query);
@@ -3556,11 +3556,11 @@  discard block
 block discarded – undo
3556 3556
 	* @return String success or false
3557 3557
 	*
3558 3558
 	*/	
3559
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3559
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3560 3560
 	{
3561 3561
 		if ($groundspeed == '') $groundspeed = NULL;
3562 3562
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3563
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3563
+                $query_values = array(':flightaware_id' => $flightaware_id, ':real_arrival_airport_icao' => $arrival_airport_icao, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3564 3564
 
3565 3565
 		try {
3566 3566
 			$sth = $this->db->prepare($query);
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
 	* @param String $verticalrate vertival rate of flight
3601 3601
 	* @return String success or false
3602 3602
 	*/
3603
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '',$source_type = '')
3603
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '', $source_type = '')
3604 3604
 	{
3605 3605
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3606 3606
 		
@@ -3623,14 +3623,14 @@  discard block
 block discarded – undo
3623 3623
 			} else {
3624 3624
 				if ($ModeS != '') {
3625 3625
 					$timeelapsed = microtime(true);
3626
-					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3626
+					$registration = $this->getAircraftRegistrationBymodeS($ModeS, $source_type);
3627
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3628 3628
 				} else {
3629
-					$myhex = explode('-',$flightaware_id);
3629
+					$myhex = explode('-', $flightaware_id);
3630 3630
 					if (count($myhex) > 0) {
3631 3631
 						$timeelapsed = microtime(true);
3632
-						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3632
+						$registration = $this->getAircraftRegistrationBymodeS($myhex[0], $source_type);
3633
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3634 3634
 					}
3635 3635
 				}
3636 3636
 			}
@@ -3652,24 +3652,24 @@  discard block
 block discarded – undo
3652 3652
 				{
3653 3653
 					$timeelapsed = microtime(true);
3654 3654
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3655
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3655
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3656 3656
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3657
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3657
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3658 3658
 					} else {
3659 3659
 						$airline_array = $this->getAllAirlineInfo("NA");
3660 3660
 					}
3661 3661
 					if (count($airline_array) == 0) {
3662 3662
 						$airline_array = $this->getAllAirlineInfo("NA");
3663 3663
 					}
3664
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3664
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3665 3665
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3666
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3667
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3668 3668
 
3669 3669
 				} else {
3670 3670
 					$timeelapsed = microtime(true);
3671 3671
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3672
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3673 3673
 				}
3674 3674
 			}
3675 3675
 		} else $airline_array = array();
@@ -3686,27 +3686,27 @@  discard block
 block discarded – undo
3686 3686
 				{
3687 3687
 					$timeelapsed = microtime(true);
3688 3688
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3689
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3690 3690
 				} else {
3691 3691
 					$timeelapsed = microtime(true);
3692 3692
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3693
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3694 3694
 				}
3695 3695
 			}
3696 3696
 		} else {
3697 3697
 			if ($ModeS != '') {
3698 3698
 				$timeelapsed = microtime(true);
3699
-				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3699
+				$aircraft_icao = $this->getAllAircraftType($ModeS, $source_type);
3700
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3701 3701
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3702
 				{
3703 3703
 					$timeelapsed = microtime(true);
3704 3704
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3705
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3706 3706
 				} else {
3707 3707
 					$timeelapsed = microtime(true);
3708 3708
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3709
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3710 3710
 				}
3711 3711
 			}
3712 3712
 		}
@@ -3722,7 +3722,7 @@  discard block
 block discarded – undo
3722 3722
 			} else {
3723 3723
 				$timeelapsed = microtime(true);
3724 3724
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3725
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3726 3726
 			}
3727 3727
 		}
3728 3728
 		
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
 			} else {
3738 3738
 				$timeelapsed = microtime(true);
3739 3739
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3740
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3741 3741
 			}
3742 3742
 		}
3743 3743
 
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 		}
3791 3791
 
3792 3792
     
3793
-		if ($date == "" || strtotime($date) < time()-20*60)
3793
+		if ($date == "" || strtotime($date) < time() - 20*60)
3794 3794
 		{
3795 3795
 			$date = date("Y-m-d H:i:s", time());
3796 3796
 		}
@@ -3800,7 +3800,7 @@  discard block
 block discarded – undo
3800 3800
 		{
3801 3801
 			$timeelapsed = microtime(true);
3802 3802
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3803
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3804 3804
 			if (!isset($image_array[0]['registration']))
3805 3805
 			{
3806 3806
 				//echo "Add image !!!! \n";
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 			}
3809 3809
 			$timeelapsed = microtime(true);
3810 3810
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3811
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3812 3812
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3813 3813
 		}
3814 3814
     
@@ -3816,33 +3816,33 @@  discard block
 block discarded – undo
3816 3816
 		{
3817 3817
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818 3818
             		else $airline_icao = '';
3819
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3819
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
3822 3822
 				//echo "Add image !!!! \n";
3823
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3823
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3824 3824
 			}
3825 3825
 		}
3826 3826
     
3827
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3828
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3829
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3830
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3831
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3832
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3833
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3834
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3835
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3836
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3837
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3838
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3839
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3840
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3841
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3842
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3843
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3844
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3845
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3827
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3828
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3829
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3830
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3831
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3832
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3833
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3834
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3835
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3836
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3837
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3838
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3839
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3840
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3841
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3842
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3843
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3844
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3845
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
@@ -3870,7 +3870,7 @@  discard block
 block discarded – undo
3870 3870
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871 3871
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872 3872
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3873
+                $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3874 3874
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3875 3875
 
3876 3876
                 $airline_name = $airline_array[0]['name'];
@@ -3880,7 +3880,7 @@  discard block
 block discarded – undo
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3883
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3884 3884
 		}
3885 3885
 		if ($airline_type == null) $airline_type = '';
3886 3886
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3892,7 +3892,7 @@  discard block
 block discarded – undo
3892 3892
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3893 3893
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3894 3894
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3895
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3895
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3896 3896
 
3897 3897
 		try {
3898 3898
 		        
@@ -3918,13 +3918,13 @@  discard block
 block discarded – undo
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
3920 3920
 		if ($globalDBdriver == 'mysql') {
3921
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3921
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3922 3922
 								WHERE spotter_output.ident = :ident 
3923 3923
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3924 3924
 								AND spotter_output.date < UTC_TIMESTAMP()";
3925 3925
 			$query_data = array(':ident' => $ident);
3926 3926
 		} else {
3927
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3927
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3928 3928
 								WHERE spotter_output.ident = :ident 
3929 3929
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3930 3930
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3933,8 +3933,8 @@  discard block
 block discarded – undo
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3937
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3936
+    		$ident_result = '';
3937
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
3940 3940
 		}
@@ -3960,8 +3960,8 @@  discard block
 block discarded – undo
3960 3960
 				return false;
3961 3961
 			} else {
3962 3962
 				$q_array = explode(" ", $q);
3963
-				foreach ($q_array as $q_item){
3964
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3963
+				foreach ($q_array as $q_item) {
3964
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3965 3965
 					$additional_query .= " AND (";
3966 3966
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3967 3967
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3976,11 +3976,11 @@  discard block
 block discarded – undo
3976 3976
 			}
3977 3977
 		}
3978 3978
 		if ($globalDBdriver == 'mysql') {
3979
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3979
+			$query = "SELECT spotter_output.* FROM spotter_output 
3980 3980
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3981 3981
 				AND spotter_output.date < UTC_TIMESTAMP()";
3982 3982
 		} else {
3983
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3983
+			$query = "SELECT spotter_output.* FROM spotter_output 
3984 3984
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3985 3985
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3986 3986
 		}
@@ -3997,11 +3997,11 @@  discard block
 block discarded – undo
3997 3997
 	* @return Array the airline list
3998 3998
 	*
3999 3999
 	*/
4000
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4000
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
4003
-		$filter_query = $this->getFilter($filters,true,true);
4004
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4003
+		$filter_query = $this->getFilter($filters, true, true);
4004
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4005 4005
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'";
4006 4006
 		if ($olderthanmonths > 0) {
4007 4007
 			if ($globalDBdriver == 'mysql') {
@@ -4021,28 +4021,28 @@  discard block
 block discarded – undo
4021 4021
 		if ($year != '') {
4022 4022
 			if ($globalDBdriver == 'mysql') {
4023 4023
 				$query .= " AND YEAR(spotter_output.date) = :year";
4024
-				$query_values = array_merge($query_values,array(':year' => $year));
4024
+				$query_values = array_merge($query_values, array(':year' => $year));
4025 4025
 			} else {
4026 4026
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4027
-				$query_values = array_merge($query_values,array(':year' => $year));
4027
+				$query_values = array_merge($query_values, array(':year' => $year));
4028 4028
 			}
4029 4029
 		}
4030 4030
 		if ($month != '') {
4031 4031
 			if ($globalDBdriver == 'mysql') {
4032 4032
 				$query .= " AND MONTH(spotter_output.date) = :month";
4033
-				$query_values = array_merge($query_values,array(':month' => $month));
4033
+				$query_values = array_merge($query_values, array(':month' => $month));
4034 4034
 			} else {
4035 4035
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4036
-				$query_values = array_merge($query_values,array(':month' => $month));
4036
+				$query_values = array_merge($query_values, array(':month' => $month));
4037 4037
 			}
4038 4038
 		}
4039 4039
 		if ($day != '') {
4040 4040
 			if ($globalDBdriver == 'mysql') {
4041 4041
 				$query .= " AND DAY(spotter_output.date) = :day";
4042
-				$query_values = array_merge($query_values,array(':day' => $day));
4042
+				$query_values = array_merge($query_values, array(':day' => $day));
4043 4043
 			} else {
4044 4044
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4045
-				$query_values = array_merge($query_values,array(':day' => $day));
4045
+				$query_values = array_merge($query_values, array(':day' => $day));
4046 4046
 			}
4047 4047
 		}
4048 4048
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
@@ -4052,7 +4052,7 @@  discard block
 block discarded – undo
4052 4052
 		$sth->execute($query_values);
4053 4053
 		$airline_array = array();
4054 4054
 		$temp_array = array();
4055
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4055
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4056 4056
 		{
4057 4057
 			$temp_array['airline_name'] = $row['airline_name'];
4058 4058
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4069,11 +4069,11 @@  discard block
 block discarded – undo
4069 4069
 	* @return Array the pilots list
4070 4070
 	*
4071 4071
 	*/
4072
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4072
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075
-		$filter_query = $this->getFilter($filters,true,true);
4076
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4075
+		$filter_query = $this->getFilter($filters, true, true);
4076
+		$query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4077 4077
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4078 4078
                 if ($olderthanmonths > 0) {
4079 4079
             		if ($globalDBdriver == 'mysql') {
@@ -4093,28 +4093,28 @@  discard block
 block discarded – undo
4093 4093
 		if ($year != '') {
4094 4094
 			if ($globalDBdriver == 'mysql') {
4095 4095
 				$query .= " AND YEAR(spotter_output.date) = :year";
4096
-				$query_values = array_merge($query_values,array(':year' => $year));
4096
+				$query_values = array_merge($query_values, array(':year' => $year));
4097 4097
 			} else {
4098 4098
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4099
-				$query_values = array_merge($query_values,array(':year' => $year));
4099
+				$query_values = array_merge($query_values, array(':year' => $year));
4100 4100
 			}
4101 4101
 		}
4102 4102
 		if ($month != '') {
4103 4103
 			if ($globalDBdriver == 'mysql') {
4104 4104
 				$query .= " AND MONTH(spotter_output.date) = :month";
4105
-				$query_values = array_merge($query_values,array(':month' => $month));
4105
+				$query_values = array_merge($query_values, array(':month' => $month));
4106 4106
 			} else {
4107 4107
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4108
-				$query_values = array_merge($query_values,array(':month' => $month));
4108
+				$query_values = array_merge($query_values, array(':month' => $month));
4109 4109
 			}
4110 4110
 		}
4111 4111
 		if ($day != '') {
4112 4112
 			if ($globalDBdriver == 'mysql') {
4113 4113
 				$query .= " AND DAY(spotter_output.date) = :day";
4114
-				$query_values = array_merge($query_values,array(':day' => $day));
4114
+				$query_values = array_merge($query_values, array(':day' => $day));
4115 4115
 			} else {
4116 4116
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4117
-				$query_values = array_merge($query_values,array(':day' => $day));
4117
+				$query_values = array_merge($query_values, array(':day' => $day));
4118 4118
 			}
4119 4119
 		}
4120 4120
 		
@@ -4126,7 +4126,7 @@  discard block
 block discarded – undo
4126 4126
 		$sth->execute($query_values);
4127 4127
 		$airline_array = array();
4128 4128
 		$temp_array = array();
4129
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4129
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4130 4130
 		{
4131 4131
 			$temp_array['pilot_name'] = $row['pilot_name'];
4132 4132
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4146,7 +4146,7 @@  discard block
 block discarded – undo
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
4149
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4149
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4150 4150
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4151 4151
                 if ($olderthanmonths > 0) {
4152 4152
             		if ($globalDBdriver == 'mysql') {
@@ -4172,7 +4172,7 @@  discard block
 block discarded – undo
4172 4172
 		$airline_array = array();
4173 4173
 		$temp_array = array();
4174 4174
         
4175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4176 4176
 		{
4177 4177
 			$temp_array['pilot_name'] = $row['pilot_name'];
4178 4178
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4190,11 +4190,11 @@  discard block
 block discarded – undo
4190 4190
 	* @return Array the pilots list
4191 4191
 	*
4192 4192
 	*/
4193
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4193
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196
-		$filter_query = $this->getFilter($filters,true,true);
4197
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4196
+		$filter_query = $this->getFilter($filters, true, true);
4197
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4198 4198
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4199 4199
                 if ($olderthanmonths > 0) {
4200 4200
             		if ($globalDBdriver == 'mysql') {
@@ -4214,28 +4214,28 @@  discard block
 block discarded – undo
4214 4214
 		if ($year != '') {
4215 4215
 			if ($globalDBdriver == 'mysql') {
4216 4216
 				$query .= " AND YEAR(spotter_output.date) = :year";
4217
-				$query_values = array_merge($query_values,array(':year' => $year));
4217
+				$query_values = array_merge($query_values, array(':year' => $year));
4218 4218
 			} else {
4219 4219
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4220
-				$query_values = array_merge($query_values,array(':year' => $year));
4220
+				$query_values = array_merge($query_values, array(':year' => $year));
4221 4221
 			}
4222 4222
 		}
4223 4223
 		if ($month != '') {
4224 4224
 			if ($globalDBdriver == 'mysql') {
4225 4225
 				$query .= " AND MONTH(spotter_output.date) = :month";
4226
-				$query_values = array_merge($query_values,array(':month' => $month));
4226
+				$query_values = array_merge($query_values, array(':month' => $month));
4227 4227
 			} else {
4228 4228
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4229
-				$query_values = array_merge($query_values,array(':month' => $month));
4229
+				$query_values = array_merge($query_values, array(':month' => $month));
4230 4230
 			}
4231 4231
 		}
4232 4232
 		if ($day != '') {
4233 4233
 			if ($globalDBdriver == 'mysql') {
4234 4234
 				$query .= " AND DAY(spotter_output.date) = :day";
4235
-				$query_values = array_merge($query_values,array(':day' => $day));
4235
+				$query_values = array_merge($query_values, array(':day' => $day));
4236 4236
 			} else {
4237 4237
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4238
-				$query_values = array_merge($query_values,array(':day' => $day));
4238
+				$query_values = array_merge($query_values, array(':day' => $day));
4239 4239
 			}
4240 4240
 		}
4241 4241
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
@@ -4245,7 +4245,7 @@  discard block
 block discarded – undo
4245 4245
 		$sth->execute($query_values);
4246 4246
 		$airline_array = array();
4247 4247
 		$temp_array = array();
4248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4249 4249
 		{
4250 4250
 			$temp_array['owner_name'] = $row['owner_name'];
4251 4251
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4260,11 +4260,11 @@  discard block
 block discarded – undo
4260 4260
 	* @return Array the pilots list
4261 4261
 	*
4262 4262
 	*/
4263
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4263
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266
-		$filter_query = $this->getFilter($filters,true,true);
4267
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4266
+		$filter_query = $this->getFilter($filters, true, true);
4267
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4268 4268
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4269 4269
                 if ($olderthanmonths > 0) {
4270 4270
             		if ($globalDBdriver == 'mysql') {
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 		$airline_array = array();
4291 4291
 		$temp_array = array();
4292 4292
         
4293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4294 4294
 		{
4295 4295
 			$temp_array['owner_name'] = $row['owner_name'];
4296 4296
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4306,11 +4306,11 @@  discard block
 block discarded – undo
4306 4306
 	* @return Array the airline list
4307 4307
 	*
4308 4308
 	*/
4309
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4309
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
4310 4310
 	{
4311
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4312
-		$filter_query = $this->getFilter($filters,true,true);
4313
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4311
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4312
+		$filter_query = $this->getFilter($filters, true, true);
4313
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4314 4314
 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
4315 4315
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4316 4316
 			    ORDER BY airline_count DESC";
@@ -4322,7 +4322,7 @@  discard block
 block discarded – undo
4322 4322
 		$airline_array = array();
4323 4323
 		$temp_array = array();
4324 4324
         
4325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4326 4326
 		{
4327 4327
 			$temp_array['airline_name'] = $row['airline_name'];
4328 4328
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4342,11 +4342,11 @@  discard block
 block discarded – undo
4342 4342
 	* @return Array the airline country list
4343 4343
 	*
4344 4344
 	*/
4345
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4345
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
4346 4346
 	{
4347
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4348
-		$filter_query = $this->getFilter($filters,true,true);
4349
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4347
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4348
+		$filter_query = $this->getFilter($filters, true, true);
4349
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4350 4350
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
4351 4351
                     GROUP BY spotter_output.airline_country
4352 4352
 					ORDER BY airline_country_count DESC
@@ -4359,7 +4359,7 @@  discard block
 block discarded – undo
4359 4359
 		$airline_country_array = array();
4360 4360
 		$temp_array = array();
4361 4361
         
4362
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4362
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4363 4363
 		{
4364 4364
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4365 4365
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4378,11 +4378,11 @@  discard block
 block discarded – undo
4378 4378
 	* @return Array the airline list
4379 4379
 	*
4380 4380
 	*/
4381
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4381
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
4382 4382
 	{
4383
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4384
-		$filter_query = $this->getFilter($filters,true,true);
4385
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4383
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4384
+		$filter_query = $this->getFilter($filters, true, true);
4385
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4386 4386
 		    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) 
4387 4387
                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country
4388 4388
 		    ORDER BY airline_count DESC";
@@ -4394,7 +4394,7 @@  discard block
 block discarded – undo
4394 4394
 		$airline_array = array();
4395 4395
 		$temp_array = array();
4396 4396
         
4397
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4397
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4398 4398
 		{
4399 4399
 			$temp_array['airline_name'] = $row['airline_name'];
4400 4400
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4413,11 +4413,11 @@  discard block
 block discarded – undo
4413 4413
 	* @return Array the airline country list
4414 4414
 	*
4415 4415
 	*/
4416
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4416
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
4417 4417
 	{
4418
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4419
-		$filter_query = $this->getFilter($filters,true,true);
4420
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4418
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4419
+		$filter_query = $this->getFilter($filters, true, true);
4420
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4421 4421
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )
4422 4422
 					GROUP BY spotter_output.airline_country
4423 4423
 					ORDER BY airline_country_count DESC
@@ -4430,7 +4430,7 @@  discard block
 block discarded – undo
4430 4430
 		$airline_country_array = array();
4431 4431
 		$temp_array = array();
4432 4432
         
4433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4434 4434
 		{
4435 4435
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4436 4436
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4447,11 +4447,11 @@  discard block
 block discarded – undo
4447 4447
 	* @return Array the airline list
4448 4448
 	*
4449 4449
 	*/
4450
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4450
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
4451 4451
 	{
4452
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4453
-		$filter_query = $this->getFilter($filters,true,true);
4454
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4452
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4453
+		$filter_query = $this->getFilter($filters, true, true);
4454
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4455 4455
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4456 4456
 					GROUP BY spotter_output.airline_name
4457 4457
 					ORDER BY airline_count DESC";
@@ -4462,7 +4462,7 @@  discard block
 block discarded – undo
4462 4462
 		$airline_array = array();
4463 4463
 		$temp_array = array();
4464 4464
         
4465
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4465
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4466 4466
 		{
4467 4467
 			$temp_array['airline_name'] = $row['airline_name'];
4468 4468
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4482,11 +4482,11 @@  discard block
 block discarded – undo
4482 4482
 	* @return Array the airline country list
4483 4483
 	*
4484 4484
 	*/
4485
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4485
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4486 4486
 	{
4487
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4488
-		$filter_query = $this->getFilter($filters,true,true);
4489
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4487
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4488
+		$filter_query = $this->getFilter($filters, true, true);
4489
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4490 4490
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4491 4491
 					GROUP BY spotter_output.airline_country
4492 4492
 					ORDER BY airline_country_count DESC
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
 		$airline_country_array = array();
4500 4500
 		$temp_array = array();
4501 4501
         
4502
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4502
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4503 4503
 		{
4504 4504
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4505 4505
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4515,11 +4515,11 @@  discard block
 block discarded – undo
4515 4515
 	* @return Array the airline list
4516 4516
 	*
4517 4517
 	*/
4518
-	public function countAllAirlinesByDate($date,$filters = array())
4518
+	public function countAllAirlinesByDate($date, $filters = array())
4519 4519
 	{
4520 4520
 		global $globalTimezone, $globalDBdriver;
4521
-		$filter_query = $this->getFilter($filters,true,true);
4522
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4521
+		$filter_query = $this->getFilter($filters, true, true);
4522
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4523 4523
 		if ($globalTimezone != '') {
4524 4524
 			date_default_timezone_set($globalTimezone);
4525 4525
 			$datetime = new DateTime($date);
@@ -4527,12 +4527,12 @@  discard block
 block discarded – undo
4527 4527
 		} else $offset = '+00:00';
4528 4528
 
4529 4529
 		if ($globalDBdriver == 'mysql') {
4530
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4530
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4531 4531
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4532 4532
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country 
4533 4533
 					ORDER BY airline_count DESC";
4534 4534
 		} else {
4535
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4535
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4536 4536
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4537 4537
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country
4538 4538
 					ORDER BY airline_count DESC";
@@ -4543,7 +4543,7 @@  discard block
 block discarded – undo
4543 4543
 
4544 4544
 		$airline_array = array();
4545 4545
 		$temp_array = array();
4546
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4546
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4547 4547
 		{
4548 4548
 			$temp_array['airline_name'] = $row['airline_name'];
4549 4549
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4563,11 +4563,11 @@  discard block
 block discarded – undo
4563 4563
 	* @return Array the airline country list
4564 4564
 	*
4565 4565
 	*/
4566
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4566
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4567 4567
 	{
4568 4568
 		global $globalTimezone, $globalDBdriver;
4569
-		$filter_query = $this->getFilter($filters,true,true);
4570
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4569
+		$filter_query = $this->getFilter($filters, true, true);
4570
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4571 4571
 		if ($globalTimezone != '') {
4572 4572
 			date_default_timezone_set($globalTimezone);
4573 4573
 			$datetime = new DateTime($date);
@@ -4575,13 +4575,13 @@  discard block
 block discarded – undo
4575 4575
 		} else $offset = '+00:00';
4576 4576
 		
4577 4577
 		if ($globalDBdriver == 'mysql') {
4578
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4578
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4579 4579
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4580 4580
 					GROUP BY spotter_output.airline_country
4581 4581
 					ORDER BY airline_country_count DESC
4582 4582
 					LIMIT 10 OFFSET 0";
4583 4583
 		} else {
4584
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4584
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4585 4585
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4586 4586
 					GROUP BY spotter_output.airline_country
4587 4587
 					ORDER BY airline_country_count DESC
@@ -4593,7 +4593,7 @@  discard block
 block discarded – undo
4593 4593
  
4594 4594
 		$airline_country_array = array();
4595 4595
 		$temp_array = array();
4596
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4596
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4597 4597
 		{
4598 4598
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4599 4599
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4610,11 +4610,11 @@  discard block
 block discarded – undo
4610 4610
 	* @return Array the airline list
4611 4611
 	*
4612 4612
 	*/
4613
-	public function countAllAirlinesByIdent($ident,$filters = array())
4613
+	public function countAllAirlinesByIdent($ident, $filters = array())
4614 4614
 	{
4615
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4616
-		$filter_query = $this->getFilter($filters,true,true);
4617
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4615
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4616
+		$filter_query = $this->getFilter($filters, true, true);
4617
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4618 4618
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4619 4619
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4620 4620
 				ORDER BY airline_count DESC";
@@ -4631,11 +4631,11 @@  discard block
 block discarded – undo
4631 4631
 	* @return Array the airline list
4632 4632
 	*
4633 4633
 	*/
4634
-	public function countAllAirlinesByOwner($owner,$filters = array())
4634
+	public function countAllAirlinesByOwner($owner, $filters = array())
4635 4635
 	{
4636
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4637
-		$filter_query = $this->getFilter($filters,true,true);
4638
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4636
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4637
+		$filter_query = $this->getFilter($filters, true, true);
4638
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4639 4639
 		 		FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  
4640 4640
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4641 4641
 				ORDER BY airline_count DESC";
@@ -4652,47 +4652,47 @@  discard block
 block discarded – undo
4652 4652
 	* @return String Duration of all flights
4653 4653
 	*
4654 4654
 	*/
4655
-	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4655
+	public function getFlightDurationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
4656 4656
 	{
4657 4657
 		global $globalDBdriver;
4658
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4659
-		$filter_query = $this->getFilter($filters,true,true);
4660
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4658
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4659
+		$filter_query = $this->getFilter($filters, true, true);
4660
+		$query = "SELECT SUM(last_seen - date) AS duration 
4661 4661
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
4662 4662
 				AND last_seen > date";
4663 4663
 		$query_values = array();
4664 4664
 		if ($year != '') {
4665 4665
 			if ($globalDBdriver == 'mysql') {
4666 4666
 				$query .= " AND YEAR(spotter_output.date) = :year";
4667
-				$query_values = array_merge($query_values,array(':year' => $year));
4667
+				$query_values = array_merge($query_values, array(':year' => $year));
4668 4668
 			} else {
4669 4669
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4670
-				$query_values = array_merge($query_values,array(':year' => $year));
4670
+				$query_values = array_merge($query_values, array(':year' => $year));
4671 4671
 			}
4672 4672
 		}
4673 4673
 		if ($month != '') {
4674 4674
 			if ($globalDBdriver == 'mysql') {
4675 4675
 				$query .= " AND MONTH(spotter_output.date) = :month";
4676
-				$query_values = array_merge($query_values,array(':month' => $month));
4676
+				$query_values = array_merge($query_values, array(':month' => $month));
4677 4677
 			} else {
4678 4678
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4679
-				$query_values = array_merge($query_values,array(':month' => $month));
4679
+				$query_values = array_merge($query_values, array(':month' => $month));
4680 4680
 			}
4681 4681
 		}
4682 4682
 		if ($day != '') {
4683 4683
 			if ($globalDBdriver == 'mysql') {
4684 4684
 				$query .= " AND DAY(spotter_output.date) = :day";
4685
-				$query_values = array_merge($query_values,array(':day' => $day));
4685
+				$query_values = array_merge($query_values, array(':day' => $day));
4686 4686
 			} else {
4687 4687
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4688
-				$query_values = array_merge($query_values,array(':day' => $day));
4688
+				$query_values = array_merge($query_values, array(':day' => $day));
4689 4689
 			}
4690 4690
 		}
4691
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4691
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4692 4692
 		$sth = $this->db->prepare($query);
4693 4693
 		$sth->execute($query_values);
4694 4694
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4695
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4695
+		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4696 4696
 		elseif ($result[0]['duration'] == '') return 0;
4697 4697
 		else return $result[0]['duration'];
4698 4698
 	}
@@ -4703,14 +4703,14 @@  discard block
 block discarded – undo
4703 4703
 	* @return String Duration of all flights
4704 4704
 	*
4705 4705
 	*/
4706
-	public function countFlightsByOwner($owner,$filters = array())
4706
+	public function countFlightsByOwner($owner, $filters = array())
4707 4707
 	{
4708
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4709
-		$filter_query = $this->getFilter($filters,true,true);
4710
-		$query  = "SELECT COUNT(*) AS nb 
4708
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4709
+		$filter_query = $this->getFilter($filters, true, true);
4710
+		$query = "SELECT COUNT(*) AS nb 
4711 4711
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
4712 4712
 		$query_values = array();
4713
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4713
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4714 4714
 		$sth = $this->db->prepare($query);
4715 4715
 		$sth->execute($query_values);
4716 4716
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4723,14 +4723,14 @@  discard block
 block discarded – undo
4723 4723
 	* @return String Duration of all flights
4724 4724
 	*
4725 4725
 	*/
4726
-	public function countFlightsByPilot($pilot,$filters = array())
4726
+	public function countFlightsByPilot($pilot, $filters = array())
4727 4727
 	{
4728
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4729
-		$filter_query = $this->getFilter($filters,true,true);
4730
-		$query  = "SELECT COUNT(*) AS nb 
4728
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4729
+		$filter_query = $this->getFilter($filters, true, true);
4730
+		$query = "SELECT COUNT(*) AS nb 
4731 4731
 				FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)";
4732 4732
 		$query_values = array();
4733
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4733
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4734 4734
 		$sth = $this->db->prepare($query);
4735 4735
 		$sth->execute($query_values);
4736 4736
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4743,47 +4743,47 @@  discard block
 block discarded – undo
4743 4743
 	* @return String Duration of all flights
4744 4744
 	*
4745 4745
 	*/
4746
-	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4746
+	public function getFlightDurationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
4747 4747
 	{
4748 4748
 		global $globalDBdriver;
4749
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4750
-		$filter_query = $this->getFilter($filters,true,true);
4751
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4749
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4750
+		$filter_query = $this->getFilter($filters, true, true);
4751
+		$query = "SELECT SUM(last_seen - date) AS duration 
4752 4752
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4753 4753
 		 		AND last_seen > date";
4754 4754
 		$query_values = array();
4755 4755
 		if ($year != '') {
4756 4756
 			if ($globalDBdriver == 'mysql') {
4757 4757
 				$query .= " AND YEAR(spotter_output.date) = :year";
4758
-				$query_values = array_merge($query_values,array(':year' => $year));
4758
+				$query_values = array_merge($query_values, array(':year' => $year));
4759 4759
 			} else {
4760 4760
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4761
-				$query_values = array_merge($query_values,array(':year' => $year));
4761
+				$query_values = array_merge($query_values, array(':year' => $year));
4762 4762
 			}
4763 4763
 		}
4764 4764
 		if ($month != '') {
4765 4765
 			if ($globalDBdriver == 'mysql') {
4766 4766
 				$query .= " AND MONTH(spotter_output.date) = :month";
4767
-				$query_values = array_merge($query_values,array(':month' => $month));
4767
+				$query_values = array_merge($query_values, array(':month' => $month));
4768 4768
 			} else {
4769 4769
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4770
-				$query_values = array_merge($query_values,array(':month' => $month));
4770
+				$query_values = array_merge($query_values, array(':month' => $month));
4771 4771
 			}
4772 4772
 		}
4773 4773
 		if ($day != '') {
4774 4774
 			if ($globalDBdriver == 'mysql') {
4775 4775
 				$query .= " AND DAY(spotter_output.date) = :day";
4776
-				$query_values = array_merge($query_values,array(':day' => $day));
4776
+				$query_values = array_merge($query_values, array(':day' => $day));
4777 4777
 			} else {
4778 4778
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4779
-				$query_values = array_merge($query_values,array(':day' => $day));
4779
+				$query_values = array_merge($query_values, array(':day' => $day));
4780 4780
 			}
4781 4781
 		}
4782
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4782
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4783 4783
 		$sth = $this->db->prepare($query);
4784 4784
 		$sth->execute($query_values);
4785 4785
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4786
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4786
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4787 4787
 		else return $result[0]['duration'];
4788 4788
 	}
4789 4789
 
@@ -4793,11 +4793,11 @@  discard block
 block discarded – undo
4793 4793
 	* @return Array the airline list
4794 4794
 	*
4795 4795
 	*/
4796
-	public function countAllAirlinesByPilot($pilot,$filters = array())
4796
+	public function countAllAirlinesByPilot($pilot, $filters = array())
4797 4797
 	{
4798
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4799
-		$filter_query = $this->getFilter($filters,true,true);
4800
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4798
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4799
+		$filter_query = $this->getFilter($filters, true, true);
4800
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4801 4801
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4802 4802
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4803 4803
 				ORDER BY airline_count DESC";
@@ -4814,25 +4814,25 @@  discard block
 block discarded – undo
4814 4814
 	* @return Array the airline list
4815 4815
 	*
4816 4816
 	*/
4817
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4817
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4818 4818
 	{
4819
-		$filter_query = $this->getFilter($filters,true,true);
4820
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4821
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4819
+		$filter_query = $this->getFilter($filters, true, true);
4820
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4821
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4822 4822
 
4823
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4823
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4824 4824
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4825 4825
 					GROUP BY spotter_output.airline_name
4826 4826
 					ORDER BY airline_count DESC";
4827 4827
       
4828 4828
 		
4829 4829
 		$sth = $this->db->prepare($query);
4830
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4830
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4831 4831
       
4832 4832
 		$airline_array = array();
4833 4833
 		$temp_array = array();
4834 4834
         
4835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4836 4836
 		{
4837 4837
 			$temp_array['airline_name'] = $row['airline_name'];
4838 4838
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4850,13 +4850,13 @@  discard block
 block discarded – undo
4850 4850
 	* @return Array the airline country list
4851 4851
 	*
4852 4852
 	*/
4853
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4853
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4854 4854
 	{
4855
-		$filter_query = $this->getFilter($filters,true,true);
4856
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4857
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4855
+		$filter_query = $this->getFilter($filters, true, true);
4856
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4857
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4858 4858
       
4859
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4859
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4860 4860
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4861 4861
 				GROUP BY spotter_output.airline_country
4862 4862
 				ORDER BY airline_country_count DESC
@@ -4864,11 +4864,11 @@  discard block
 block discarded – undo
4864 4864
       
4865 4865
 		
4866 4866
 		$sth = $this->db->prepare($query);
4867
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4867
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4868 4868
       
4869 4869
 		$airline_country_array = array();
4870 4870
 		$temp_array = array();
4871
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4871
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4872 4872
 		{
4873 4873
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4874 4874
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4886,11 +4886,11 @@  discard block
 block discarded – undo
4886 4886
 	* @return Array the airline list
4887 4887
 	*
4888 4888
 	*/
4889
-	public function countAllAirlinesByCountry($country,$filters = array())
4889
+	public function countAllAirlinesByCountry($country, $filters = array())
4890 4890
 	{
4891
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4892
-		$filter_query = $this->getFilter($filters,true,true);
4893
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4891
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4892
+		$filter_query = $this->getFilter($filters, true, true);
4893
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4894 4894
 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4895 4895
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4896 4896
 			    ORDER BY airline_count DESC";
@@ -4901,7 +4901,7 @@  discard block
 block discarded – undo
4901 4901
 
4902 4902
 		$airline_array = array();
4903 4903
 		$temp_array = array();
4904
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4904
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4905 4905
 		{
4906 4906
 			$temp_array['airline_name'] = $row['airline_name'];
4907 4907
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4920,11 +4920,11 @@  discard block
 block discarded – undo
4920 4920
 	* @return Array the airline country list
4921 4921
 	*
4922 4922
 	*/
4923
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4923
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4924 4924
 	{
4925
-		$filter_query = $this->getFilter($filters,true,true);
4926
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4927
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4925
+		$filter_query = $this->getFilter($filters, true, true);
4926
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4927
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4928 4928
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4929 4929
 				GROUP BY spotter_output.airline_country
4930 4930
 				ORDER BY airline_country_count DESC
@@ -4936,7 +4936,7 @@  discard block
 block discarded – undo
4936 4936
 
4937 4937
 		$airline_country_array = array();
4938 4938
 		$temp_array = array();
4939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4940 4940
 		{
4941 4941
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4942 4942
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4956,35 +4956,35 @@  discard block
 block discarded – undo
4956 4956
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4957 4957
 	{
4958 4958
 		global $globalDBdriver;
4959
-		$filter_query = $this->getFilter($filters,true,true);
4960
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4959
+		$filter_query = $this->getFilter($filters, true, true);
4960
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4961 4961
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'";
4962 4962
 		$query_values = array();
4963 4963
 		if ($year != '') {
4964 4964
 			if ($globalDBdriver == 'mysql') {
4965 4965
 				$query .= " AND YEAR(spotter_output.date) = :year";
4966
-				$query_values = array_merge($query_values,array(':year' => $year));
4966
+				$query_values = array_merge($query_values, array(':year' => $year));
4967 4967
 			} else {
4968 4968
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4969
-				$query_values = array_merge($query_values,array(':year' => $year));
4969
+				$query_values = array_merge($query_values, array(':year' => $year));
4970 4970
 			}
4971 4971
 		}
4972 4972
 		if ($month != '') {
4973 4973
 			if ($globalDBdriver == 'mysql') {
4974 4974
 				$query .= " AND MONTH(spotter_output.date) = :month";
4975
-				$query_values = array_merge($query_values,array(':month' => $month));
4975
+				$query_values = array_merge($query_values, array(':month' => $month));
4976 4976
 			} else {
4977 4977
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4978
-				$query_values = array_merge($query_values,array(':month' => $month));
4978
+				$query_values = array_merge($query_values, array(':month' => $month));
4979 4979
 			}
4980 4980
 		}
4981 4981
 		if ($day != '') {
4982 4982
 			if ($globalDBdriver == 'mysql') {
4983 4983
 				$query .= " AND DAY(spotter_output.date) = :day";
4984
-				$query_values = array_merge($query_values,array(':day' => $day));
4984
+				$query_values = array_merge($query_values, array(':day' => $day));
4985 4985
 			} else {
4986 4986
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4987
-				$query_values = array_merge($query_values,array(':day' => $day));
4987
+				$query_values = array_merge($query_values, array(':day' => $day));
4988 4988
 			}
4989 4989
 		}
4990 4990
 		$query .= " GROUP BY spotter_output.airline_country
@@ -4996,7 +4996,7 @@  discard block
 block discarded – undo
4996 4996
 
4997 4997
 		$airline_array = array();
4998 4998
 		$temp_array = array();
4999
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4999
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5000 5000
 		{
5001 5001
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
5002 5002
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -5012,11 +5012,11 @@  discard block
 block discarded – undo
5012 5012
 	* @return Array the airline country list
5013 5013
 	*
5014 5014
 	*/
5015
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5015
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5016 5016
 	{
5017 5017
 		global $globalDBdriver;
5018 5018
 		//$filter_query = $this->getFilter($filters,true,true);
5019
-		$Connection= new Connection($this->db);
5019
+		$Connection = new Connection($this->db);
5020 5020
 		if (!$Connection->tableExists('countries')) return array();
5021 5021
 		/*
5022 5022
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -5031,7 +5031,7 @@  discard block
 block discarded – undo
5031 5031
 */
5032 5032
 		require_once('class.SpotterLive.php');
5033 5033
 		$SpotterLive = new SpotterLive();
5034
-		$filter_query = $SpotterLive->getFilter($filters,true,true);
5034
+		$filter_query = $SpotterLive->getFilter($filters, true, true);
5035 5035
 		$filter_query .= ' over_country IS NOT NULL';
5036 5036
                 if ($olderthanmonths > 0) {
5037 5037
 			if ($globalDBdriver == 'mysql') {
@@ -5058,7 +5058,7 @@  discard block
 block discarded – undo
5058 5058
 		$flight_array = array();
5059 5059
 		$temp_array = array();
5060 5060
         
5061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5062 5062
 		{
5063 5063
 			$temp_array['flight_count'] = $row['nb'];
5064 5064
 			$temp_array['flight_country'] = $row['name'];
@@ -5076,11 +5076,11 @@  discard block
 block discarded – undo
5076 5076
 	* @return Array the aircraft list
5077 5077
 	*
5078 5078
 	*/
5079
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5079
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5080 5080
 	{
5081 5081
 		global $globalDBdriver;
5082
-		$filter_query = $this->getFilter($filters,true,true);
5083
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5082
+		$filter_query = $this->getFilter($filters, true, true);
5083
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5084 5084
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
5085 5085
 		if ($olderthanmonths > 0) {
5086 5086
 			if ($globalDBdriver == 'mysql') {
@@ -5100,28 +5100,28 @@  discard block
 block discarded – undo
5100 5100
 		if ($year != '') {
5101 5101
 			if ($globalDBdriver == 'mysql') {
5102 5102
 				$query .= " AND YEAR(spotter_output.date) = :year";
5103
-				$query_values = array_merge($query_values,array(':year' => $year));
5103
+				$query_values = array_merge($query_values, array(':year' => $year));
5104 5104
 			} else {
5105 5105
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5106
-				$query_values = array_merge($query_values,array(':year' => $year));
5106
+				$query_values = array_merge($query_values, array(':year' => $year));
5107 5107
 			}
5108 5108
 		}
5109 5109
 		if ($month != '') {
5110 5110
 			if ($globalDBdriver == 'mysql') {
5111 5111
 				$query .= " AND MONTH(spotter_output.date) = :month";
5112
-				$query_values = array_merge($query_values,array(':month' => $month));
5112
+				$query_values = array_merge($query_values, array(':month' => $month));
5113 5113
 			} else {
5114 5114
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5115
-				$query_values = array_merge($query_values,array(':month' => $month));
5115
+				$query_values = array_merge($query_values, array(':month' => $month));
5116 5116
 			}
5117 5117
 		}
5118 5118
 		if ($day != '') {
5119 5119
 			if ($globalDBdriver == 'mysql') {
5120 5120
 				$query .= " AND DAY(spotter_output.date) = :day";
5121
-				$query_values = array_merge($query_values,array(':day' => $day));
5121
+				$query_values = array_merge($query_values, array(':day' => $day));
5122 5122
 			} else {
5123 5123
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5124
-				$query_values = array_merge($query_values,array(':day' => $day));
5124
+				$query_values = array_merge($query_values, array(':day' => $day));
5125 5125
 			}
5126 5126
 		}
5127 5127
 
@@ -5133,7 +5133,7 @@  discard block
 block discarded – undo
5133 5133
 
5134 5134
 		$aircraft_array = array();
5135 5135
 		$temp_array = array();
5136
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5136
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5137 5137
 		{
5138 5138
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5139 5139
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5150,11 +5150,11 @@  discard block
 block discarded – undo
5150 5150
 	* @return Array the aircraft list
5151 5151
 	*
5152 5152
 	*/
5153
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5153
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5154 5154
 	{
5155 5155
 		global $globalDBdriver;
5156
-		$filter_query = $this->getFilter($filters,true,true);
5157
-		$query  = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5156
+		$filter_query = $this->getFilter($filters, true, true);
5157
+		$query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5158 5158
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA'";
5159 5159
 		if ($olderthanmonths > 0) {
5160 5160
 			if ($globalDBdriver == 'mysql') {
@@ -5174,28 +5174,28 @@  discard block
 block discarded – undo
5174 5174
 		if ($year != '') {
5175 5175
 			if ($globalDBdriver == 'mysql') {
5176 5176
 				$query .= " AND YEAR(spotter_output.date) = :year";
5177
-				$query_values = array_merge($query_values,array(':year' => $year));
5177
+				$query_values = array_merge($query_values, array(':year' => $year));
5178 5178
 			} else {
5179 5179
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5180
-				$query_values = array_merge($query_values,array(':year' => $year));
5180
+				$query_values = array_merge($query_values, array(':year' => $year));
5181 5181
 			}
5182 5182
 		}
5183 5183
 		if ($month != '') {
5184 5184
 			if ($globalDBdriver == 'mysql') {
5185 5185
 				$query .= " AND MONTH(spotter_output.date) = :month";
5186
-				$query_values = array_merge($query_values,array(':month' => $month));
5186
+				$query_values = array_merge($query_values, array(':month' => $month));
5187 5187
 			} else {
5188 5188
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5189
-				$query_values = array_merge($query_values,array(':month' => $month));
5189
+				$query_values = array_merge($query_values, array(':month' => $month));
5190 5190
 			}
5191 5191
 		}
5192 5192
 		if ($day != '') {
5193 5193
 			if ($globalDBdriver == 'mysql') {
5194 5194
 				$query .= " AND DAY(spotter_output.date) = :day";
5195
-				$query_values = array_merge($query_values,array(':day' => $day));
5195
+				$query_values = array_merge($query_values, array(':day' => $day));
5196 5196
 			} else {
5197 5197
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5198
-				$query_values = array_merge($query_values,array(':day' => $day));
5198
+				$query_values = array_merge($query_values, array(':day' => $day));
5199 5199
 			}
5200 5200
 		}
5201 5201
 
@@ -5207,7 +5207,7 @@  discard block
 block discarded – undo
5207 5207
 
5208 5208
 		$aircraft_array = array();
5209 5209
 		$temp_array = array();
5210
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5210
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5211 5211
 		{
5212 5212
 			$temp_array['airline_icao'] = $row['airline_icao'];
5213 5213
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5225,11 +5225,11 @@  discard block
 block discarded – undo
5225 5225
 	* @return Array the aircraft list
5226 5226
 	*
5227 5227
 	*/
5228
-	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5228
+	public function countAllAircraftTypesByMonths($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5229 5229
 	{
5230 5230
 		global $globalDBdriver;
5231
-		$filter_query = $this->getFilter($filters,true,true);
5232
-		$query  = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5231
+		$filter_query = $this->getFilter($filters, true, true);
5232
+		$query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5233 5233
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' ";
5234 5234
 		if ($olderthanmonths > 0) {
5235 5235
 			if ($globalDBdriver == 'mysql') {
@@ -5254,7 +5254,7 @@  discard block
 block discarded – undo
5254 5254
 
5255 5255
 		$aircraft_array = array();
5256 5256
 		$temp_array = array();
5257
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5257
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5258 5258
 		{
5259 5259
 			//$temp_array['airline_icao'] = $row['airline_icao'];
5260 5260
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5273,13 +5273,13 @@  discard block
 block discarded – undo
5273 5273
 	* @return Array the aircraft list
5274 5274
 	*
5275 5275
 	*/
5276
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5276
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
5277 5277
 	{
5278 5278
 		$Image = new Image($this->db);
5279
-		$filter_query = $this->getFilter($filters,true,true);
5280
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5279
+		$filter_query = $this->getFilter($filters, true, true);
5280
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5281 5281
 
5282
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5282
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5283 5283
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
5284 5284
 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5285 5285
 				ORDER BY registration_count DESC";
@@ -5290,14 +5290,14 @@  discard block
 block discarded – undo
5290 5290
 		$aircraft_array = array();
5291 5291
 		$temp_array = array();
5292 5292
         
5293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5294 5294
 		{
5295 5295
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5296 5296
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5297 5297
 			$temp_array['registration'] = $row['registration'];
5298 5298
 			$temp_array['airline_name'] = $row['airline_name'];
5299 5299
 			$temp_array['image_thumbnail'] = "";
5300
-			if($row['registration'] != "")
5300
+			if ($row['registration'] != "")
5301 5301
 			{
5302 5302
 				$image_array = $Image->getSpotterImage($row['registration']);
5303 5303
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5316,11 +5316,11 @@  discard block
 block discarded – undo
5316 5316
 	* @return Array the aircraft list
5317 5317
 	*
5318 5318
 	*/
5319
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5319
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
5320 5320
 	{
5321
-		$filter_query = $this->getFilter($filters,true,true);
5322
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5323
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5321
+		$filter_query = $this->getFilter($filters, true, true);
5322
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5323
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5324 5324
 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
5325 5325
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5326 5326
 			    ORDER BY aircraft_icao_count DESC";
@@ -5331,7 +5331,7 @@  discard block
 block discarded – undo
5331 5331
 		$aircraft_array = array();
5332 5332
 		$temp_array = array();
5333 5333
 
5334
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5334
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5335 5335
 		{
5336 5336
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5337 5337
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5349,13 +5349,13 @@  discard block
 block discarded – undo
5349 5349
 	* @return Array the aircraft list
5350 5350
 	*
5351 5351
 	*/
5352
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5352
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
5353 5353
 	{
5354
-		$filter_query = $this->getFilter($filters,true,true);
5354
+		$filter_query = $this->getFilter($filters, true, true);
5355 5355
 		$Image = new Image($this->db);
5356
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5356
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5357 5357
 
5358
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5358
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5359 5359
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
5360 5360
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5361 5361
 			    ORDER BY registration_count DESC";
@@ -5365,14 +5365,14 @@  discard block
 block discarded – undo
5365 5365
 
5366 5366
 		$aircraft_array = array();
5367 5367
 		$temp_array = array();
5368
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5368
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5369 5369
 		{
5370 5370
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5371 5371
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5372 5372
 			$temp_array['registration'] = $row['registration'];
5373 5373
 			$temp_array['airline_name'] = $row['airline_name'];
5374 5374
 			$temp_array['image_thumbnail'] = "";
5375
-			if($row['registration'] != "")
5375
+			if ($row['registration'] != "")
5376 5376
 			{
5377 5377
 				$image_array = $Image->getSpotterImage($row['registration']);
5378 5378
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5391,11 +5391,11 @@  discard block
 block discarded – undo
5391 5391
 	* @return Array the aircraft list
5392 5392
 	*
5393 5393
 	*/
5394
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5394
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
5395 5395
 	{
5396
-		$filter_query = $this->getFilter($filters,true,true);
5397
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5398
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5396
+		$filter_query = $this->getFilter($filters, true, true);
5397
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5398
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5399 5399
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
5400 5400
 				GROUP BY spotter_output.aircraft_manufacturer 
5401 5401
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5406,7 +5406,7 @@  discard block
 block discarded – undo
5406 5406
 		$aircraft_array = array();
5407 5407
 		$temp_array = array();
5408 5408
 
5409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5410 5410
 		{
5411 5411
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5412 5412
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5423,12 +5423,12 @@  discard block
 block discarded – undo
5423 5423
 	* @return Array the aircraft list
5424 5424
 	*
5425 5425
 	*/
5426
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5426
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
5427 5427
 	{
5428
-		$filter_query = $this->getFilter($filters,true,true);
5429
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5428
+		$filter_query = $this->getFilter($filters, true, true);
5429
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5430 5430
 
5431
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5431
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5432 5432
 				FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
5433 5433
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5434 5434
 				ORDER BY aircraft_icao_count DESC";
@@ -5438,7 +5438,7 @@  discard block
 block discarded – undo
5438 5438
 
5439 5439
 		$aircraft_array = array();
5440 5440
 		$temp_array = array();
5441
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5441
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5442 5442
 		{
5443 5443
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5444 5444
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5456,13 +5456,13 @@  discard block
 block discarded – undo
5456 5456
 	* @return Array the aircraft list
5457 5457
 	*
5458 5458
 	*/
5459
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5459
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
5460 5460
 	{
5461
-		$filter_query = $this->getFilter($filters,true,true);
5461
+		$filter_query = $this->getFilter($filters, true, true);
5462 5462
 		$Image = new Image($this->db);
5463
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5463
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5464 5464
 
5465
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5465
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5466 5466
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
5467 5467
                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5468 5468
 		    ORDER BY registration_count DESC";
@@ -5472,14 +5472,14 @@  discard block
 block discarded – undo
5472 5472
 
5473 5473
 		$aircraft_array = array();
5474 5474
 		$temp_array = array();
5475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5476 5476
 		{
5477 5477
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5478 5478
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5479 5479
 			$temp_array['registration'] = $row['registration'];
5480 5480
 			$temp_array['airline_name'] = $row['airline_name'];
5481 5481
 			$temp_array['image_thumbnail'] = "";
5482
-			if($row['registration'] != "")
5482
+			if ($row['registration'] != "")
5483 5483
 			{
5484 5484
 				$image_array = $Image->getSpotterImage($row['registration']);
5485 5485
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5497,11 +5497,11 @@  discard block
 block discarded – undo
5497 5497
 	* @return Array the aircraft list
5498 5498
 	*
5499 5499
 	*/
5500
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5500
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
5501 5501
 	{
5502
-		$filter_query = $this->getFilter($filters,true,true);
5503
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5504
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5502
+		$filter_query = $this->getFilter($filters, true, true);
5503
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5504
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5505 5505
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  
5506 5506
                     GROUP BY spotter_output.aircraft_manufacturer 
5507 5507
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5512,7 +5512,7 @@  discard block
 block discarded – undo
5512 5512
 
5513 5513
 		$aircraft_array = array();
5514 5514
 		$temp_array = array();
5515
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5515
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5516 5516
 		{
5517 5517
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5518 5518
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5527,12 +5527,12 @@  discard block
 block discarded – undo
5527 5527
 	* @return Array the aircraft list
5528 5528
 	*
5529 5529
 	*/
5530
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5530
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
5531 5531
 	{
5532
-		$filter_query = $this->getFilter($filters,true,true);
5533
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5532
+		$filter_query = $this->getFilter($filters, true, true);
5533
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5534 5534
 
5535
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5535
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5536 5536
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
5537 5537
                     GROUP BY spotter_output.aircraft_name 
5538 5538
 					ORDER BY aircraft_icao_count DESC";
@@ -5541,7 +5541,7 @@  discard block
 block discarded – undo
5541 5541
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5542 5542
 		$aircraft_array = array();
5543 5543
 		$temp_array = array();
5544
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5544
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5545 5545
 		{
5546 5546
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5547 5547
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5560,11 +5560,11 @@  discard block
 block discarded – undo
5560 5560
 	*/
5561 5561
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5562 5562
 	{
5563
-		$filter_query = $this->getFilter($filters,true,true);
5563
+		$filter_query = $this->getFilter($filters, true, true);
5564 5564
 		$Image = new Image($this->db);
5565
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5565
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5566 5566
 
5567
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5567
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5568 5568
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
5569 5569
                     GROUP BY spotter_output.registration 
5570 5570
 					ORDER BY registration_count DESC";
@@ -5574,14 +5574,14 @@  discard block
 block discarded – undo
5574 5574
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5575 5575
 		$aircraft_array = array();
5576 5576
 		$temp_array = array();
5577
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5577
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5578 5578
 		{
5579 5579
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5580 5580
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5581 5581
 			$temp_array['registration'] = $row['registration'];
5582 5582
 			$temp_array['airline_name'] = $row['airline_name'];
5583 5583
 			$temp_array['image_thumbnail'] = "";
5584
-			if($row['registration'] != "")
5584
+			if ($row['registration'] != "")
5585 5585
 			{
5586 5586
 				$image_array = $Image->getSpotterImage($row['registration']);
5587 5587
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5598,11 +5598,11 @@  discard block
 block discarded – undo
5598 5598
 	* @return Array the aircraft list
5599 5599
 	*
5600 5600
 	*/
5601
-	public function countAllAircraftTypesByDate($date,$filters = array())
5601
+	public function countAllAircraftTypesByDate($date, $filters = array())
5602 5602
 	{
5603 5603
 		global $globalTimezone, $globalDBdriver;
5604
-		$filter_query = $this->getFilter($filters,true,true);
5605
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5604
+		$filter_query = $this->getFilter($filters, true, true);
5605
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5606 5606
 		if ($globalTimezone != '') {
5607 5607
 			date_default_timezone_set($globalTimezone);
5608 5608
 			$datetime = new DateTime($date);
@@ -5610,12 +5610,12 @@  discard block
 block discarded – undo
5610 5610
 		} else $offset = '+00:00';
5611 5611
 
5612 5612
 		if ($globalDBdriver == 'mysql') {
5613
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5613
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5614 5614
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
5615 5615
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5616 5616
 					ORDER BY aircraft_icao_count DESC";
5617 5617
 		} else {
5618
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5618
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5619 5619
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
5620 5620
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5621 5621
 					ORDER BY aircraft_icao_count DESC";
@@ -5626,7 +5626,7 @@  discard block
 block discarded – undo
5626 5626
 
5627 5627
 		$aircraft_array = array();
5628 5628
 		$temp_array = array();
5629
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5629
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5630 5630
 		{
5631 5631
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5632 5632
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5644,12 +5644,12 @@  discard block
 block discarded – undo
5644 5644
 	* @return Array the aircraft list
5645 5645
 	*
5646 5646
 	*/
5647
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
5647
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
5648 5648
 	{
5649 5649
 		global $globalTimezone, $globalDBdriver;
5650
-		$filter_query = $this->getFilter($filters,true,true);
5650
+		$filter_query = $this->getFilter($filters, true, true);
5651 5651
 		$Image = new Image($this->db);
5652
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5652
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5653 5653
 		if ($globalTimezone != '') {
5654 5654
 			date_default_timezone_set($globalTimezone);
5655 5655
 			$datetime = new DateTime($date);
@@ -5657,12 +5657,12 @@  discard block
 block discarded – undo
5657 5657
 		} else $offset = '+00:00';
5658 5658
 
5659 5659
 		if ($globalDBdriver == 'mysql') {
5660
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5660
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5661 5661
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5662 5662
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5663 5663
 					ORDER BY registration_count DESC";
5664 5664
 		} else {
5665
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
5665
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
5666 5666
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5667 5667
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5668 5668
 					ORDER BY registration_count DESC";
@@ -5673,14 +5673,14 @@  discard block
 block discarded – undo
5673 5673
 
5674 5674
 		$aircraft_array = array();
5675 5675
 		$temp_array = array();
5676
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5676
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5677 5677
 		{
5678 5678
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5679 5679
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5680 5680
 			$temp_array['registration'] = $row['registration'];
5681 5681
 			$temp_array['airline_name'] = $row['airline_name'];
5682 5682
 			$temp_array['image_thumbnail'] = "";
5683
-			if($row['registration'] != "")
5683
+			if ($row['registration'] != "")
5684 5684
 			{
5685 5685
 				$image_array = $Image->getSpotterImage($row['registration']);
5686 5686
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5699,11 +5699,11 @@  discard block
 block discarded – undo
5699 5699
 	* @return Array the aircraft manufacturer list
5700 5700
 	*
5701 5701
 	*/
5702
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
5702
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
5703 5703
 	{
5704 5704
 		global $globalTimezone, $globalDBdriver;
5705
-		$filter_query = $this->getFilter($filters,true,true);
5706
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5705
+		$filter_query = $this->getFilter($filters, true, true);
5706
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5707 5707
 		if ($globalTimezone != '') {
5708 5708
 			date_default_timezone_set($globalTimezone);
5709 5709
 			$datetime = new DateTime($date);
@@ -5711,12 +5711,12 @@  discard block
 block discarded – undo
5711 5711
 		} else $offset = '+00:00';
5712 5712
 
5713 5713
 		if ($globalDBdriver == 'mysql') {
5714
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5714
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5715 5715
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5716 5716
 				GROUP BY spotter_output.aircraft_manufacturer 
5717 5717
 				ORDER BY aircraft_manufacturer_count DESC";
5718 5718
 		} else {
5719
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5719
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5720 5720
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5721 5721
 				GROUP BY spotter_output.aircraft_manufacturer 
5722 5722
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5728,7 +5728,7 @@  discard block
 block discarded – undo
5728 5728
 		$aircraft_array = array();
5729 5729
 		$temp_array = array();
5730 5730
 
5731
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5731
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5732 5732
 		{
5733 5733
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5734 5734
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5745,11 +5745,11 @@  discard block
 block discarded – undo
5745 5745
 	* @return Array the aircraft list
5746 5746
 	*
5747 5747
 	*/
5748
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
5748
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
5749 5749
 	{
5750
-		$filter_query = $this->getFilter($filters,true,true);
5751
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5752
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5750
+		$filter_query = $this->getFilter($filters, true, true);
5751
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5752
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5753 5753
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
5754 5754
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5755 5755
 				ORDER BY aircraft_icao_count DESC";
@@ -5760,7 +5760,7 @@  discard block
 block discarded – undo
5760 5760
 		$aircraft_array = array();
5761 5761
 		$temp_array = array();
5762 5762
 
5763
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5763
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5764 5764
 		{
5765 5765
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5766 5766
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5777,45 +5777,45 @@  discard block
 block discarded – undo
5777 5777
 	* @return Array the aircraft list
5778 5778
 	*
5779 5779
 	*/
5780
-	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5780
+	public function countAllAircraftTypesByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5781 5781
 	{
5782 5782
 		global $globalDBdriver;
5783
-		$filter_query = $this->getFilter($filters,true,true);
5784
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
5785
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5783
+		$filter_query = $this->getFilter($filters, true, true);
5784
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
5785
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5786 5786
 				FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)";
5787 5787
 		$query_values = array();
5788 5788
 		if ($year != '') {
5789 5789
 			if ($globalDBdriver == 'mysql') {
5790 5790
 				$query .= " AND YEAR(spotter_output.date) = :year";
5791
-				$query_values = array_merge($query_values,array(':year' => $year));
5791
+				$query_values = array_merge($query_values, array(':year' => $year));
5792 5792
 			} else {
5793 5793
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5794
-				$query_values = array_merge($query_values,array(':year' => $year));
5794
+				$query_values = array_merge($query_values, array(':year' => $year));
5795 5795
 			}
5796 5796
 		}
5797 5797
 		if ($month != '') {
5798 5798
 			if ($globalDBdriver == 'mysql') {
5799 5799
 				$query .= " AND MONTH(spotter_output.date) = :month";
5800
-				$query_values = array_merge($query_values,array(':month' => $month));
5800
+				$query_values = array_merge($query_values, array(':month' => $month));
5801 5801
 			} else {
5802 5802
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5803
-				$query_values = array_merge($query_values,array(':month' => $month));
5803
+				$query_values = array_merge($query_values, array(':month' => $month));
5804 5804
 			}
5805 5805
 		}
5806 5806
 		if ($day != '') {
5807 5807
 			if ($globalDBdriver == 'mysql') {
5808 5808
 				$query .= " AND DAY(spotter_output.date) = :day";
5809
-				$query_values = array_merge($query_values,array(':day' => $day));
5809
+				$query_values = array_merge($query_values, array(':day' => $day));
5810 5810
 			} else {
5811 5811
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5812
-				$query_values = array_merge($query_values,array(':day' => $day));
5812
+				$query_values = array_merge($query_values, array(':day' => $day));
5813 5813
 			}
5814 5814
 		}
5815 5815
 
5816 5816
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5817 5817
 				ORDER BY aircraft_icao_count DESC";
5818
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
5818
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
5819 5819
 		$sth = $this->db->prepare($query);
5820 5820
 		$sth->execute($query_values);
5821 5821
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5827,44 +5827,44 @@  discard block
 block discarded – undo
5827 5827
 	* @return Array the aircraft list
5828 5828
 	*
5829 5829
 	*/
5830
-	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5830
+	public function countAllAircraftTypesByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5831 5831
 	{
5832 5832
 		global $globalDBdriver;
5833
-		$filter_query = $this->getFilter($filters,true,true);
5834
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5835
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5833
+		$filter_query = $this->getFilter($filters, true, true);
5834
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5835
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5836 5836
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
5837 5837
 		$query_values = array();
5838 5838
 		if ($year != '') {
5839 5839
 			if ($globalDBdriver == 'mysql') {
5840 5840
 				$query .= " AND YEAR(spotter_output.date) = :year";
5841
-				$query_values = array_merge($query_values,array(':year' => $year));
5841
+				$query_values = array_merge($query_values, array(':year' => $year));
5842 5842
 			} else {
5843 5843
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5844
-				$query_values = array_merge($query_values,array(':year' => $year));
5844
+				$query_values = array_merge($query_values, array(':year' => $year));
5845 5845
 			}
5846 5846
 		}
5847 5847
 		if ($month != '') {
5848 5848
 			if ($globalDBdriver == 'mysql') {
5849 5849
 				$query .= " AND MONTH(spotter_output.date) = :month";
5850
-				$query_values = array_merge($query_values,array(':month' => $month));
5850
+				$query_values = array_merge($query_values, array(':month' => $month));
5851 5851
 			} else {
5852 5852
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5853
-				$query_values = array_merge($query_values,array(':month' => $month));
5853
+				$query_values = array_merge($query_values, array(':month' => $month));
5854 5854
 			}
5855 5855
 		}
5856 5856
 		if ($day != '') {
5857 5857
 			if ($globalDBdriver == 'mysql') {
5858 5858
 				$query .= " AND DAY(spotter_output.date) = :day";
5859
-				$query_values = array_merge($query_values,array(':day' => $day));
5859
+				$query_values = array_merge($query_values, array(':day' => $day));
5860 5860
 			} else {
5861 5861
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5862
-				$query_values = array_merge($query_values,array(':day' => $day));
5862
+				$query_values = array_merge($query_values, array(':day' => $day));
5863 5863
 			}
5864 5864
 		}
5865 5865
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao
5866 5866
 				ORDER BY aircraft_icao_count DESC";
5867
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5867
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5868 5868
 		$sth = $this->db->prepare($query);
5869 5869
 		$sth->execute($query_values);
5870 5870
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5876,13 +5876,13 @@  discard block
 block discarded – undo
5876 5876
 	* @return Array the aircraft list
5877 5877
 	*
5878 5878
 	*/
5879
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5879
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5880 5880
 	{
5881
-		$filter_query = $this->getFilter($filters,true,true);
5881
+		$filter_query = $this->getFilter($filters, true, true);
5882 5882
 		$Image = new Image($this->db);
5883
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5883
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5884 5884
 
5885
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5885
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5886 5886
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5887 5887
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5888 5888
 		    ORDER BY registration_count DESC";
@@ -5894,14 +5894,14 @@  discard block
 block discarded – undo
5894 5894
 		$aircraft_array = array();
5895 5895
 		$temp_array = array();
5896 5896
         
5897
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5897
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5898 5898
 		{
5899 5899
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5900 5900
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5901 5901
 			$temp_array['registration'] = $row['registration'];
5902 5902
 			$temp_array['airline_name'] = $row['airline_name'];
5903 5903
 			$temp_array['image_thumbnail'] = "";
5904
-			if($row['registration'] != "")
5904
+			if ($row['registration'] != "")
5905 5905
 			{
5906 5906
 				$image_array = $Image->getSpotterImage($row['registration']);
5907 5907
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5919,44 +5919,44 @@  discard block
 block discarded – undo
5919 5919
 	* @return Array the aircraft list
5920 5920
 	*
5921 5921
 	*/
5922
-	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5922
+	public function countAllAircraftRegistrationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5923 5923
 	{
5924 5924
 		global $globalDBdriver;
5925
-		$filter_query = $this->getFilter($filters,true,true);
5925
+		$filter_query = $this->getFilter($filters, true, true);
5926 5926
 		$Image = new Image($this->db);
5927
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5927
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5928 5928
 
5929
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5929
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5930 5930
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner";
5931 5931
 		$query_values = array();
5932 5932
 		if ($year != '') {
5933 5933
 			if ($globalDBdriver == 'mysql') {
5934 5934
 				$query .= " AND YEAR(spotter_output.date) = :year";
5935
-				$query_values = array_merge($query_values,array(':year' => $year));
5935
+				$query_values = array_merge($query_values, array(':year' => $year));
5936 5936
 			} else {
5937 5937
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5938
-				$query_values = array_merge($query_values,array(':year' => $year));
5938
+				$query_values = array_merge($query_values, array(':year' => $year));
5939 5939
 			}
5940 5940
 		}
5941 5941
 		if ($month != '') {
5942 5942
 			if ($globalDBdriver == 'mysql') {
5943 5943
 				$query .= " AND MONTH(spotter_output.date) = :month";
5944
-				$query_values = array_merge($query_values,array(':month' => $month));
5944
+				$query_values = array_merge($query_values, array(':month' => $month));
5945 5945
 			} else {
5946 5946
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5947
-				$query_values = array_merge($query_values,array(':month' => $month));
5947
+				$query_values = array_merge($query_values, array(':month' => $month));
5948 5948
 			}
5949 5949
 		}
5950 5950
 		if ($day != '') {
5951 5951
 			if ($globalDBdriver == 'mysql') {
5952 5952
 				$query .= " AND DAY(spotter_output.date) = :day";
5953
-				$query_values = array_merge($query_values,array(':day' => $day));
5953
+				$query_values = array_merge($query_values, array(':day' => $day));
5954 5954
 			} else {
5955 5955
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5956
-				$query_values = array_merge($query_values,array(':day' => $day));
5956
+				$query_values = array_merge($query_values, array(':day' => $day));
5957 5957
 			}
5958 5958
 		}
5959
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5959
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5960 5960
 
5961 5961
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
5962 5962
 		    ORDER BY registration_count DESC";
@@ -5968,7 +5968,7 @@  discard block
 block discarded – undo
5968 5968
 		$aircraft_array = array();
5969 5969
 		$temp_array = array();
5970 5970
         
5971
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5971
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5972 5972
 		{
5973 5973
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5974 5974
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5976,7 +5976,7 @@  discard block
 block discarded – undo
5976 5976
 			$temp_array['registration'] = $row['registration'];
5977 5977
 			$temp_array['airline_name'] = $row['airline_name'];
5978 5978
 			$temp_array['image_thumbnail'] = "";
5979
-			if($row['registration'] != "")
5979
+			if ($row['registration'] != "")
5980 5980
 			{
5981 5981
 				$image_array = $Image->getSpotterImage($row['registration']);
5982 5982
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5994,44 +5994,44 @@  discard block
 block discarded – undo
5994 5994
 	* @return Array the aircraft list
5995 5995
 	*
5996 5996
 	*/
5997
-	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5997
+	public function countAllAircraftRegistrationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5998 5998
 	{
5999 5999
 		global $globalDBdriver;
6000
-		$filter_query = $this->getFilter($filters,true,true);
6000
+		$filter_query = $this->getFilter($filters, true, true);
6001 6001
 		$Image = new Image($this->db);
6002
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6002
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6003 6003
 
6004
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6004
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6005 6005
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6006 6006
 		$query_values = array();
6007 6007
 		if ($year != '') {
6008 6008
 			if ($globalDBdriver == 'mysql') {
6009 6009
 				$query .= " AND YEAR(spotter_output.date) = :year";
6010
-				$query_values = array_merge($query_values,array(':year' => $year));
6010
+				$query_values = array_merge($query_values, array(':year' => $year));
6011 6011
 			} else {
6012 6012
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6013
-				$query_values = array_merge($query_values,array(':year' => $year));
6013
+				$query_values = array_merge($query_values, array(':year' => $year));
6014 6014
 			}
6015 6015
 		}
6016 6016
 		if ($month != '') {
6017 6017
 			if ($globalDBdriver == 'mysql') {
6018 6018
 				$query .= " AND MONTH(spotter_output.date) = :month";
6019
-				$query_values = array_merge($query_values,array(':month' => $month));
6019
+				$query_values = array_merge($query_values, array(':month' => $month));
6020 6020
 			} else {
6021 6021
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6022
-				$query_values = array_merge($query_values,array(':month' => $month));
6022
+				$query_values = array_merge($query_values, array(':month' => $month));
6023 6023
 			}
6024 6024
 		}
6025 6025
 		if ($day != '') {
6026 6026
 			if ($globalDBdriver == 'mysql') {
6027 6027
 				$query .= " AND DAY(spotter_output.date) = :day";
6028
-				$query_values = array_merge($query_values,array(':day' => $day));
6028
+				$query_values = array_merge($query_values, array(':day' => $day));
6029 6029
 			} else {
6030 6030
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6031
-				$query_values = array_merge($query_values,array(':day' => $day));
6031
+				$query_values = array_merge($query_values, array(':day' => $day));
6032 6032
 			}
6033 6033
 		}
6034
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6034
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6035 6035
 
6036 6036
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
6037 6037
 		    ORDER BY registration_count DESC";
@@ -6043,7 +6043,7 @@  discard block
 block discarded – undo
6043 6043
 		$aircraft_array = array();
6044 6044
 		$temp_array = array();
6045 6045
         
6046
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6046
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6047 6047
 		{
6048 6048
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6049 6049
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6051,7 +6051,7 @@  discard block
 block discarded – undo
6051 6051
 			$temp_array['registration'] = $row['registration'];
6052 6052
 			$temp_array['airline_name'] = $row['airline_name'];
6053 6053
 			$temp_array['image_thumbnail'] = "";
6054
-			if($row['registration'] != "")
6054
+			if ($row['registration'] != "")
6055 6055
 			{
6056 6056
 				$image_array = $Image->getSpotterImage($row['registration']);
6057 6057
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6070,11 +6070,11 @@  discard block
 block discarded – undo
6070 6070
 	* @return Array the aircraft manufacturer list
6071 6071
 	*
6072 6072
 	*/
6073
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6073
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
6074 6074
 	{
6075
-		$filter_query = $this->getFilter($filters,true,true);
6076
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6077
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6075
+		$filter_query = $this->getFilter($filters, true, true);
6076
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6077
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6078 6078
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
6079 6079
                     GROUP BY spotter_output.aircraft_manufacturer 
6080 6080
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6084,7 +6084,7 @@  discard block
 block discarded – undo
6084 6084
 		$sth->execute(array(':ident' => $ident));
6085 6085
 		$aircraft_array = array();
6086 6086
 		$temp_array = array();
6087
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6087
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6088 6088
 		{
6089 6089
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6090 6090
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6099,42 +6099,42 @@  discard block
 block discarded – undo
6099 6099
 	* @return Array the aircraft manufacturer list
6100 6100
 	*
6101 6101
 	*/
6102
-	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6102
+	public function countAllAircraftManufacturerByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
6103 6103
 	{
6104 6104
 		global $globalDBdriver;
6105
-		$filter_query = $this->getFilter($filters,true,true);
6106
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
6107
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6105
+		$filter_query = $this->getFilter($filters, true, true);
6106
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
6107
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6108 6108
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner";
6109 6109
 		$query_values = array();
6110 6110
 		if ($year != '') {
6111 6111
 			if ($globalDBdriver == 'mysql') {
6112 6112
 				$query .= " AND YEAR(spotter_output.date) = :year";
6113
-				$query_values = array_merge($query_values,array(':year' => $year));
6113
+				$query_values = array_merge($query_values, array(':year' => $year));
6114 6114
 			} else {
6115 6115
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6116
-				$query_values = array_merge($query_values,array(':year' => $year));
6116
+				$query_values = array_merge($query_values, array(':year' => $year));
6117 6117
 			}
6118 6118
 		}
6119 6119
 		if ($month != '') {
6120 6120
 			if ($globalDBdriver == 'mysql') {
6121 6121
 				$query .= " AND MONTH(spotter_output.date) = :month";
6122
-				$query_values = array_merge($query_values,array(':month' => $month));
6122
+				$query_values = array_merge($query_values, array(':month' => $month));
6123 6123
 			} else {
6124 6124
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6125
-				$query_values = array_merge($query_values,array(':month' => $month));
6125
+				$query_values = array_merge($query_values, array(':month' => $month));
6126 6126
 			}
6127 6127
 		}
6128 6128
 		if ($day != '') {
6129 6129
 			if ($globalDBdriver == 'mysql') {
6130 6130
 				$query .= " AND DAY(spotter_output.date) = :day";
6131
-				$query_values = array_merge($query_values,array(':day' => $day));
6131
+				$query_values = array_merge($query_values, array(':day' => $day));
6132 6132
 			} else {
6133 6133
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6134
-				$query_values = array_merge($query_values,array(':day' => $day));
6134
+				$query_values = array_merge($query_values, array(':day' => $day));
6135 6135
 			}
6136 6136
 		}
6137
-		$query_values = array_merge($query_values,array(':owner' => $owner));
6137
+		$query_values = array_merge($query_values, array(':owner' => $owner));
6138 6138
 
6139 6139
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6140 6140
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6151,42 +6151,42 @@  discard block
 block discarded – undo
6151 6151
 	* @return Array the aircraft manufacturer list
6152 6152
 	*
6153 6153
 	*/
6154
-	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6154
+	public function countAllAircraftManufacturerByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
6155 6155
 	{
6156 6156
 		global $globalDBdriver;
6157
-		$filter_query = $this->getFilter($filters,true,true);
6158
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6159
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6157
+		$filter_query = $this->getFilter($filters, true, true);
6158
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6159
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6160 6160
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6161 6161
 		$query_values = array();
6162 6162
 		if ($year != '') {
6163 6163
 			if ($globalDBdriver == 'mysql') {
6164 6164
 				$query .= " AND YEAR(spotter_output.date) = :year";
6165
-				$query_values = array_merge($query_values,array(':year' => $year));
6165
+				$query_values = array_merge($query_values, array(':year' => $year));
6166 6166
 			} else {
6167 6167
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6168
-				$query_values = array_merge($query_values,array(':year' => $year));
6168
+				$query_values = array_merge($query_values, array(':year' => $year));
6169 6169
 			}
6170 6170
 		}
6171 6171
 		if ($month != '') {
6172 6172
 			if ($globalDBdriver == 'mysql') {
6173 6173
 				$query .= " AND MONTH(spotter_output.date) = :month";
6174
-				$query_values = array_merge($query_values,array(':month' => $month));
6174
+				$query_values = array_merge($query_values, array(':month' => $month));
6175 6175
 			} else {
6176 6176
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6177
-				$query_values = array_merge($query_values,array(':month' => $month));
6177
+				$query_values = array_merge($query_values, array(':month' => $month));
6178 6178
 			}
6179 6179
 		}
6180 6180
 		if ($day != '') {
6181 6181
 			if ($globalDBdriver == 'mysql') {
6182 6182
 				$query .= " AND DAY(spotter_output.date) = :day";
6183
-				$query_values = array_merge($query_values,array(':day' => $day));
6183
+				$query_values = array_merge($query_values, array(':day' => $day));
6184 6184
 			} else {
6185 6185
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6186
-				$query_values = array_merge($query_values,array(':day' => $day));
6186
+				$query_values = array_merge($query_values, array(':day' => $day));
6187 6187
 			}
6188 6188
 		}
6189
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6189
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6190 6190
 
6191 6191
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6192 6192
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6204,24 +6204,24 @@  discard block
 block discarded – undo
6204 6204
 	* @return Array the aircraft list
6205 6205
 	*
6206 6206
 	*/
6207
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6207
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6208 6208
 	{
6209
-		$filter_query = $this->getFilter($filters,true,true);
6210
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6211
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6209
+		$filter_query = $this->getFilter($filters, true, true);
6210
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6211
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6212 6212
 		
6213 6213
 
6214
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6214
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6215 6215
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
6216 6216
                     GROUP BY spotter_output.aircraft_name 
6217 6217
 					ORDER BY aircraft_icao_count DESC";
6218 6218
  
6219 6219
 		
6220 6220
 		$sth = $this->db->prepare($query);
6221
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6221
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6222 6222
 		$aircraft_array = array();
6223 6223
 		$temp_array = array();
6224
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6224
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6225 6225
 		{
6226 6226
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6227 6227
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6237,33 +6237,33 @@  discard block
 block discarded – undo
6237 6237
 	* @return Array the aircraft list
6238 6238
 	*
6239 6239
 	*/
6240
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6240
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6241 6241
 	{
6242
-		$filter_query = $this->getFilter($filters,true,true);
6242
+		$filter_query = $this->getFilter($filters, true, true);
6243 6243
 		$Image = new Image($this->db);
6244
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6245
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6244
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6245
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6246 6246
 
6247
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
6247
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
6248 6248
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)   
6249 6249
                     GROUP BY spotter_output.registration 
6250 6250
 					ORDER BY registration_count DESC";
6251 6251
 
6252 6252
 		
6253 6253
 		$sth = $this->db->prepare($query);
6254
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6254
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6255 6255
       
6256 6256
 		$aircraft_array = array();
6257 6257
 		$temp_array = array();
6258 6258
         
6259
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6259
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6260 6260
 		{
6261 6261
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6262 6262
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6263 6263
 			$temp_array['registration'] = $row['registration'];
6264 6264
 			$temp_array['airline_name'] = $row['airline_name'];
6265 6265
 			$temp_array['image_thumbnail'] = "";
6266
-			if($row['registration'] != "")
6266
+			if ($row['registration'] != "")
6267 6267
 			{
6268 6268
 				$image_array = $Image->getSpotterImage($row['registration']);
6269 6269
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6283,25 +6283,25 @@  discard block
 block discarded – undo
6283 6283
 	* @return Array the aircraft manufacturer list
6284 6284
 	*
6285 6285
 	*/
6286
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6286
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6287 6287
 	{
6288
-		$filter_query = $this->getFilter($filters,true,true);
6289
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6290
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6288
+		$filter_query = $this->getFilter($filters, true, true);
6289
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6290
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6291 6291
 
6292
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6292
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6293 6293
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
6294 6294
                     GROUP BY spotter_output.aircraft_manufacturer 
6295 6295
 					ORDER BY aircraft_manufacturer_count DESC";
6296 6296
 
6297 6297
 		
6298 6298
 		$sth = $this->db->prepare($query);
6299
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6299
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6300 6300
       
6301 6301
 		$aircraft_array = array();
6302 6302
 		$temp_array = array();
6303 6303
         
6304
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6304
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6305 6305
 		{
6306 6306
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6307 6307
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6321,11 +6321,11 @@  discard block
 block discarded – undo
6321 6321
 	* @return Array the aircraft list
6322 6322
 	*
6323 6323
 	*/
6324
-	public function countAllAircraftTypesByCountry($country,$filters = array())
6324
+	public function countAllAircraftTypesByCountry($country, $filters = array())
6325 6325
 	{
6326
-		$filter_query = $this->getFilter($filters,true,true);
6327
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6328
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6326
+		$filter_query = $this->getFilter($filters, true, true);
6327
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6328
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6329 6329
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6330 6330
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
6331 6331
 			    ORDER BY aircraft_icao_count DESC";
@@ -6337,7 +6337,7 @@  discard block
 block discarded – undo
6337 6337
 		$aircraft_array = array();
6338 6338
 		$temp_array = array();
6339 6339
         
6340
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6340
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6341 6341
 		{
6342 6342
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6343 6343
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6356,12 +6356,12 @@  discard block
 block discarded – undo
6356 6356
 	* @return Array the aircraft list
6357 6357
 	*
6358 6358
 	*/
6359
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6359
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
6360 6360
 	{
6361
-		$filter_query = $this->getFilter($filters,true,true);
6361
+		$filter_query = $this->getFilter($filters, true, true);
6362 6362
 		$Image = new Image($this->db);
6363
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6364
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
6363
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6364
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
6365 6365
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
6366 6366
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
6367 6367
 			    ORDER BY registration_count DESC";
@@ -6373,14 +6373,14 @@  discard block
 block discarded – undo
6373 6373
 		$aircraft_array = array();
6374 6374
 		$temp_array = array();
6375 6375
         
6376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6377 6377
 		{
6378 6378
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6379 6379
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6380 6380
 			$temp_array['registration'] = $row['registration'];
6381 6381
 			$temp_array['airline_name'] = $row['airline_name'];
6382 6382
 			$temp_array['image_thumbnail'] = "";
6383
-			if($row['registration'] != "")
6383
+			if ($row['registration'] != "")
6384 6384
 			{
6385 6385
 				$image_array = $Image->getSpotterImage($row['registration']);
6386 6386
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6400,11 +6400,11 @@  discard block
 block discarded – undo
6400 6400
 	* @return Array the aircraft manufacturer list
6401 6401
 	*
6402 6402
 	*/
6403
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6403
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
6404 6404
 	{
6405
-		$filter_query = $this->getFilter($filters,true,true);
6406
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6407
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6405
+		$filter_query = $this->getFilter($filters, true, true);
6406
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6407
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6408 6408
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) 
6409 6409
                     GROUP BY spotter_output.aircraft_manufacturer 
6410 6410
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6416,7 +6416,7 @@  discard block
 block discarded – undo
6416 6416
 		$aircraft_array = array();
6417 6417
 		$temp_array = array();
6418 6418
         
6419
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6419
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6420 6420
 		{
6421 6421
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6422 6422
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6435,38 +6435,38 @@  discard block
 block discarded – undo
6435 6435
 	* @return Array the aircraft list
6436 6436
 	*
6437 6437
 	*/
6438
-	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6438
+	public function countAllAircraftManufacturers($filters = array(), $year = '', $month = '', $day = '')
6439 6439
 	{
6440 6440
 		global $globalDBdriver;
6441
-		$filter_query = $this->getFilter($filters,true,true);
6442
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6441
+		$filter_query = $this->getFilter($filters, true, true);
6442
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443 6443
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6444 6444
                 $query_values = array();
6445 6445
 		if ($year != '') {
6446 6446
 			if ($globalDBdriver == 'mysql') {
6447 6447
 				$query .= " AND YEAR(spotter_output.date) = :year";
6448
-				$query_values = array_merge($query_values,array(':year' => $year));
6448
+				$query_values = array_merge($query_values, array(':year' => $year));
6449 6449
 			} else {
6450 6450
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6451
-				$query_values = array_merge($query_values,array(':year' => $year));
6451
+				$query_values = array_merge($query_values, array(':year' => $year));
6452 6452
 			}
6453 6453
 		}
6454 6454
 		if ($month != '') {
6455 6455
 			if ($globalDBdriver == 'mysql') {
6456 6456
 				$query .= " AND MONTH(spotter_output.date) = :month";
6457
-				$query_values = array_merge($query_values,array(':month' => $month));
6457
+				$query_values = array_merge($query_values, array(':month' => $month));
6458 6458
 			} else {
6459 6459
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6460
-				$query_values = array_merge($query_values,array(':month' => $month));
6460
+				$query_values = array_merge($query_values, array(':month' => $month));
6461 6461
 			}
6462 6462
 		}
6463 6463
 		if ($day != '') {
6464 6464
 			if ($globalDBdriver == 'mysql') {
6465 6465
 				$query .= " AND DAY(spotter_output.date) = :day";
6466
-				$query_values = array_merge($query_values,array(':day' => $day));
6466
+				$query_values = array_merge($query_values, array(':day' => $day));
6467 6467
 			} else {
6468 6468
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6469
-				$query_values = array_merge($query_values,array(':day' => $day));
6469
+				$query_values = array_merge($query_values, array(':day' => $day));
6470 6470
 			}
6471 6471
 		}
6472 6472
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer
@@ -6480,7 +6480,7 @@  discard block
 block discarded – undo
6480 6480
 		$manufacturer_array = array();
6481 6481
 		$temp_array = array();
6482 6482
         
6483
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6483
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6484 6484
 		{
6485 6485
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6486 6486
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6499,12 +6499,12 @@  discard block
 block discarded – undo
6499 6499
 	* @return Array the aircraft list
6500 6500
 	*
6501 6501
 	*/
6502
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6502
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6503 6503
 	{
6504 6504
 		global $globalDBdriver;
6505 6505
 		$Image = new Image($this->db);
6506
-		$filter_query = $this->getFilter($filters,true,true);
6507
-		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6506
+		$filter_query = $this->getFilter($filters, true, true);
6507
+		$query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6508 6508
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6509 6509
                 if ($olderthanmonths > 0) {
6510 6510
             		if ($globalDBdriver == 'mysql') {
@@ -6524,28 +6524,28 @@  discard block
 block discarded – undo
6524 6524
 		if ($year != '') {
6525 6525
 			if ($globalDBdriver == 'mysql') {
6526 6526
 				$query .= " AND YEAR(spotter_output.date) = :year";
6527
-				$query_values = array_merge($query_values,array(':year' => $year));
6527
+				$query_values = array_merge($query_values, array(':year' => $year));
6528 6528
 			} else {
6529 6529
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6530
-				$query_values = array_merge($query_values,array(':year' => $year));
6530
+				$query_values = array_merge($query_values, array(':year' => $year));
6531 6531
 			}
6532 6532
 		}
6533 6533
 		if ($month != '') {
6534 6534
 			if ($globalDBdriver == 'mysql') {
6535 6535
 				$query .= " AND MONTH(spotter_output.date) = :month";
6536
-				$query_values = array_merge($query_values,array(':month' => $month));
6536
+				$query_values = array_merge($query_values, array(':month' => $month));
6537 6537
 			} else {
6538 6538
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6539
-				$query_values = array_merge($query_values,array(':month' => $month));
6539
+				$query_values = array_merge($query_values, array(':month' => $month));
6540 6540
 			}
6541 6541
 		}
6542 6542
 		if ($day != '') {
6543 6543
 			if ($globalDBdriver == 'mysql') {
6544 6544
 				$query .= " AND DAY(spotter_output.date) = :day";
6545
-				$query_values = array_merge($query_values,array(':day' => $day));
6545
+				$query_values = array_merge($query_values, array(':day' => $day));
6546 6546
 			} else {
6547 6547
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6548
-				$query_values = array_merge($query_values,array(':day' => $day));
6548
+				$query_values = array_merge($query_values, array(':day' => $day));
6549 6549
 			}
6550 6550
 		}
6551 6551
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
@@ -6557,7 +6557,7 @@  discard block
 block discarded – undo
6557 6557
 		$aircraft_array = array();
6558 6558
 		$temp_array = array();
6559 6559
         
6560
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6560
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6561 6561
 		{
6562 6562
 			$temp_array['registration'] = $row['registration'];
6563 6563
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6565,7 +6565,7 @@  discard block
 block discarded – undo
6565 6565
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6566 6566
 			$temp_array['airline_name'] = $row['airline_name'];
6567 6567
 			$temp_array['image_thumbnail'] = "";
6568
-			if($row['registration'] != "")
6568
+			if ($row['registration'] != "")
6569 6569
 			{
6570 6570
 				$image_array = $Image->getSpotterImage($row['registration']);
6571 6571
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6584,12 +6584,12 @@  discard block
 block discarded – undo
6584 6584
 	* @return Array the aircraft list
6585 6585
 	*
6586 6586
 	*/
6587
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6587
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6588 6588
 	{
6589 6589
 		global $globalDBdriver;
6590
-		$filter_query = $this->getFilter($filters,true,true);
6590
+		$filter_query = $this->getFilter($filters, true, true);
6591 6591
 		$Image = new Image($this->db);
6592
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6592
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6593 6593
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6594 6594
                 if ($olderthanmonths > 0) {
6595 6595
             		if ($globalDBdriver == 'mysql') {
@@ -6617,7 +6617,7 @@  discard block
 block discarded – undo
6617 6617
 		$aircraft_array = array();
6618 6618
 		$temp_array = array();
6619 6619
         
6620
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6620
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6621 6621
 		{
6622 6622
 			$temp_array['registration'] = $row['registration'];
6623 6623
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6626,7 +6626,7 @@  discard block
 block discarded – undo
6626 6626
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6627 6627
 			$temp_array['airline_name'] = $row['airline_name'];
6628 6628
 			$temp_array['image_thumbnail'] = "";
6629
-			if($row['registration'] != "")
6629
+			if ($row['registration'] != "")
6630 6630
 			{
6631 6631
 				$image_array = $Image->getSpotterImage($row['registration']);
6632 6632
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6645,11 +6645,11 @@  discard block
 block discarded – undo
6645 6645
 	* @return Array the airport list
6646 6646
 	*
6647 6647
 	*/
6648
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6648
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6649 6649
 	{
6650 6650
 		global $globalDBdriver;
6651
-		$filter_query = $this->getFilter($filters,true,true);
6652
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6651
+		$filter_query = $this->getFilter($filters, true, true);
6652
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6653 6653
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6654 6654
                 if ($olderthanmonths > 0) {
6655 6655
             		if ($globalDBdriver == 'mysql') {
@@ -6669,28 +6669,28 @@  discard block
 block discarded – undo
6669 6669
 		if ($year != '') {
6670 6670
 			if ($globalDBdriver == 'mysql') {
6671 6671
 				$query .= " AND YEAR(spotter_output.date) = :year";
6672
-				$query_values = array_merge($query_values,array(':year' => $year));
6672
+				$query_values = array_merge($query_values, array(':year' => $year));
6673 6673
 			} else {
6674 6674
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6675
-				$query_values = array_merge($query_values,array(':year' => $year));
6675
+				$query_values = array_merge($query_values, array(':year' => $year));
6676 6676
 			}
6677 6677
 		}
6678 6678
 		if ($month != '') {
6679 6679
 			if ($globalDBdriver == 'mysql') {
6680 6680
 				$query .= " AND MONTH(spotter_output.date) = :month";
6681
-				$query_values = array_merge($query_values,array(':month' => $month));
6681
+				$query_values = array_merge($query_values, array(':month' => $month));
6682 6682
 			} else {
6683 6683
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6684
-				$query_values = array_merge($query_values,array(':month' => $month));
6684
+				$query_values = array_merge($query_values, array(':month' => $month));
6685 6685
 			}
6686 6686
 		}
6687 6687
 		if ($day != '') {
6688 6688
 			if ($globalDBdriver == 'mysql') {
6689 6689
 				$query .= " AND DAY(spotter_output.date) = :day";
6690
-				$query_values = array_merge($query_values,array(':day' => $day));
6690
+				$query_values = array_merge($query_values, array(':day' => $day));
6691 6691
 			} else {
6692 6692
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6693
-				$query_values = array_merge($query_values,array(':day' => $day));
6693
+				$query_values = array_merge($query_values, array(':day' => $day));
6694 6694
 			}
6695 6695
 		}
6696 6696
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -6702,7 +6702,7 @@  discard block
 block discarded – undo
6702 6702
 
6703 6703
 		$airport_array = array();
6704 6704
 		$temp_array = array();
6705
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6705
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6706 6706
 		{
6707 6707
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6708 6708
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6721,11 +6721,11 @@  discard block
 block discarded – undo
6721 6721
 	* @return Array the airport list
6722 6722
 	*
6723 6723
 	*/
6724
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6724
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6725 6725
 	{
6726 6726
 		global $globalDBdriver;
6727
-		$filter_query = $this->getFilter($filters,true,true);
6728
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6727
+		$filter_query = $this->getFilter($filters, true, true);
6728
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6729 6729
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6730 6730
                 if ($olderthanmonths > 0) {
6731 6731
             		if ($globalDBdriver == 'mysql') {
@@ -6754,7 +6754,7 @@  discard block
 block discarded – undo
6754 6754
 		$airport_array = array();
6755 6755
 		$temp_array = array();
6756 6756
         
6757
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6757
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6758 6758
 		{
6759 6759
 			$temp_array['airline_icao'] = $row['airline_icao'];
6760 6760
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6774,11 +6774,11 @@  discard block
 block discarded – undo
6774 6774
 	* @return Array the airport list
6775 6775
 	*
6776 6776
 	*/
6777
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6777
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6778 6778
 	{
6779 6779
 		global $globalDBdriver;
6780
-		$filter_query = $this->getFilter($filters,true,true);
6781
-		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6780
+		$filter_query = $this->getFilter($filters, true, true);
6781
+		$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6782 6782
 				FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao";
6783 6783
                 if ($olderthanmonths > 0) {
6784 6784
             		if ($globalDBdriver == 'mysql') {
@@ -6798,28 +6798,28 @@  discard block
 block discarded – undo
6798 6798
 		if ($year != '') {
6799 6799
 			if ($globalDBdriver == 'mysql') {
6800 6800
 				$query .= " AND YEAR(spotter_output.date) = :year";
6801
-				$query_values = array_merge($query_values,array(':year' => $year));
6801
+				$query_values = array_merge($query_values, array(':year' => $year));
6802 6802
 			} else {
6803 6803
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6804
-				$query_values = array_merge($query_values,array(':year' => $year));
6804
+				$query_values = array_merge($query_values, array(':year' => $year));
6805 6805
 			}
6806 6806
 		}
6807 6807
 		if ($month != '') {
6808 6808
 			if ($globalDBdriver == 'mysql') {
6809 6809
 				$query .= " AND MONTH(spotter_output.date) = :month";
6810
-				$query_values = array_merge($query_values,array(':month' => $month));
6810
+				$query_values = array_merge($query_values, array(':month' => $month));
6811 6811
 			} else {
6812 6812
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6813
-				$query_values = array_merge($query_values,array(':month' => $month));
6813
+				$query_values = array_merge($query_values, array(':month' => $month));
6814 6814
 			}
6815 6815
 		}
6816 6816
 		if ($day != '') {
6817 6817
 			if ($globalDBdriver == 'mysql') {
6818 6818
 				$query .= " AND DAY(spotter_output.date) = :day";
6819
-				$query_values = array_merge($query_values,array(':day' => $day));
6819
+				$query_values = array_merge($query_values, array(':day' => $day));
6820 6820
 			} else {
6821 6821
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6822
-				$query_values = array_merge($query_values,array(':day' => $day));
6822
+				$query_values = array_merge($query_values, array(':day' => $day));
6823 6823
 			}
6824 6824
 		}
6825 6825
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
@@ -6832,7 +6832,7 @@  discard block
 block discarded – undo
6832 6832
 		$airport_array = array();
6833 6833
 		$temp_array = array();
6834 6834
         
6835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6836 6836
 		{
6837 6837
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6838 6838
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6851,11 +6851,11 @@  discard block
 block discarded – undo
6851 6851
 	* @return Array the airport list
6852 6852
 	*
6853 6853
 	*/
6854
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6854
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6855 6855
 	{
6856 6856
 		global $globalDBdriver;
6857
-		$filter_query = $this->getFilter($filters,true,true);
6858
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6857
+		$filter_query = $this->getFilter($filters, true, true);
6858
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6859 6859
 				FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
6860 6860
                 if ($olderthanmonths > 0) {
6861 6861
             		if ($globalDBdriver == 'mysql') {
@@ -6884,7 +6884,7 @@  discard block
 block discarded – undo
6884 6884
 		$airport_array = array();
6885 6885
 		$temp_array = array();
6886 6886
         
6887
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6887
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6888 6888
 		{
6889 6889
 			$temp_array['airline_icao'] = $row['airline_icao'];
6890 6890
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6904,11 +6904,11 @@  discard block
 block discarded – undo
6904 6904
 	* @return Array the airport list
6905 6905
 	*
6906 6906
 	*/
6907
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6907
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
6908 6908
 	{
6909
-		$filter_query = $this->getFilter($filters,true,true);
6910
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6911
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6909
+		$filter_query = $this->getFilter($filters, true, true);
6910
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6911
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6912 6912
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> '' 
6913 6913
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6914 6914
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6920,7 +6920,7 @@  discard block
 block discarded – undo
6920 6920
 		$airport_array = array();
6921 6921
 		$temp_array = array();
6922 6922
         
6923
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6923
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6924 6924
 		{
6925 6925
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6926 6926
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6942,11 +6942,11 @@  discard block
 block discarded – undo
6942 6942
 	* @return Array the airport list
6943 6943
 	*
6944 6944
 	*/
6945
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6945
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
6946 6946
 	{
6947
-		$filter_query = $this->getFilter($filters,true,true);
6948
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6949
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6947
+		$filter_query = $this->getFilter($filters, true, true);
6948
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6949
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6950 6950
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6951 6951
                     GROUP BY spotter_output.departure_airport_country
6952 6952
 					ORDER BY airport_departure_country_count DESC";
@@ -6958,7 +6958,7 @@  discard block
 block discarded – undo
6958 6958
 		$airport_array = array();
6959 6959
 		$temp_array = array();
6960 6960
         
6961
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6961
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6962 6962
 		{
6963 6963
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6964 6964
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6977,11 +6977,11 @@  discard block
 block discarded – undo
6977 6977
 	* @return Array the airport list
6978 6978
 	*
6979 6979
 	*/
6980
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6980
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
6981 6981
 	{
6982
-		$filter_query = $this->getFilter($filters,true,true);
6983
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6984
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6982
+		$filter_query = $this->getFilter($filters, true, true);
6983
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6984
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6985 6985
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> '' 
6986 6986
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6987 6987
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6993,7 +6993,7 @@  discard block
 block discarded – undo
6993 6993
 		$airport_array = array();
6994 6994
 		$temp_array = array();
6995 6995
         
6996
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6996
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6997 6997
 		{
6998 6998
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6999 6999
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7014,11 +7014,11 @@  discard block
 block discarded – undo
7014 7014
 	* @return Array the airport list
7015 7015
 	*
7016 7016
 	*/
7017
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7017
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
7018 7018
 	{
7019
-		$filter_query = $this->getFilter($filters,true,true);
7020
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7021
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7019
+		$filter_query = $this->getFilter($filters, true, true);
7020
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7021
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7022 7022
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
7023 7023
                     GROUP BY spotter_output.departure_airport_country
7024 7024
 					ORDER BY airport_departure_country_count DESC";
@@ -7030,7 +7030,7 @@  discard block
 block discarded – undo
7030 7030
 		$airport_array = array();
7031 7031
 		$temp_array = array();
7032 7032
         
7033
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7033
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7034 7034
 		{
7035 7035
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7036 7036
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7048,11 +7048,11 @@  discard block
 block discarded – undo
7048 7048
 	* @return Array the airport list
7049 7049
 	*
7050 7050
 	*/
7051
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7051
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
7052 7052
 	{
7053
-		$filter_query = $this->getFilter($filters,true,true);
7054
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7055
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7053
+		$filter_query = $this->getFilter($filters, true, true);
7054
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7055
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7056 7056
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> '' 
7057 7057
                     GROUP BY spotter_output.departure_airport_icao
7058 7058
 					ORDER BY airport_departure_icao_count DESC";
@@ -7064,7 +7064,7 @@  discard block
 block discarded – undo
7064 7064
 		$airport_array = array();
7065 7065
 		$temp_array = array();
7066 7066
         
7067
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7067
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7068 7068
 		{
7069 7069
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7070 7070
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7085,11 +7085,11 @@  discard block
 block discarded – undo
7085 7085
 	* @return Array the airport list
7086 7086
 	*
7087 7087
 	*/
7088
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7088
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
7089 7089
 	{
7090
-		$filter_query = $this->getFilter($filters,true,true);
7091
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7092
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7090
+		$filter_query = $this->getFilter($filters, true, true);
7091
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7092
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7093 7093
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
7094 7094
                     GROUP BY spotter_output.departure_airport_country
7095 7095
 					ORDER BY airport_departure_country_count DESC";
@@ -7101,7 +7101,7 @@  discard block
 block discarded – undo
7101 7101
 		$airport_array = array();
7102 7102
 		$temp_array = array();
7103 7103
         
7104
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7104
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7105 7105
 		{
7106 7106
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7107 7107
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7119,11 +7119,11 @@  discard block
 block discarded – undo
7119 7119
 	* @return Array the airport list
7120 7120
 	*
7121 7121
 	*/
7122
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7122
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
7123 7123
 	{
7124
-		$filter_query = $this->getFilter($filters,true,true);
7125
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7126
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7124
+		$filter_query = $this->getFilter($filters, true, true);
7125
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7126
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7127 7127
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao AND spotter_output.departure_airport_icao <> '' 
7128 7128
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7129 7129
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7135,7 +7135,7 @@  discard block
 block discarded – undo
7135 7135
 		$airport_array = array();
7136 7136
 		$temp_array = array();
7137 7137
         
7138
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7138
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7139 7139
 		{
7140 7140
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7141 7141
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7156,11 +7156,11 @@  discard block
 block discarded – undo
7156 7156
 	* @return Array the airport list
7157 7157
 	*
7158 7158
 	*/
7159
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7159
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
7160 7160
 	{
7161
-		$filter_query = $this->getFilter($filters,true,true);
7162
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7163
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7161
+		$filter_query = $this->getFilter($filters, true, true);
7162
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7163
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7164 7164
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
7165 7165
                     GROUP BY spotter_output.departure_airport_country
7166 7166
 					ORDER BY airport_departure_country_count DESC";
@@ -7172,7 +7172,7 @@  discard block
 block discarded – undo
7172 7172
 		$airport_array = array();
7173 7173
 		$temp_array = array();
7174 7174
         
7175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7176 7176
 		{
7177 7177
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7178 7178
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7191,11 +7191,11 @@  discard block
 block discarded – undo
7191 7191
 	* @return Array the airport list
7192 7192
 	*
7193 7193
 	*/
7194
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7194
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
7195 7195
 	{
7196
-		$filter_query = $this->getFilter($filters,true,true);
7197
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7198
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7196
+		$filter_query = $this->getFilter($filters, true, true);
7197
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7198
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7199 7199
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> '' 
7200 7200
                     GROUP BY spotter_output.departure_airport_icao
7201 7201
 					ORDER BY airport_departure_icao_count DESC";
@@ -7207,7 +7207,7 @@  discard block
 block discarded – undo
7207 7207
 		$airport_array = array();
7208 7208
 		$temp_array = array();
7209 7209
         
7210
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7210
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7211 7211
 		{
7212 7212
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7213 7213
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7228,11 +7228,11 @@  discard block
 block discarded – undo
7228 7228
 	* @return Array the airport list
7229 7229
 	*
7230 7230
 	*/
7231
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7231
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
7232 7232
 	{
7233
-		$filter_query = $this->getFilter($filters,true,true);
7234
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7235
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7233
+		$filter_query = $this->getFilter($filters, true, true);
7234
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7235
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7236 7236
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
7237 7237
                     GROUP BY spotter_output.departure_airport_country
7238 7238
 					ORDER BY airport_departure_country_count DESC";
@@ -7244,7 +7244,7 @@  discard block
 block discarded – undo
7244 7244
 		$airport_array = array();
7245 7245
 		$temp_array = array();
7246 7246
         
7247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7248 7248
 		{
7249 7249
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7250 7250
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7262,11 +7262,11 @@  discard block
 block discarded – undo
7262 7262
 	* @return Array the airport list
7263 7263
 	*
7264 7264
 	*/
7265
-	public function countAllDepartureAirportsByDate($date,$filters = array())
7265
+	public function countAllDepartureAirportsByDate($date, $filters = array())
7266 7266
 	{
7267 7267
 		global $globalTimezone, $globalDBdriver;
7268
-		$filter_query = $this->getFilter($filters,true,true);
7269
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7268
+		$filter_query = $this->getFilter($filters, true, true);
7269
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7270 7270
 		if ($globalTimezone != '') {
7271 7271
 			date_default_timezone_set($globalTimezone);
7272 7272
 			$datetime = new DateTime($date);
@@ -7274,12 +7274,12 @@  discard block
 block discarded – undo
7274 7274
 		} else $offset = '+00:00';
7275 7275
 
7276 7276
 		if ($globalDBdriver == 'mysql') {
7277
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7277
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7278 7278
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
7279 7279
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7280 7280
 					ORDER BY airport_departure_icao_count DESC";
7281 7281
 		} else {
7282
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7282
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7283 7283
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
7284 7284
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7285 7285
 					ORDER BY airport_departure_icao_count DESC";
@@ -7291,7 +7291,7 @@  discard block
 block discarded – undo
7291 7291
 		$airport_array = array();
7292 7292
 		$temp_array = array();
7293 7293
         
7294
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7294
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7295 7295
 		{
7296 7296
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7297 7297
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7312,11 +7312,11 @@  discard block
 block discarded – undo
7312 7312
 	* @return Array the airport list
7313 7313
 	*
7314 7314
 	*/
7315
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7315
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
7316 7316
 	{
7317 7317
 		global $globalTimezone, $globalDBdriver;
7318
-		$filter_query = $this->getFilter($filters,true,true);
7319
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7318
+		$filter_query = $this->getFilter($filters, true, true);
7319
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7320 7320
 		if ($globalTimezone != '') {
7321 7321
 			date_default_timezone_set($globalTimezone);
7322 7322
 			$datetime = new DateTime($date);
@@ -7324,12 +7324,12 @@  discard block
 block discarded – undo
7324 7324
 		} else $offset = '+00:00';
7325 7325
 
7326 7326
 		if ($globalDBdriver == 'mysql') {
7327
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7327
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7328 7328
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
7329 7329
 					GROUP BY spotter_output.departure_airport_country
7330 7330
 					ORDER BY airport_departure_country_count DESC";
7331 7331
 		} else {
7332
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7332
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7333 7333
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
7334 7334
 					GROUP BY spotter_output.departure_airport_country
7335 7335
 					ORDER BY airport_departure_country_count DESC";
@@ -7341,7 +7341,7 @@  discard block
 block discarded – undo
7341 7341
 		$airport_array = array();
7342 7342
 		$temp_array = array();
7343 7343
         
7344
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7344
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7345 7345
 		{
7346 7346
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7347 7347
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7359,11 +7359,11 @@  discard block
 block discarded – undo
7359 7359
 	* @return Array the airport list
7360 7360
 	*
7361 7361
 	*/
7362
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7362
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
7363 7363
 	{
7364
-		$filter_query = $this->getFilter($filters,true,true);
7365
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7366
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7364
+		$filter_query = $this->getFilter($filters, true, true);
7365
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7366
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7367 7367
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident 
7368 7368
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7369 7369
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7375,7 +7375,7 @@  discard block
 block discarded – undo
7375 7375
 		$airport_array = array();
7376 7376
 		$temp_array = array();
7377 7377
         
7378
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7378
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7379 7379
 		{
7380 7380
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7381 7381
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7395,11 +7395,11 @@  discard block
 block discarded – undo
7395 7395
 	* @return Array the airport list
7396 7396
 	*
7397 7397
 	*/
7398
-	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7398
+	public function countAllDepartureAirportsByOwner($owner, $filters = array())
7399 7399
 	{
7400
-		$filter_query = $this->getFilter($filters,true,true);
7401
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7402
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7400
+		$filter_query = $this->getFilter($filters, true, true);
7401
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7402
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7403 7403
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner 
7404 7404
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7405 7405
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7411,7 +7411,7 @@  discard block
 block discarded – undo
7411 7411
 		$airport_array = array();
7412 7412
 		$temp_array = array();
7413 7413
         
7414
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7414
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7415 7415
 		{
7416 7416
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7417 7417
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7431,11 +7431,11 @@  discard block
 block discarded – undo
7431 7431
 	* @return Array the airport list
7432 7432
 	*
7433 7433
 	*/
7434
-	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7434
+	public function countAllDepartureAirportsByPilot($pilot, $filters = array())
7435 7435
 	{
7436
-		$filter_query = $this->getFilter($filters,true,true);
7437
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7438
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7436
+		$filter_query = $this->getFilter($filters, true, true);
7437
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7438
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7439 7439
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7440 7440
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7441 7441
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7446,7 +7446,7 @@  discard block
 block discarded – undo
7446 7446
 		$airport_array = array();
7447 7447
 		$temp_array = array();
7448 7448
         
7449
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7449
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7450 7450
 		{
7451 7451
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7452 7452
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7468,11 +7468,11 @@  discard block
 block discarded – undo
7468 7468
 	* @return Array the airport list
7469 7469
 	*
7470 7470
 	*/
7471
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7471
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
7472 7472
 	{
7473
-		$filter_query = $this->getFilter($filters,true,true);
7474
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7475
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7473
+		$filter_query = $this->getFilter($filters, true, true);
7474
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7475
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7476 7476
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
7477 7477
                     GROUP BY spotter_output.departure_airport_country
7478 7478
 					ORDER BY airport_departure_country_count DESC";
@@ -7484,7 +7484,7 @@  discard block
 block discarded – undo
7484 7484
 		$airport_array = array();
7485 7485
 		$temp_array = array();
7486 7486
         
7487
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7487
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7488 7488
 		{
7489 7489
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7490 7490
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7501,11 +7501,11 @@  discard block
 block discarded – undo
7501 7501
 	* @return Array the airport list
7502 7502
 	*
7503 7503
 	*/
7504
-	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7504
+	public function countAllDepartureAirportCountriesByOwner($owner, $filters = array())
7505 7505
 	{
7506
-		$filter_query = $this->getFilter($filters,true,true);
7507
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7508
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7506
+		$filter_query = $this->getFilter($filters, true, true);
7507
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7508
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7509 7509
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner 
7510 7510
 			GROUP BY spotter_output.departure_airport_country
7511 7511
 			ORDER BY airport_departure_country_count DESC";
@@ -7521,11 +7521,11 @@  discard block
 block discarded – undo
7521 7521
 	* @return Array the airport list
7522 7522
 	*
7523 7523
 	*/
7524
-	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7524
+	public function countAllDepartureAirportCountriesByPilot($pilot, $filters = array())
7525 7525
 	{
7526
-		$filter_query = $this->getFilter($filters,true,true);
7527
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7528
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7526
+		$filter_query = $this->getFilter($filters, true, true);
7527
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7528
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7529 7529
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7530 7530
 			GROUP BY spotter_output.departure_airport_country
7531 7531
 			ORDER BY airport_departure_country_count DESC";
@@ -7543,12 +7543,12 @@  discard block
 block discarded – undo
7543 7543
 	* @return Array the airport list
7544 7544
 	*
7545 7545
 	*/
7546
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
7546
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
7547 7547
 	{
7548
-		$filter_query = $this->getFilter($filters,true,true);
7549
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7548
+		$filter_query = $this->getFilter($filters, true, true);
7549
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7550 7550
 
7551
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7551
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7552 7552
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
7553 7553
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7554 7554
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7560,7 +7560,7 @@  discard block
 block discarded – undo
7560 7560
 		$airport_array = array();
7561 7561
 		$temp_array = array();
7562 7562
         
7563
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7563
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7564 7564
 		{
7565 7565
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7566 7566
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7581,11 +7581,11 @@  discard block
 block discarded – undo
7581 7581
 	* @return Array the airport list
7582 7582
 	*
7583 7583
 	*/
7584
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7584
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
7585 7585
 	{
7586
-		$filter_query = $this->getFilter($filters,true,true);
7587
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7588
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7586
+		$filter_query = $this->getFilter($filters, true, true);
7587
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7588
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7589 7589
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7590 7590
                     GROUP BY spotter_output.departure_airport_country
7591 7591
 					ORDER BY airport_departure_country_count DESC";
@@ -7597,7 +7597,7 @@  discard block
 block discarded – undo
7597 7597
 		$airport_array = array();
7598 7598
 		$temp_array = array();
7599 7599
         
7600
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7600
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7601 7601
 		{
7602 7602
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7603 7603
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7620,11 +7620,11 @@  discard block
 block discarded – undo
7620 7620
 	* @return Array the airport list
7621 7621
 	*
7622 7622
 	*/
7623
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7623
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7624 7624
 	{
7625 7625
 		global $globalDBdriver;
7626
-		$filter_query = $this->getFilter($filters,true,true);
7627
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7626
+		$filter_query = $this->getFilter($filters, true, true);
7627
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7628 7628
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7629 7629
                 if ($olderthanmonths > 0) {
7630 7630
             		if ($globalDBdriver == 'mysql') {
@@ -7644,28 +7644,28 @@  discard block
 block discarded – undo
7644 7644
 		if ($year != '') {
7645 7645
 			if ($globalDBdriver == 'mysql') {
7646 7646
 				$query .= " AND YEAR(spotter_output.date) = :year";
7647
-				$query_values = array_merge($query_values,array(':year' => $year));
7647
+				$query_values = array_merge($query_values, array(':year' => $year));
7648 7648
 			} else {
7649 7649
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7650
-				$query_values = array_merge($query_values,array(':year' => $year));
7650
+				$query_values = array_merge($query_values, array(':year' => $year));
7651 7651
 			}
7652 7652
 		}
7653 7653
 		if ($month != '') {
7654 7654
 			if ($globalDBdriver == 'mysql') {
7655 7655
 				$query .= " AND MONTH(spotter_output.date) = :month";
7656
-				$query_values = array_merge($query_values,array(':month' => $month));
7656
+				$query_values = array_merge($query_values, array(':month' => $month));
7657 7657
 			} else {
7658 7658
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7659
-				$query_values = array_merge($query_values,array(':month' => $month));
7659
+				$query_values = array_merge($query_values, array(':month' => $month));
7660 7660
 			}
7661 7661
 		}
7662 7662
 		if ($day != '') {
7663 7663
 			if ($globalDBdriver == 'mysql') {
7664 7664
 				$query .= " AND DAY(spotter_output.date) = :day";
7665
-				$query_values = array_merge($query_values,array(':day' => $day));
7665
+				$query_values = array_merge($query_values, array(':day' => $day));
7666 7666
 			} else {
7667 7667
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7668
-				$query_values = array_merge($query_values,array(':day' => $day));
7668
+				$query_values = array_merge($query_values, array(':day' => $day));
7669 7669
 			}
7670 7670
 		}
7671 7671
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7679,7 +7679,7 @@  discard block
 block discarded – undo
7679 7679
 		$airport_array = array();
7680 7680
 		$temp_array = array();
7681 7681
         
7682
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7682
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7683 7683
 		{
7684 7684
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7685 7685
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7702,11 +7702,11 @@  discard block
 block discarded – undo
7702 7702
 	* @return Array the airport list
7703 7703
 	*
7704 7704
 	*/
7705
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7705
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7706 7706
 	{
7707 7707
 		global $globalDBdriver;
7708
-		$filter_query = $this->getFilter($filters,true,true);
7709
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7708
+		$filter_query = $this->getFilter($filters, true, true);
7709
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7710 7710
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7711 7711
                 if ($olderthanmonths > 0) {
7712 7712
             		if ($globalDBdriver == 'mysql') {
@@ -7736,7 +7736,7 @@  discard block
 block discarded – undo
7736 7736
 		$airport_array = array();
7737 7737
 		$temp_array = array();
7738 7738
         
7739
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7739
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7740 7740
 		{
7741 7741
 			$temp_array['airline_icao'] = $row['airline_icao'];
7742 7742
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -7761,11 +7761,11 @@  discard block
 block discarded – undo
7761 7761
 	* @return Array the airport list
7762 7762
 	*
7763 7763
 	*/
7764
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7764
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7765 7765
 	{
7766 7766
 		global $globalDBdriver;
7767
-		$filter_query = $this->getFilter($filters,true,true);
7768
-		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7767
+		$filter_query = $this->getFilter($filters, true, true);
7768
+		$query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7769 7769
 			FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao";
7770 7770
                 if ($olderthanmonths > 0) {
7771 7771
             		if ($globalDBdriver == 'mysql') {
@@ -7785,28 +7785,28 @@  discard block
 block discarded – undo
7785 7785
 		if ($year != '') {
7786 7786
 			if ($globalDBdriver == 'mysql') {
7787 7787
 				$query .= " AND YEAR(spotter_output.date) = :year";
7788
-				$query_values = array_merge($query_values,array(':year' => $year));
7788
+				$query_values = array_merge($query_values, array(':year' => $year));
7789 7789
 			} else {
7790 7790
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7791
-				$query_values = array_merge($query_values,array(':year' => $year));
7791
+				$query_values = array_merge($query_values, array(':year' => $year));
7792 7792
 			}
7793 7793
 		}
7794 7794
 		if ($month != '') {
7795 7795
 			if ($globalDBdriver == 'mysql') {
7796 7796
 				$query .= " AND MONTH(spotter_output.date) = :month";
7797
-				$query_values = array_merge($query_values,array(':month' => $month));
7797
+				$query_values = array_merge($query_values, array(':month' => $month));
7798 7798
 			} else {
7799 7799
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7800
-				$query_values = array_merge($query_values,array(':month' => $month));
7800
+				$query_values = array_merge($query_values, array(':month' => $month));
7801 7801
 			}
7802 7802
 		}
7803 7803
 		if ($day != '') {
7804 7804
 			if ($globalDBdriver == 'mysql') {
7805 7805
 				$query .= " AND DAY(spotter_output.date) = :day";
7806
-				$query_values = array_merge($query_values,array(':day' => $day));
7806
+				$query_values = array_merge($query_values, array(':day' => $day));
7807 7807
 			} else {
7808 7808
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7809
-				$query_values = array_merge($query_values,array(':day' => $day));
7809
+				$query_values = array_merge($query_values, array(':day' => $day));
7810 7810
 			}
7811 7811
 		}
7812 7812
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
@@ -7819,7 +7819,7 @@  discard block
 block discarded – undo
7819 7819
       
7820 7820
 		$airport_array = array();
7821 7821
 		$temp_array = array();
7822
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7822
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7823 7823
 		{
7824 7824
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7825 7825
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7842,11 +7842,11 @@  discard block
 block discarded – undo
7842 7842
 	* @return Array the airport list
7843 7843
 	*
7844 7844
 	*/
7845
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7845
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7846 7846
 	{
7847 7847
 		global $globalDBdriver;
7848
-		$filter_query = $this->getFilter($filters,true,true);
7849
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7848
+		$filter_query = $this->getFilter($filters, true, true);
7849
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7850 7850
 			FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
7851 7851
                 if ($olderthanmonths > 0) {
7852 7852
             		if ($globalDBdriver == 'mysql') {
@@ -7876,7 +7876,7 @@  discard block
 block discarded – undo
7876 7876
 		$airport_array = array();
7877 7877
 		$temp_array = array();
7878 7878
         
7879
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7879
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7880 7880
 		{
7881 7881
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7882 7882
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7902,9 +7902,9 @@  discard block
 block discarded – undo
7902 7902
 	*/
7903 7903
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7904 7904
 	{
7905
-		$filter_query = $this->getFilter($filters,true,true);
7906
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7907
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7905
+		$filter_query = $this->getFilter($filters, true, true);
7906
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7907
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7908 7908
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao 
7909 7909
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7910 7910
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7915,7 +7915,7 @@  discard block
 block discarded – undo
7915 7915
 		$airport_array = array();
7916 7916
 		$temp_array = array();
7917 7917
         
7918
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7918
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7919 7919
 		{
7920 7920
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7921 7921
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7936,12 +7936,12 @@  discard block
 block discarded – undo
7936 7936
 	* @return Array the airport list
7937 7937
 	*
7938 7938
 	*/
7939
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7939
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
7940 7940
 	{
7941
-		$filter_query = $this->getFilter($filters,true,true);
7942
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7941
+		$filter_query = $this->getFilter($filters, true, true);
7942
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7943 7943
 					
7944
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7944
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7945 7945
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
7946 7946
                     GROUP BY spotter_output.arrival_airport_country
7947 7947
 					ORDER BY airport_arrival_country_count DESC";
@@ -7953,7 +7953,7 @@  discard block
 block discarded – undo
7953 7953
 		$airport_array = array();
7954 7954
 		$temp_array = array();
7955 7955
         
7956
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7956
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7957 7957
 		{
7958 7958
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7959 7959
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7971,11 +7971,11 @@  discard block
 block discarded – undo
7971 7971
 	* @return Array the airport list
7972 7972
 	*
7973 7973
 	*/
7974
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7974
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
7975 7975
 	{
7976
-		$filter_query = $this->getFilter($filters,true,true);
7977
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7978
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7976
+		$filter_query = $this->getFilter($filters, true, true);
7977
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7978
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7979 7979
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7980 7980
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7981 7981
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7987,7 +7987,7 @@  discard block
 block discarded – undo
7987 7987
 		$airport_array = array();
7988 7988
 		$temp_array = array();
7989 7989
         
7990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7991 7991
 		{
7992 7992
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7993 7993
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8009,11 +8009,11 @@  discard block
 block discarded – undo
8009 8009
 	* @return Array the airport list
8010 8010
 	*
8011 8011
 	*/
8012
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8012
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
8013 8013
 	{
8014
-		$filter_query = $this->getFilter($filters,true,true);
8015
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8016
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8014
+		$filter_query = $this->getFilter($filters, true, true);
8015
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8016
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8017 8017
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
8018 8018
                     GROUP BY spotter_output.arrival_airport_country
8019 8019
 					ORDER BY airport_arrival_country_count DESC";
@@ -8025,7 +8025,7 @@  discard block
 block discarded – undo
8025 8025
 		$airport_array = array();
8026 8026
 		$temp_array = array();
8027 8027
         
8028
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8028
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8029 8029
 		{
8030 8030
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8031 8031
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8043,12 +8043,12 @@  discard block
 block discarded – undo
8043 8043
 	* @return Array the airport list
8044 8044
 	*
8045 8045
 	*/
8046
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8046
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
8047 8047
 	{
8048
-		$filter_query = $this->getFilter($filters,true,true);
8049
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8048
+		$filter_query = $this->getFilter($filters, true, true);
8049
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8050 8050
 
8051
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8051
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8052 8052
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.registration = :registration 
8053 8053
                     GROUP BY spotter_output.arrival_airport_icao
8054 8054
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8060,7 +8060,7 @@  discard block
 block discarded – undo
8060 8060
 		$airport_array = array();
8061 8061
 		$temp_array = array();
8062 8062
         
8063
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8063
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8064 8064
 		{
8065 8065
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8066 8066
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8081,11 +8081,11 @@  discard block
 block discarded – undo
8081 8081
 	* @return Array the airport list
8082 8082
 	*
8083 8083
 	*/
8084
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8084
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
8085 8085
 	{
8086
-		$filter_query = $this->getFilter($filters,true,true);
8087
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8088
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8086
+		$filter_query = $this->getFilter($filters, true, true);
8087
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8088
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8089 8089
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
8090 8090
                     GROUP BY spotter_output.arrival_airport_country
8091 8091
 					ORDER BY airport_arrival_country_count DESC";
@@ -8097,7 +8097,7 @@  discard block
 block discarded – undo
8097 8097
 		$airport_array = array();
8098 8098
 		$temp_array = array();
8099 8099
         
8100
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8100
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8101 8101
 		{
8102 8102
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8103 8103
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8116,11 +8116,11 @@  discard block
 block discarded – undo
8116 8116
 	* @return Array the airport list
8117 8117
 	*
8118 8118
 	*/
8119
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8119
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
8120 8120
 	{
8121
-		$filter_query = $this->getFilter($filters,true,true);
8122
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8123
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8121
+		$filter_query = $this->getFilter($filters, true, true);
8122
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8123
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8124 8124
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8125 8125
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8126 8126
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8132,7 +8132,7 @@  discard block
 block discarded – undo
8132 8132
 		$airport_array = array();
8133 8133
 		$temp_array = array();
8134 8134
         
8135
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8135
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8136 8136
 		{
8137 8137
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8138 8138
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8153,11 +8153,11 @@  discard block
 block discarded – undo
8153 8153
 	* @return Array the airport list
8154 8154
 	*
8155 8155
 	*/
8156
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8156
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
8157 8157
 	{
8158
-		$filter_query = $this->getFilter($filters,true,true);
8159
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8160
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8158
+		$filter_query = $this->getFilter($filters, true, true);
8159
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8160
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8161 8161
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8162 8162
                     GROUP BY spotter_output.arrival_airport_country
8163 8163
 					ORDER BY airport_arrival_country_count DESC";
@@ -8169,7 +8169,7 @@  discard block
 block discarded – undo
8169 8169
 		$airport_array = array();
8170 8170
 		$temp_array = array();
8171 8171
         
8172
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8172
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8173 8173
 		{
8174 8174
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8175 8175
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8187,11 +8187,11 @@  discard block
 block discarded – undo
8187 8187
 	* @return Array the airport list
8188 8188
 	*
8189 8189
 	*/
8190
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8190
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
8191 8191
 	{
8192
-		$filter_query = $this->getFilter($filters,true,true);
8193
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8194
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8192
+		$filter_query = $this->getFilter($filters, true, true);
8193
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8194
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8195 8195
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8196 8196
                     GROUP BY spotter_output.arrival_airport_icao
8197 8197
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8203,7 +8203,7 @@  discard block
 block discarded – undo
8203 8203
 		$airport_array = array();
8204 8204
 		$temp_array = array();
8205 8205
         
8206
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8206
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8207 8207
 		{
8208 8208
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8209 8209
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8225,11 +8225,11 @@  discard block
 block discarded – undo
8225 8225
 	* @return Array the airport list
8226 8226
 	*
8227 8227
 	*/
8228
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8228
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
8229 8229
 	{
8230
-		$filter_query = $this->getFilter($filters,true,true);
8231
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8232
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8230
+		$filter_query = $this->getFilter($filters, true, true);
8231
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8232
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8233 8233
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8234 8234
                     GROUP BY spotter_output.arrival_airport_country
8235 8235
 					ORDER BY airport_arrival_country_count DESC";
@@ -8241,7 +8241,7 @@  discard block
 block discarded – undo
8241 8241
 		$airport_array = array();
8242 8242
 		$temp_array = array();
8243 8243
         
8244
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8244
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8245 8245
 		{
8246 8246
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8247 8247
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8260,11 +8260,11 @@  discard block
 block discarded – undo
8260 8260
 	* @return Array the airport list
8261 8261
 	*
8262 8262
 	*/
8263
-	public function countAllArrivalAirportsByDate($date,$filters = array())
8263
+	public function countAllArrivalAirportsByDate($date, $filters = array())
8264 8264
 	{
8265 8265
 		global $globalTimezone, $globalDBdriver;
8266
-		$filter_query = $this->getFilter($filters,true,true);
8267
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8266
+		$filter_query = $this->getFilter($filters, true, true);
8267
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8268 8268
 		if ($globalTimezone != '') {
8269 8269
 			date_default_timezone_set($globalTimezone);
8270 8270
 			$datetime = new DateTime($date);
@@ -8272,12 +8272,12 @@  discard block
 block discarded – undo
8272 8272
 		} else $offset = '+00:00';
8273 8273
 
8274 8274
 		if ($globalDBdriver == 'mysql') {
8275
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8275
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8276 8276
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
8277 8277
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8278 8278
 					ORDER BY airport_arrival_icao_count DESC";
8279 8279
 		} else {
8280
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8280
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8281 8281
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
8282 8282
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8283 8283
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8289,7 +8289,7 @@  discard block
 block discarded – undo
8289 8289
 		$airport_array = array();
8290 8290
 		$temp_array = array();
8291 8291
         
8292
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8292
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8293 8293
 		{
8294 8294
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8295 8295
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8313,8 +8313,8 @@  discard block
 block discarded – undo
8313 8313
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8314 8314
 	{
8315 8315
 		global $globalTimezone, $globalDBdriver;
8316
-		$filter_query = $this->getFilter($filters,true,true);
8317
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8316
+		$filter_query = $this->getFilter($filters, true, true);
8317
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8318 8318
 		if ($globalTimezone != '') {
8319 8319
 			date_default_timezone_set($globalTimezone);
8320 8320
 			$datetime = new DateTime($date);
@@ -8322,12 +8322,12 @@  discard block
 block discarded – undo
8322 8322
 		} else $offset = '+00:00';
8323 8323
 
8324 8324
 		if ($globalDBdriver == 'mysql') {
8325
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8325
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8326 8326
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
8327 8327
 					GROUP BY spotter_output.arrival_airport_country
8328 8328
 					ORDER BY airport_arrival_country_count DESC";
8329 8329
 		} else {
8330
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8330
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8331 8331
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
8332 8332
 					GROUP BY spotter_output.arrival_airport_country
8333 8333
 					ORDER BY airport_arrival_country_count DESC";
@@ -8339,7 +8339,7 @@  discard block
 block discarded – undo
8339 8339
 		$airport_array = array();
8340 8340
 		$temp_array = array();
8341 8341
         
8342
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8342
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8343 8343
 		{
8344 8344
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8345 8345
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8357,11 +8357,11 @@  discard block
 block discarded – undo
8357 8357
 	* @return Array the airport list
8358 8358
 	*
8359 8359
 	*/
8360
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8360
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
8361 8361
 	{
8362
-		$filter_query = $this->getFilter($filters,true,true);
8363
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8364
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8362
+		$filter_query = $this->getFilter($filters, true, true);
8363
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8364
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8365 8365
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.ident = :ident  
8366 8366
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8367 8367
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8373,7 +8373,7 @@  discard block
 block discarded – undo
8373 8373
 		$airport_array = array();
8374 8374
 		$temp_array = array();
8375 8375
         
8376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8377 8377
 		{
8378 8378
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8379 8379
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8393,11 +8393,11 @@  discard block
 block discarded – undo
8393 8393
 	* @return Array the airport list
8394 8394
 	*
8395 8395
 	*/
8396
-	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8396
+	public function countAllArrivalAirportsByOwner($owner, $filters = array())
8397 8397
 	{
8398
-		$filter_query = $this->getFilter($filters,true,true);
8399
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8400
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8398
+		$filter_query = $this->getFilter($filters, true, true);
8399
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8400
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8401 8401
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.owner_name = :owner 
8402 8402
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8403 8403
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8408,7 +8408,7 @@  discard block
 block discarded – undo
8408 8408
 		$airport_array = array();
8409 8409
 		$temp_array = array();
8410 8410
         
8411
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8411
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8412 8412
 		{
8413 8413
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8414 8414
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8428,11 +8428,11 @@  discard block
 block discarded – undo
8428 8428
 	* @return Array the airport list
8429 8429
 	*
8430 8430
 	*/
8431
-	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8431
+	public function countAllArrivalAirportsByPilot($pilot, $filters = array())
8432 8432
 	{
8433
-		$filter_query = $this->getFilter($filters,true,true);
8434
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8435
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8433
+		$filter_query = $this->getFilter($filters, true, true);
8434
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8435
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8436 8436
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8437 8437
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8438 8438
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8443,7 +8443,7 @@  discard block
 block discarded – undo
8443 8443
 		$airport_array = array();
8444 8444
 		$temp_array = array();
8445 8445
         
8446
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8446
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8447 8447
 		{
8448 8448
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8449 8449
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8465,9 +8465,9 @@  discard block
 block discarded – undo
8465 8465
 	*/
8466 8466
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8467 8467
 	{
8468
-		$filter_query = $this->getFilter($filters,true,true);
8469
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8470
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8468
+		$filter_query = $this->getFilter($filters, true, true);
8469
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8470
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8471 8471
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
8472 8472
                     GROUP BY spotter_output.arrival_airport_country
8473 8473
 					ORDER BY airport_arrival_country_count DESC";
@@ -8479,7 +8479,7 @@  discard block
 block discarded – undo
8479 8479
 		$airport_array = array();
8480 8480
 		$temp_array = array();
8481 8481
         
8482
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8482
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8483 8483
 		{
8484 8484
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8485 8485
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8498,9 +8498,9 @@  discard block
 block discarded – undo
8498 8498
 	*/
8499 8499
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8500 8500
 	{
8501
-		$filter_query = $this->getFilter($filters,true,true);
8502
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8503
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8501
+		$filter_query = $this->getFilter($filters, true, true);
8502
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8503
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8504 8504
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner 
8505 8505
                     GROUP BY spotter_output.arrival_airport_country
8506 8506
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8518,9 +8518,9 @@  discard block
 block discarded – undo
8518 8518
 	*/
8519 8519
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8520 8520
 	{
8521
-		$filter_query = $this->getFilter($filters,true,true);
8522
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8523
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8521
+		$filter_query = $this->getFilter($filters, true, true);
8522
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8523
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8524 8524
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8525 8525
                     GROUP BY spotter_output.arrival_airport_country
8526 8526
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8538,11 +8538,11 @@  discard block
 block discarded – undo
8538 8538
 	* @return Array the airport list
8539 8539
 	*
8540 8540
 	*/
8541
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
8541
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
8542 8542
 	{
8543
-		$filter_query = $this->getFilter($filters,true,true);
8544
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8545
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8543
+		$filter_query = $this->getFilter($filters, true, true);
8544
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8545
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8546 8546
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
8547 8547
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8548 8548
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8554,7 +8554,7 @@  discard block
 block discarded – undo
8554 8554
 		$airport_array = array();
8555 8555
 		$temp_array = array();
8556 8556
         
8557
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8557
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8558 8558
 		{
8559 8559
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8560 8560
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8575,12 +8575,12 @@  discard block
 block discarded – undo
8575 8575
 	* @return Array the airport list
8576 8576
 	*
8577 8577
 	*/
8578
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8578
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
8579 8579
 	{
8580 8580
 		global $globalDBdriver;
8581
-		$filter_query = $this->getFilter($filters,true,true);
8582
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8583
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8581
+		$filter_query = $this->getFilter($filters, true, true);
8582
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8583
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8584 8584
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
8585 8585
                     GROUP BY spotter_output.arrival_airport_country
8586 8586
 					ORDER BY airport_arrival_country_count DESC";
@@ -8592,7 +8592,7 @@  discard block
 block discarded – undo
8592 8592
 		$airport_array = array();
8593 8593
 		$temp_array = array();
8594 8594
         
8595
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8595
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8596 8596
 		{
8597 8597
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8598 8598
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8611,38 +8611,38 @@  discard block
 block discarded – undo
8611 8611
 	* @return Array the airport departure list
8612 8612
 	*
8613 8613
 	*/
8614
-	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8614
+	public function countAllDepartureCountries($filters = array(), $year = '', $month = '', $day = '')
8615 8615
 	{
8616 8616
 		global $globalDBdriver;
8617
-		$filter_query = $this->getFilter($filters,true,true);
8618
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8617
+		$filter_query = $this->getFilter($filters, true, true);
8618
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8619 8619
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
8620 8620
 		$query_values = array();
8621 8621
 		if ($year != '') {
8622 8622
 			if ($globalDBdriver == 'mysql') {
8623 8623
 				$query .= " AND YEAR(spotter_output.date) = :year";
8624
-				$query_values = array_merge($query_values,array(':year' => $year));
8624
+				$query_values = array_merge($query_values, array(':year' => $year));
8625 8625
 			} else {
8626 8626
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8627
-				$query_values = array_merge($query_values,array(':year' => $year));
8627
+				$query_values = array_merge($query_values, array(':year' => $year));
8628 8628
 			}
8629 8629
 		}
8630 8630
 		if ($month != '') {
8631 8631
 			if ($globalDBdriver == 'mysql') {
8632 8632
 				$query .= " AND MONTH(spotter_output.date) = :month";
8633
-				$query_values = array_merge($query_values,array(':month' => $month));
8633
+				$query_values = array_merge($query_values, array(':month' => $month));
8634 8634
 			} else {
8635 8635
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8636
-				$query_values = array_merge($query_values,array(':month' => $month));
8636
+				$query_values = array_merge($query_values, array(':month' => $month));
8637 8637
 			}
8638 8638
 		}
8639 8639
 		if ($day != '') {
8640 8640
 			if ($globalDBdriver == 'mysql') {
8641 8641
 				$query .= " AND DAY(spotter_output.date) = :day";
8642
-				$query_values = array_merge($query_values,array(':day' => $day));
8642
+				$query_values = array_merge($query_values, array(':day' => $day));
8643 8643
 			} else {
8644 8644
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8645
-				$query_values = array_merge($query_values,array(':day' => $day));
8645
+				$query_values = array_merge($query_values, array(':day' => $day));
8646 8646
 			}
8647 8647
 		}
8648 8648
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -8656,7 +8656,7 @@  discard block
 block discarded – undo
8656 8656
 		$airport_array = array();
8657 8657
 		$temp_array = array();
8658 8658
         
8659
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8659
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8660 8660
 		{
8661 8661
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
8662 8662
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -8674,38 +8674,38 @@  discard block
 block discarded – undo
8674 8674
 	* @return Array the airport arrival list
8675 8675
 	*
8676 8676
 	*/
8677
-	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8677
+	public function countAllArrivalCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
8678 8678
 	{
8679 8679
 		global $globalDBdriver;
8680
-		$filter_query = $this->getFilter($filters,true,true);
8681
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8680
+		$filter_query = $this->getFilter($filters, true, true);
8681
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8682 8682
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
8683 8683
 		$query_values = array();
8684 8684
 		if ($year != '') {
8685 8685
 			if ($globalDBdriver == 'mysql') {
8686 8686
 				$query .= " AND YEAR(spotter_output.date) = :year";
8687
-				$query_values = array_merge($query_values,array(':year' => $year));
8687
+				$query_values = array_merge($query_values, array(':year' => $year));
8688 8688
 			} else {
8689 8689
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8690
-				$query_values = array_merge($query_values,array(':year' => $year));
8690
+				$query_values = array_merge($query_values, array(':year' => $year));
8691 8691
 			}
8692 8692
 		}
8693 8693
 		if ($month != '') {
8694 8694
 			if ($globalDBdriver == 'mysql') {
8695 8695
 				$query .= " AND MONTH(spotter_output.date) = :month";
8696
-				$query_values = array_merge($query_values,array(':month' => $month));
8696
+				$query_values = array_merge($query_values, array(':month' => $month));
8697 8697
 			} else {
8698 8698
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8699
-				$query_values = array_merge($query_values,array(':month' => $month));
8699
+				$query_values = array_merge($query_values, array(':month' => $month));
8700 8700
 			}
8701 8701
 		}
8702 8702
 		if ($day != '') {
8703 8703
 			if ($globalDBdriver == 'mysql') {
8704 8704
 				$query .= " AND DAY(spotter_output.date) = :day";
8705
-				$query_values = array_merge($query_values,array(':day' => $day));
8705
+				$query_values = array_merge($query_values, array(':day' => $day));
8706 8706
 			} else {
8707 8707
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8708
-				$query_values = array_merge($query_values,array(':day' => $day));
8708
+				$query_values = array_merge($query_values, array(':day' => $day));
8709 8709
 			}
8710 8710
 		}
8711 8711
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -8719,7 +8719,7 @@  discard block
 block discarded – undo
8719 8719
 		$airport_array = array();
8720 8720
 		$temp_array = array();
8721 8721
         
8722
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8722
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8723 8723
 		{
8724 8724
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
8725 8725
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -8742,8 +8742,8 @@  discard block
 block discarded – undo
8742 8742
 	*/
8743 8743
 	public function countAllRoutes($filters = array())
8744 8744
 	{
8745
-		$filter_query = $this->getFilter($filters,true,true);
8746
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8745
+		$filter_query = $this->getFilter($filters, true, true);
8746
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8747 8747
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''
8748 8748
                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
8749 8749
                     ORDER BY route_count DESC
@@ -8756,7 +8756,7 @@  discard block
 block discarded – undo
8756 8756
 		$routes_array = array();
8757 8757
 		$temp_array = array();
8758 8758
         
8759
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8759
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8760 8760
 		{
8761 8761
 			$temp_array['route_count'] = $row['route_count'];
8762 8762
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8783,11 +8783,11 @@  discard block
 block discarded – undo
8783 8783
 	* @return Array the route list
8784 8784
 	*
8785 8785
 	*/
8786
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8786
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
8787 8787
 	{
8788
-		$filter_query = $this->getFilter($filters,true,true);
8789
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8790
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8788
+		$filter_query = $this->getFilter($filters, true, true);
8789
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8790
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8791 8791
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
8792 8792
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8793 8793
 			    ORDER BY route_count DESC";
@@ -8798,7 +8798,7 @@  discard block
 block discarded – undo
8798 8798
 		$routes_array = array();
8799 8799
 		$temp_array = array();
8800 8800
         
8801
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8801
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8802 8802
 		{
8803 8803
 			$temp_array['route_count'] = $row['route_count'];
8804 8804
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8825,9 +8825,9 @@  discard block
 block discarded – undo
8825 8825
 	*/
8826 8826
 	public function countAllRoutesByRegistration($registration, $filters = array())
8827 8827
 	{
8828
-		$filter_query = $this->getFilter($filters,true,true);
8828
+		$filter_query = $this->getFilter($filters, true, true);
8829 8829
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8830
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8830
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8831 8831
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
8832 8832
                     GROUP BY route
8833 8833
                     ORDER BY route_count DESC";
@@ -8839,7 +8839,7 @@  discard block
 block discarded – undo
8839 8839
 		$routes_array = array();
8840 8840
 		$temp_array = array();
8841 8841
         
8842
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8842
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8843 8843
 		{
8844 8844
 			$temp_array['route_count'] = $row['route_count'];
8845 8845
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8867,9 +8867,9 @@  discard block
 block discarded – undo
8867 8867
 	*/
8868 8868
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8869 8869
 	{
8870
-		$filter_query = $this->getFilter($filters,true,true);
8871
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8872
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8870
+		$filter_query = $this->getFilter($filters, true, true);
8871
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8872
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8873 8873
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
8874 8874
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8875 8875
 			    ORDER BY route_count DESC";
@@ -8881,7 +8881,7 @@  discard block
 block discarded – undo
8881 8881
 		$routes_array = array();
8882 8882
 		$temp_array = array();
8883 8883
         
8884
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8884
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8885 8885
 		{
8886 8886
 			$temp_array['route_count'] = $row['route_count'];
8887 8887
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8909,9 +8909,9 @@  discard block
 block discarded – undo
8909 8909
 	*/
8910 8910
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8911 8911
 	{
8912
-		$filter_query = $this->getFilter($filters,true,true);
8913
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8914
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8912
+		$filter_query = $this->getFilter($filters, true, true);
8913
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8914
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8915 8915
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8916 8916
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8917 8917
 			    ORDER BY route_count DESC";
@@ -8922,7 +8922,7 @@  discard block
 block discarded – undo
8922 8922
 		$routes_array = array();
8923 8923
 		$temp_array = array();
8924 8924
         
8925
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8925
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8926 8926
 		{
8927 8927
 			$temp_array['route_count'] = $row['route_count'];
8928 8928
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8950,9 +8950,9 @@  discard block
 block discarded – undo
8950 8950
 	*/
8951 8951
 	public function countAllRoutesByCountry($country, $filters = array())
8952 8952
 	{
8953
-		$filter_query = $this->getFilter($filters,true,true);
8954
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8955
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8953
+		$filter_query = $this->getFilter($filters, true, true);
8954
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8955
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8956 8956
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
8957 8957
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8958 8958
 			    ORDER BY route_count DESC";
@@ -8963,7 +8963,7 @@  discard block
 block discarded – undo
8963 8963
 		$routes_array = array();
8964 8964
 		$temp_array = array();
8965 8965
         
8966
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8966
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8967 8967
 		{
8968 8968
 			$temp_array['route_count'] = $row['route_count'];
8969 8969
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8991,8 +8991,8 @@  discard block
 block discarded – undo
8991 8991
 	public function countAllRoutesByDate($date, $filters = array())
8992 8992
 	{
8993 8993
 		global $globalTimezone, $globalDBdriver;
8994
-		$filter_query = $this->getFilter($filters,true,true);
8995
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8994
+		$filter_query = $this->getFilter($filters, true, true);
8995
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8996 8996
 		if ($globalTimezone != '') {
8997 8997
 			date_default_timezone_set($globalTimezone);
8998 8998
 			$datetime = new DateTime($date);
@@ -9000,12 +9000,12 @@  discard block
 block discarded – undo
9000 9000
 		} else $offset = '+00:00';
9001 9001
 		
9002 9002
 		if ($globalDBdriver == 'mysql') {
9003
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9003
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9004 9004
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
9005 9005
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9006 9006
 				    ORDER BY route_count DESC";
9007 9007
 		} else {
9008
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9008
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9009 9009
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
9010 9010
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9011 9011
 				    ORDER BY route_count DESC";
@@ -9017,7 +9017,7 @@  discard block
 block discarded – undo
9017 9017
 		$routes_array = array();
9018 9018
 		$temp_array = array();
9019 9019
         
9020
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9020
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9021 9021
 		{
9022 9022
 			$temp_array['route_count'] = $row['route_count'];
9023 9023
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9044,9 +9044,9 @@  discard block
 block discarded – undo
9044 9044
 	*/
9045 9045
 	public function countAllRoutesByIdent($ident, $filters = array())
9046 9046
 	{
9047
-		$filter_query = $this->getFilter($filters,true,true);
9048
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9049
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9047
+		$filter_query = $this->getFilter($filters, true, true);
9048
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9049
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9050 9050
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
9051 9051
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9052 9052
                     ORDER BY route_count DESC";
@@ -9058,7 +9058,7 @@  discard block
 block discarded – undo
9058 9058
 		$routes_array = array();
9059 9059
 		$temp_array = array();
9060 9060
         
9061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9062 9062
 		{
9063 9063
 			$temp_array['route_count'] = $row['route_count'];
9064 9064
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9082,11 +9082,11 @@  discard block
 block discarded – undo
9082 9082
 	* @return Array the route list
9083 9083
 	*
9084 9084
 	*/
9085
-	public function countAllRoutesByOwner($owner,$filters = array())
9085
+	public function countAllRoutesByOwner($owner, $filters = array())
9086 9086
 	{
9087
-		$filter_query = $this->getFilter($filters,true,true);
9088
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
9089
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9087
+		$filter_query = $this->getFilter($filters, true, true);
9088
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
9089
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9090 9090
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner 
9091 9091
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9092 9092
                     ORDER BY route_count DESC";
@@ -9098,7 +9098,7 @@  discard block
 block discarded – undo
9098 9098
 		$routes_array = array();
9099 9099
 		$temp_array = array();
9100 9100
         
9101
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9101
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9102 9102
 		{
9103 9103
 			$temp_array['route_count'] = $row['route_count'];
9104 9104
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9122,11 +9122,11 @@  discard block
 block discarded – undo
9122 9122
 	* @return Array the route list
9123 9123
 	*
9124 9124
 	*/
9125
-	public function countAllRoutesByPilot($pilot,$filters = array())
9125
+	public function countAllRoutesByPilot($pilot, $filters = array())
9126 9126
 	{
9127
-		$filter_query = $this->getFilter($filters,true,true);
9128
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
9129
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9127
+		$filter_query = $this->getFilter($filters, true, true);
9128
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
9129
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9130 9130
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
9131 9131
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9132 9132
                     ORDER BY route_count DESC";
@@ -9138,7 +9138,7 @@  discard block
 block discarded – undo
9138 9138
 		$routes_array = array();
9139 9139
 		$temp_array = array();
9140 9140
         
9141
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9141
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9142 9142
 		{
9143 9143
 			$temp_array['route_count'] = $row['route_count'];
9144 9144
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9165,9 +9165,9 @@  discard block
 block discarded – undo
9165 9165
 	*/
9166 9166
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9167 9167
 	{
9168
-		$filter_query = $this->getFilter($filters,true,true);
9169
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
9170
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9168
+		$filter_query = $this->getFilter($filters, true, true);
9169
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
9170
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9171 9171
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
9172 9172
                     GROUP BY route
9173 9173
                     ORDER BY route_count DESC";
@@ -9179,7 +9179,7 @@  discard block
 block discarded – undo
9179 9179
 		$routes_array = array();
9180 9180
 		$temp_array = array();
9181 9181
         
9182
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9182
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9183 9183
 		{
9184 9184
 			$temp_array['route_count'] = $row['route_count'];
9185 9185
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9207,8 +9207,8 @@  discard block
 block discarded – undo
9207 9207
 	*/
9208 9208
 	public function countAllRoutesWithWaypoints($filters = array())
9209 9209
 	{
9210
-		$filter_query = $this->getFilter($filters,true,true);
9211
-		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9210
+		$filter_query = $this->getFilter($filters, true, true);
9211
+		$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9212 9212
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
9213 9213
                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9214 9214
                     ORDER BY route_count DESC
@@ -9221,7 +9221,7 @@  discard block
 block discarded – undo
9221 9221
 		$routes_array = array();
9222 9222
 		$temp_array = array();
9223 9223
         
9224
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9224
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9225 9225
 		{
9226 9226
 			$temp_array['spotter_id'] = $row['spotter_id'];
9227 9227
 			$temp_array['route_count'] = $row['route_count'];
@@ -9246,11 +9246,11 @@  discard block
 block discarded – undo
9246 9246
 	* @return Array the callsign list
9247 9247
 	*
9248 9248
 	*/
9249
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9249
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
9250 9250
 	{
9251 9251
 		global $globalDBdriver;
9252
-		$filter_query = $this->getFilter($filters,true,true);
9253
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9252
+		$filter_query = $this->getFilter($filters, true, true);
9253
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9254 9254
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9255 9255
 		 if ($olderthanmonths > 0) {
9256 9256
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -9264,28 +9264,28 @@  discard block
 block discarded – undo
9264 9264
 		if ($year != '') {
9265 9265
 			if ($globalDBdriver == 'mysql') {
9266 9266
 				$query .= " AND YEAR(spotter_output.date) = :year";
9267
-				$query_values = array_merge($query_values,array(':year' => $year));
9267
+				$query_values = array_merge($query_values, array(':year' => $year));
9268 9268
 			} else {
9269 9269
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
9270
-				$query_values = array_merge($query_values,array(':year' => $year));
9270
+				$query_values = array_merge($query_values, array(':year' => $year));
9271 9271
 			}
9272 9272
 		}
9273 9273
 		if ($month != '') {
9274 9274
 			if ($globalDBdriver == 'mysql') {
9275 9275
 				$query .= " AND MONTH(spotter_output.date) = :month";
9276
-				$query_values = array_merge($query_values,array(':month' => $month));
9276
+				$query_values = array_merge($query_values, array(':month' => $month));
9277 9277
 			} else {
9278 9278
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
9279
-				$query_values = array_merge($query_values,array(':month' => $month));
9279
+				$query_values = array_merge($query_values, array(':month' => $month));
9280 9280
 			}
9281 9281
 		}
9282 9282
 		if ($day != '') {
9283 9283
 			if ($globalDBdriver == 'mysql') {
9284 9284
 				$query .= " AND DAY(spotter_output.date) = :day";
9285
-				$query_values = array_merge($query_values,array(':day' => $day));
9285
+				$query_values = array_merge($query_values, array(':day' => $day));
9286 9286
 			} else {
9287 9287
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
9288
-				$query_values = array_merge($query_values,array(':day' => $day));
9288
+				$query_values = array_merge($query_values, array(':day' => $day));
9289 9289
 			}
9290 9290
 		}
9291 9291
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
@@ -9297,7 +9297,7 @@  discard block
 block discarded – undo
9297 9297
 		$callsign_array = array();
9298 9298
 		$temp_array = array();
9299 9299
         
9300
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9300
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9301 9301
 		{
9302 9302
 			$temp_array['callsign_icao'] = $row['ident'];
9303 9303
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9319,8 +9319,8 @@  discard block
 block discarded – undo
9319 9319
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9320 9320
 	{
9321 9321
 		global $globalDBdriver;
9322
-		$filter_query = $this->getFilter($filters,true,true);
9323
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9322
+		$filter_query = $this->getFilter($filters, true, true);
9323
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9324 9324
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9325 9325
 		 if ($olderthanmonths > 0) {
9326 9326
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -9339,7 +9339,7 @@  discard block
 block discarded – undo
9339 9339
 		$callsign_array = array();
9340 9340
 		$temp_array = array();
9341 9341
         
9342
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9342
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9343 9343
 		{
9344 9344
 			$temp_array['callsign_icao'] = $row['ident'];
9345 9345
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9393,7 +9393,7 @@  discard block
 block discarded – undo
9393 9393
 		$date_array = array();
9394 9394
 		$temp_array = array();
9395 9395
         
9396
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9396
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9397 9397
 		{
9398 9398
 			$temp_array['date_name'] = $row['date_name'];
9399 9399
 			$temp_array['date_count'] = $row['date_count'];
@@ -9418,15 +9418,15 @@  discard block
 block discarded – undo
9418 9418
 			$datetime = new DateTime();
9419 9419
 			$offset = $datetime->format('P');
9420 9420
 		} else $offset = '+00:00';
9421
-		$filter_query = $this->getFilter($filters,true,true);
9421
+		$filter_query = $this->getFilter($filters, true, true);
9422 9422
 		if ($globalDBdriver == 'mysql') {
9423
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9423
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9424 9424
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9425 9425
 								GROUP BY spotter_output.airline_icao, date_name 
9426 9426
 								ORDER BY date_count DESC
9427 9427
 								LIMIT 10 OFFSET 0";
9428 9428
 		} else {
9429
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9429
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9430 9430
 								FROM spotter_output 
9431 9431
 								WHERE spotter_output.airline_icao <> '' 
9432 9432
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -9441,7 +9441,7 @@  discard block
 block discarded – undo
9441 9441
 		$date_array = array();
9442 9442
 		$temp_array = array();
9443 9443
         
9444
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9444
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9445 9445
 		{
9446 9446
 			$temp_array['date_name'] = $row['date_name'];
9447 9447
 			$temp_array['date_count'] = $row['date_count'];
@@ -9467,7 +9467,7 @@  discard block
 block discarded – undo
9467 9467
 			$datetime = new DateTime();
9468 9468
 			$offset = $datetime->format('P');
9469 9469
 		} else $offset = '+00:00';
9470
-		$filter_query = $this->getFilter($filters,true,true);
9470
+		$filter_query = $this->getFilter($filters, true, true);
9471 9471
 		if ($globalDBdriver == 'mysql') {
9472 9472
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9473 9473
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -9488,7 +9488,7 @@  discard block
 block discarded – undo
9488 9488
 		$date_array = array();
9489 9489
 		$temp_array = array();
9490 9490
         
9491
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9491
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9492 9492
 		{
9493 9493
 			$temp_array['date_name'] = $row['date_name'];
9494 9494
 			$temp_array['date_count'] = $row['date_count'];
@@ -9513,7 +9513,7 @@  discard block
 block discarded – undo
9513 9513
 			$datetime = new DateTime();
9514 9514
 			$offset = $datetime->format('P');
9515 9515
 		} else $offset = '+00:00';
9516
-		$filter_query = $this->getFilter($filters,true,true);
9516
+		$filter_query = $this->getFilter($filters, true, true);
9517 9517
 		if ($globalDBdriver == 'mysql') {
9518 9518
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9519 9519
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -9534,7 +9534,7 @@  discard block
 block discarded – undo
9534 9534
 		$date_array = array();
9535 9535
 		$temp_array = array();
9536 9536
         
9537
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9537
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9538 9538
 		{
9539 9539
 			$temp_array['date_name'] = $row['date_name'];
9540 9540
 			$temp_array['date_count'] = $row['date_count'];
@@ -9555,7 +9555,7 @@  discard block
 block discarded – undo
9555 9555
 	public function countAllDatesLastMonthByAirlines($filters = array())
9556 9556
 	{
9557 9557
 		global $globalTimezone, $globalDBdriver;
9558
-		$filter_query = $this->getFilter($filters,true,true);
9558
+		$filter_query = $this->getFilter($filters, true, true);
9559 9559
 		if ($globalTimezone != '') {
9560 9560
 			date_default_timezone_set($globalTimezone);
9561 9561
 			$datetime = new DateTime();
@@ -9563,13 +9563,13 @@  discard block
 block discarded – undo
9563 9563
 		} else $offset = '+00:00';
9564 9564
 		
9565 9565
 		if ($globalDBdriver == 'mysql') {
9566
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9566
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9567 9567
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
9568 9568
 								GROUP BY spotter_output.airline_icao, date_name 
9569 9569
 								ORDER BY spotter_output.date ASC";
9570 9570
 			$query_data = array(':offset' => $offset);
9571 9571
 		} else {
9572
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9572
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9573 9573
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY date_name ASC";
@@ -9582,7 +9582,7 @@  discard block
 block discarded – undo
9582 9582
 		$date_array = array();
9583 9583
 		$temp_array = array();
9584 9584
         
9585
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9585
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9586 9586
 		{
9587 9587
 			$temp_array['date_name'] = $row['date_name'];
9588 9588
 			$temp_array['date_count'] = $row['date_count'];
@@ -9629,7 +9629,7 @@  discard block
 block discarded – undo
9629 9629
 		$date_array = array();
9630 9630
 		$temp_array = array();
9631 9631
         
9632
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9632
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9633 9633
 		{
9634 9634
 			$temp_array['month_name'] = $row['month_name'];
9635 9635
 			$temp_array['year_name'] = $row['year_name'];
@@ -9650,7 +9650,7 @@  discard block
 block discarded – undo
9650 9650
 	public function countAllMonthsByAirlines($filters = array())
9651 9651
 	{
9652 9652
 		global $globalTimezone, $globalDBdriver;
9653
-		$filter_query = $this->getFilter($filters,true,true);
9653
+		$filter_query = $this->getFilter($filters, true, true);
9654 9654
 		if ($globalTimezone != '') {
9655 9655
 			date_default_timezone_set($globalTimezone);
9656 9656
 			$datetime = new DateTime();
@@ -9658,12 +9658,12 @@  discard block
 block discarded – undo
9658 9658
 		} else $offset = '+00:00';
9659 9659
 
9660 9660
 		if ($globalDBdriver == 'mysql') {
9661
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9661
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9662 9662
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9663 9663
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
9664 9664
 								ORDER BY date_count DESC";
9665 9665
 		} else {
9666
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9666
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9667 9667
 								FROM spotter_output 
9668 9668
 								WHERE spotter_output.airline_icao <> '' 
9669 9669
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -9677,7 +9677,7 @@  discard block
 block discarded – undo
9677 9677
 		$date_array = array();
9678 9678
 		$temp_array = array();
9679 9679
         
9680
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9680
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9681 9681
 		{
9682 9682
 			$temp_array['month_name'] = $row['month_name'];
9683 9683
 			$temp_array['year_name'] = $row['year_name'];
@@ -9704,14 +9704,14 @@  discard block
 block discarded – undo
9704 9704
 			$datetime = new DateTime();
9705 9705
 			$offset = $datetime->format('P');
9706 9706
 		} else $offset = '+00:00';
9707
-		$filter_query = $this->getFilter($filters,true,true);
9707
+		$filter_query = $this->getFilter($filters, true, true);
9708 9708
 		if ($globalDBdriver == 'mysql') {
9709
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9709
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9710 9710
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9711 9711
 								GROUP BY year_name, month_name 
9712 9712
 								ORDER BY date_count DESC";
9713 9713
 		} else {
9714
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9714
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9715 9715
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9716 9716
 								GROUP BY year_name, month_name 
9717 9717
 								ORDER BY date_count DESC";
@@ -9723,7 +9723,7 @@  discard block
 block discarded – undo
9723 9723
 		$date_array = array();
9724 9724
 		$temp_array = array();
9725 9725
         
9726
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9726
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9727 9727
 		{
9728 9728
 			$temp_array['month_name'] = $row['month_name'];
9729 9729
 			$temp_array['year_name'] = $row['year_name'];
@@ -9749,15 +9749,15 @@  discard block
 block discarded – undo
9749 9749
 			$datetime = new DateTime();
9750 9750
 			$offset = $datetime->format('P');
9751 9751
 		} else $offset = '+00:00';
9752
-		$filter_query = $this->getFilter($filters,true,true);
9752
+		$filter_query = $this->getFilter($filters, true, true);
9753 9753
 
9754 9754
 		if ($globalDBdriver == 'mysql') {
9755
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9755
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9756 9756
 								FROM spotter_output".$filter_query." owner_name <> ''
9757 9757
 								GROUP BY year_name, month_name
9758 9758
 								ORDER BY date_count DESC";
9759 9759
 		} else {
9760
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9760
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9761 9761
 								FROM spotter_output".$filter_query." owner_name <> ''
9762 9762
 								GROUP BY year_name, month_name
9763 9763
 								ORDER BY date_count DESC";
@@ -9769,7 +9769,7 @@  discard block
 block discarded – undo
9769 9769
 		$date_array = array();
9770 9770
 		$temp_array = array();
9771 9771
         
9772
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9772
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9773 9773
 		{
9774 9774
 			$temp_array['month_name'] = $row['month_name'];
9775 9775
 			$temp_array['year_name'] = $row['year_name'];
@@ -9790,7 +9790,7 @@  discard block
 block discarded – undo
9790 9790
 	public function countAllMonthsOwnersByAirlines($filters = array())
9791 9791
 	{
9792 9792
 		global $globalTimezone, $globalDBdriver;
9793
-		$filter_query = $this->getFilter($filters,true,true);
9793
+		$filter_query = $this->getFilter($filters, true, true);
9794 9794
 		if ($globalTimezone != '') {
9795 9795
 			date_default_timezone_set($globalTimezone);
9796 9796
 			$datetime = new DateTime();
@@ -9798,12 +9798,12 @@  discard block
 block discarded – undo
9798 9798
 		} else $offset = '+00:00';
9799 9799
 
9800 9800
 		if ($globalDBdriver == 'mysql') {
9801
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9801
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9802 9802
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9803 9803
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9804 9804
 								ORDER BY date_count DESC";
9805 9805
 		} else {
9806
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9806
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9807 9807
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9808 9808
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9809 9809
 								ORDER BY date_count DESC";
@@ -9815,7 +9815,7 @@  discard block
 block discarded – undo
9815 9815
 		$date_array = array();
9816 9816
 		$temp_array = array();
9817 9817
         
9818
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9818
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9819 9819
 		{
9820 9820
 			$temp_array['month_name'] = $row['month_name'];
9821 9821
 			$temp_array['year_name'] = $row['year_name'];
@@ -9842,15 +9842,15 @@  discard block
 block discarded – undo
9842 9842
 			$datetime = new DateTime();
9843 9843
 			$offset = $datetime->format('P');
9844 9844
 		} else $offset = '+00:00';
9845
-		$filter_query = $this->getFilter($filters,true,true);
9845
+		$filter_query = $this->getFilter($filters, true, true);
9846 9846
 
9847 9847
 		if ($globalDBdriver == 'mysql') {
9848
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9848
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9849 9849
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9850 9850
 								GROUP BY year_name, month_name
9851 9851
 								ORDER BY date_count DESC";
9852 9852
 		} else {
9853
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9853
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9854 9854
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9855 9855
 								GROUP BY year_name, month_name
9856 9856
 								ORDER BY date_count DESC";
@@ -9862,7 +9862,7 @@  discard block
 block discarded – undo
9862 9862
 		$date_array = array();
9863 9863
 		$temp_array = array();
9864 9864
         
9865
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9865
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9866 9866
 		{
9867 9867
 			$temp_array['month_name'] = $row['month_name'];
9868 9868
 			$temp_array['year_name'] = $row['year_name'];
@@ -9883,7 +9883,7 @@  discard block
 block discarded – undo
9883 9883
 	public function countAllMonthsPilotsByAirlines($filters = array())
9884 9884
 	{
9885 9885
 		global $globalTimezone, $globalDBdriver;
9886
-		$filter_query = $this->getFilter($filters,true,true);
9886
+		$filter_query = $this->getFilter($filters, true, true);
9887 9887
 		if ($globalTimezone != '') {
9888 9888
 			date_default_timezone_set($globalTimezone);
9889 9889
 			$datetime = new DateTime();
@@ -9891,12 +9891,12 @@  discard block
 block discarded – undo
9891 9891
 		} else $offset = '+00:00';
9892 9892
 
9893 9893
 		if ($globalDBdriver == 'mysql') {
9894
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9894
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9895 9895
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9896 9896
 								GROUP BY spotter_output.airline_icao,year_name, month_name
9897 9897
 								ORDER BY date_count DESC";
9898 9898
 		} else {
9899
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9899
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9900 9900
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9901 9901
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9902 9902
 								ORDER BY date_count DESC";
@@ -9908,7 +9908,7 @@  discard block
 block discarded – undo
9908 9908
 		$date_array = array();
9909 9909
 		$temp_array = array();
9910 9910
         
9911
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9911
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9912 9912
 		{
9913 9913
 			$temp_array['month_name'] = $row['month_name'];
9914 9914
 			$temp_array['year_name'] = $row['year_name'];
@@ -9930,7 +9930,7 @@  discard block
 block discarded – undo
9930 9930
 	public function countAllMonthsAirlines($filters = array())
9931 9931
 	{
9932 9932
 		global $globalTimezone, $globalDBdriver;
9933
-		$filter_query = $this->getFilter($filters,true,true);
9933
+		$filter_query = $this->getFilter($filters, true, true);
9934 9934
 		if ($globalTimezone != '') {
9935 9935
 			date_default_timezone_set($globalTimezone);
9936 9936
 			$datetime = new DateTime();
@@ -9938,12 +9938,12 @@  discard block
 block discarded – undo
9938 9938
 		} else $offset = '+00:00';
9939 9939
 
9940 9940
 		if ($globalDBdriver == 'mysql') {
9941
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
9941
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
9942 9942
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9943 9943
 								GROUP BY year_name, month_name
9944 9944
 								ORDER BY date_count DESC";
9945 9945
 		} else {
9946
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
9946
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
9947 9947
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9948 9948
 								GROUP BY year_name, month_name
9949 9949
 								ORDER BY date_count DESC";
@@ -9955,7 +9955,7 @@  discard block
 block discarded – undo
9955 9955
 		$date_array = array();
9956 9956
 		$temp_array = array();
9957 9957
         
9958
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9958
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9959 9959
 		{
9960 9960
 			$temp_array['month_name'] = $row['month_name'];
9961 9961
 			$temp_array['year_name'] = $row['year_name'];
@@ -9981,15 +9981,15 @@  discard block
 block discarded – undo
9981 9981
 			$datetime = new DateTime();
9982 9982
 			$offset = $datetime->format('P');
9983 9983
 		} else $offset = '+00:00';
9984
-		$filter_query = $this->getFilter($filters,true,true);
9984
+		$filter_query = $this->getFilter($filters, true, true);
9985 9985
 
9986 9986
 		if ($globalDBdriver == 'mysql') {
9987
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
9987
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
9988 9988
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9989 9989
 								GROUP BY year_name, month_name
9990 9990
 								ORDER BY date_count DESC";
9991 9991
 		} else {
9992
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
9992
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
9993 9993
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9994 9994
 								GROUP BY year_name, month_name
9995 9995
 								ORDER BY date_count DESC";
@@ -10001,7 +10001,7 @@  discard block
 block discarded – undo
10001 10001
 		$date_array = array();
10002 10002
 		$temp_array = array();
10003 10003
         
10004
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10004
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10005 10005
 		{
10006 10006
 			$temp_array['month_name'] = $row['month_name'];
10007 10007
 			$temp_array['year_name'] = $row['year_name'];
@@ -10023,7 +10023,7 @@  discard block
 block discarded – undo
10023 10023
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10024 10024
 	{
10025 10025
 		global $globalTimezone, $globalDBdriver;
10026
-		$filter_query = $this->getFilter($filters,true,true);
10026
+		$filter_query = $this->getFilter($filters, true, true);
10027 10027
 		if ($globalTimezone != '') {
10028 10028
 			date_default_timezone_set($globalTimezone);
10029 10029
 			$datetime = new DateTime();
@@ -10031,12 +10031,12 @@  discard block
 block discarded – undo
10031 10031
 		} else $offset = '+00:00';
10032 10032
 
10033 10033
 		if ($globalDBdriver == 'mysql') {
10034
-			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
10034
+			$query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
10035 10035
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
10036 10036
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10037 10037
 								ORDER BY date_count DESC";
10038 10038
 		} else {
10039
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
10039
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
10040 10040
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
10041 10041
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10042 10042
 								ORDER BY date_count DESC";
@@ -10048,7 +10048,7 @@  discard block
 block discarded – undo
10048 10048
 		$date_array = array();
10049 10049
 		$temp_array = array();
10050 10050
         
10051
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10051
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10052 10052
 		{
10053 10053
 			$temp_array['month_name'] = $row['month_name'];
10054 10054
 			$temp_array['year_name'] = $row['year_name'];
@@ -10075,15 +10075,15 @@  discard block
 block discarded – undo
10075 10075
 			$datetime = new DateTime();
10076 10076
 			$offset = $datetime->format('P');
10077 10077
 		} else $offset = '+00:00';
10078
-		$filter_query = $this->getFilter($filters,true,true);
10078
+		$filter_query = $this->getFilter($filters, true, true);
10079 10079
 
10080 10080
 		if ($globalDBdriver == 'mysql') {
10081
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10081
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10082 10082
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10083 10083
 								GROUP BY year_name, month_name
10084 10084
 								ORDER BY date_count DESC";
10085 10085
 		} else {
10086
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10086
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10087 10087
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10088 10088
 								GROUP BY year_name, month_name
10089 10089
 								ORDER BY date_count DESC";
@@ -10095,7 +10095,7 @@  discard block
 block discarded – undo
10095 10095
 		$date_array = array();
10096 10096
 		$temp_array = array();
10097 10097
         
10098
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10098
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10099 10099
 		{
10100 10100
 			$temp_array['month_name'] = $row['month_name'];
10101 10101
 			$temp_array['year_name'] = $row['year_name'];
@@ -10117,7 +10117,7 @@  discard block
 block discarded – undo
10117 10117
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10118 10118
 	{
10119 10119
 		global $globalTimezone, $globalDBdriver;
10120
-		$filter_query = $this->getFilter($filters,true,true);
10120
+		$filter_query = $this->getFilter($filters, true, true);
10121 10121
 		if ($globalTimezone != '') {
10122 10122
 			date_default_timezone_set($globalTimezone);
10123 10123
 			$datetime = new DateTime();
@@ -10125,12 +10125,12 @@  discard block
 block discarded – undo
10125 10125
 		} else $offset = '+00:00';
10126 10126
 
10127 10127
 		if ($globalDBdriver == 'mysql') {
10128
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10128
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10129 10129
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10130 10130
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10131 10131
 								ORDER BY date_count DESC";
10132 10132
 		} else {
10133
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10133
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10134 10134
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10135 10135
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10136 10136
 								ORDER BY date_count DESC";
@@ -10142,7 +10142,7 @@  discard block
 block discarded – undo
10142 10142
 		$date_array = array();
10143 10143
 		$temp_array = array();
10144 10144
         
10145
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10145
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10146 10146
 		{
10147 10147
 			$temp_array['month_name'] = $row['month_name'];
10148 10148
 			$temp_array['year_name'] = $row['year_name'];
@@ -10170,7 +10170,7 @@  discard block
 block discarded – undo
10170 10170
 			$datetime = new DateTime();
10171 10171
 			$offset = $datetime->format('P');
10172 10172
 		} else $offset = '+00:00';
10173
-		$filter_query = $this->getFilter($filters,true,true);
10173
+		$filter_query = $this->getFilter($filters, true, true);
10174 10174
 		if ($globalDBdriver == 'mysql') {
10175 10175
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
10176 10176
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -10191,7 +10191,7 @@  discard block
 block discarded – undo
10191 10191
 		$date_array = array();
10192 10192
 		$temp_array = array();
10193 10193
         
10194
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10194
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10195 10195
 		{
10196 10196
 			$temp_array['year_name'] = $row['year_name'];
10197 10197
 			$temp_array['month_name'] = $row['month_name'];
@@ -10211,7 +10211,7 @@  discard block
 block discarded – undo
10211 10211
 	* @return Array the hour list
10212 10212
 	*
10213 10213
 	*/
10214
-	public function countAllHours($orderby,$filters = array())
10214
+	public function countAllHours($orderby, $filters = array())
10215 10215
 	{
10216 10216
 		global $globalTimezone, $globalDBdriver;
10217 10217
 		if ($globalTimezone != '') {
@@ -10259,7 +10259,7 @@  discard block
 block discarded – undo
10259 10259
 		$hour_array = array();
10260 10260
 		$temp_array = array();
10261 10261
         
10262
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10262
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10263 10263
 		{
10264 10264
 			$temp_array['hour_name'] = $row['hour_name'];
10265 10265
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10279,7 +10279,7 @@  discard block
 block discarded – undo
10279 10279
 	public function countAllHoursByAirlines($orderby, $filters = array())
10280 10280
 	{
10281 10281
 		global $globalTimezone, $globalDBdriver;
10282
-		$filter_query = $this->getFilter($filters,true,true);
10282
+		$filter_query = $this->getFilter($filters, true, true);
10283 10283
 		if ($globalTimezone != '') {
10284 10284
 			date_default_timezone_set($globalTimezone);
10285 10285
 			$datetime = new DateTime();
@@ -10297,7 +10297,7 @@  discard block
 block discarded – undo
10297 10297
 		}
10298 10298
 		
10299 10299
 		if ($globalDBdriver == 'mysql') {
10300
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10300
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10301 10301
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10302 10302
 								GROUP BY spotter_output.airline_icao, hour_name 
10303 10303
 								".$orderby_sql;
@@ -10310,7 +10310,7 @@  discard block
 block discarded – undo
10310 10310
   */    
10311 10311
 		$query_data = array(':offset' => $offset);
10312 10312
 		} else {
10313
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10313
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10314 10314
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10315 10315
 								GROUP BY spotter_output.airline_icao, hour_name 
10316 10316
 								".$orderby_sql;
@@ -10323,7 +10323,7 @@  discard block
 block discarded – undo
10323 10323
 		$hour_array = array();
10324 10324
 		$temp_array = array();
10325 10325
         
10326
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10326
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10327 10327
 		{
10328 10328
 			$temp_array['hour_name'] = $row['hour_name'];
10329 10329
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10346,34 +10346,34 @@  discard block
 block discarded – undo
10346 10346
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10347 10347
 	{
10348 10348
 		global $globalTimezone, $globalDBdriver;
10349
-		$filter_query = $this->getFilter($filters,true,true);
10349
+		$filter_query = $this->getFilter($filters, true, true);
10350 10350
 		if ($globalTimezone != '') {
10351 10351
 			date_default_timezone_set($globalTimezone);
10352 10352
 			$datetime = new DateTime();
10353 10353
 			$offset = $datetime->format('P');
10354 10354
 		} else $offset = '+00:00';
10355 10355
 
10356
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10356
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
10357 10357
 
10358 10358
 		if ($globalDBdriver == 'mysql') {
10359
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10359
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10360 10360
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10361 10361
 								GROUP BY hour_name 
10362 10362
 								ORDER BY hour_name ASC";
10363 10363
 		} else {
10364
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10364
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10365 10365
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10366 10366
 								GROUP BY hour_name 
10367 10367
 								ORDER BY hour_name ASC";
10368 10368
 		}
10369 10369
 		
10370 10370
 		$sth = $this->db->prepare($query);
10371
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
10371
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
10372 10372
       
10373 10373
 		$hour_array = array();
10374 10374
 		$temp_array = array();
10375 10375
         
10376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10377 10377
 		{
10378 10378
 			$temp_array['hour_name'] = $row['hour_name'];
10379 10379
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10396,8 +10396,8 @@  discard block
 block discarded – undo
10396 10396
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10397 10397
 	{
10398 10398
 		global $globalTimezone, $globalDBdriver;
10399
-		$filter_query = $this->getFilter($filters,true,true);
10400
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
10399
+		$filter_query = $this->getFilter($filters, true, true);
10400
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
10401 10401
 		if ($globalTimezone != '') {
10402 10402
 			date_default_timezone_set($globalTimezone);
10403 10403
 			$datetime = new DateTime();
@@ -10405,24 +10405,24 @@  discard block
 block discarded – undo
10405 10405
 		} else $offset = '+00:00';
10406 10406
 
10407 10407
 		if ($globalDBdriver == 'mysql') {
10408
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10408
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10409 10409
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10410 10410
 								GROUP BY hour_name 
10411 10411
 								ORDER BY hour_name ASC";
10412 10412
 		} else {
10413
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10413
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10414 10414
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10415 10415
 								GROUP BY hour_name 
10416 10416
 								ORDER BY hour_name ASC";
10417 10417
 		}
10418 10418
 		
10419 10419
 		$sth = $this->db->prepare($query);
10420
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
10420
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
10421 10421
       
10422 10422
 		$hour_array = array();
10423 10423
 		$temp_array = array();
10424 10424
         
10425
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10425
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10426 10426
 		{
10427 10427
 			$temp_array['hour_name'] = $row['hour_name'];
10428 10428
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10443,8 +10443,8 @@  discard block
 block discarded – undo
10443 10443
 	public function countAllHoursByRegistration($registration, $filters = array())
10444 10444
 	{
10445 10445
 		global $globalTimezone, $globalDBdriver;
10446
-		$filter_query = $this->getFilter($filters,true,true);
10447
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
10446
+		$filter_query = $this->getFilter($filters, true, true);
10447
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
10448 10448
 		if ($globalTimezone != '') {
10449 10449
 			date_default_timezone_set($globalTimezone);
10450 10450
 			$datetime = new DateTime();
@@ -10452,24 +10452,24 @@  discard block
 block discarded – undo
10452 10452
 		} else $offset = '+00:00';
10453 10453
 
10454 10454
 		if ($globalDBdriver == 'mysql') {
10455
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10455
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10456 10456
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10457 10457
 								GROUP BY hour_name 
10458 10458
 								ORDER BY hour_name ASC";
10459 10459
 		} else {
10460
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10460
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10461 10461
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10462 10462
 								GROUP BY hour_name 
10463 10463
 								ORDER BY hour_name ASC";
10464 10464
 		}
10465 10465
 		
10466 10466
 		$sth = $this->db->prepare($query);
10467
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
10467
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
10468 10468
       
10469 10469
 		$hour_array = array();
10470 10470
 		$temp_array = array();
10471 10471
         
10472
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10472
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10473 10473
 		{
10474 10474
 			$temp_array['hour_name'] = $row['hour_name'];
10475 10475
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10490,8 +10490,8 @@  discard block
 block discarded – undo
10490 10490
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10491 10491
 	{
10492 10492
 		global $globalTimezone, $globalDBdriver;
10493
-		$filter_query = $this->getFilter($filters,true,true);
10494
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
10493
+		$filter_query = $this->getFilter($filters, true, true);
10494
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
10495 10495
 		if ($globalTimezone != '') {
10496 10496
 			date_default_timezone_set($globalTimezone);
10497 10497
 			$datetime = new DateTime();
@@ -10499,24 +10499,24 @@  discard block
 block discarded – undo
10499 10499
 		} else $offset = '+00:00';
10500 10500
 
10501 10501
 		if ($globalDBdriver == 'mysql') {
10502
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10502
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10503 10503
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10504 10504
 								GROUP BY hour_name 
10505 10505
 								ORDER BY hour_name ASC";
10506 10506
 		} else {
10507
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10507
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10508 10508
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10509 10509
 								GROUP BY hour_name 
10510 10510
 								ORDER BY hour_name ASC";
10511 10511
 		}
10512 10512
 		
10513 10513
 		$sth = $this->db->prepare($query);
10514
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
10514
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
10515 10515
       
10516 10516
 		$hour_array = array();
10517 10517
 		$temp_array = array();
10518 10518
         
10519
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10519
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10520 10520
 		{
10521 10521
 			$temp_array['hour_name'] = $row['hour_name'];
10522 10522
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10535,11 +10535,11 @@  discard block
 block discarded – undo
10535 10535
 	* @return Array the hour list
10536 10536
 	*
10537 10537
 	*/
10538
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10538
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
10539 10539
 	{
10540 10540
 		global $globalTimezone, $globalDBdriver;
10541
-		$filter_query = $this->getFilter($filters,true,true);
10542
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
10541
+		$filter_query = $this->getFilter($filters, true, true);
10542
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
10543 10543
 		if ($globalTimezone != '') {
10544 10544
 			date_default_timezone_set($globalTimezone);
10545 10545
 			$datetime = new DateTime();
@@ -10547,24 +10547,24 @@  discard block
 block discarded – undo
10547 10547
 		} else $offset = '+00:00';
10548 10548
 
10549 10549
 		if ($globalDBdriver == 'mysql') {
10550
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10550
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10551 10551
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10552 10552
 								GROUP BY hour_name 
10553 10553
 								ORDER BY hour_name ASC";
10554 10554
 		} else {
10555
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10555
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10556 10556
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10557 10557
 								GROUP BY hour_name 
10558 10558
 								ORDER BY hour_name ASC";
10559 10559
 		}
10560 10560
 		
10561 10561
 		$sth = $this->db->prepare($query);
10562
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
10562
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
10563 10563
       
10564 10564
 		$hour_array = array();
10565 10565
 		$temp_array = array();
10566 10566
         
10567
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10567
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10568 10568
 		{
10569 10569
 			$temp_array['hour_name'] = $row['hour_name'];
10570 10570
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10586,8 +10586,8 @@  discard block
 block discarded – undo
10586 10586
 	public function countAllHoursByDate($date, $filters = array())
10587 10587
 	{
10588 10588
 		global $globalTimezone, $globalDBdriver;
10589
-		$filter_query = $this->getFilter($filters,true,true);
10590
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
10589
+		$filter_query = $this->getFilter($filters, true, true);
10590
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
10591 10591
 		if ($globalTimezone != '') {
10592 10592
 			date_default_timezone_set($globalTimezone);
10593 10593
 			$datetime = new DateTime($date);
@@ -10595,12 +10595,12 @@  discard block
 block discarded – undo
10595 10595
 		} else $offset = '+00:00';
10596 10596
 
10597 10597
 		if ($globalDBdriver == 'mysql') {
10598
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10598
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10599 10599
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
10600 10600
 								GROUP BY hour_name 
10601 10601
 								ORDER BY hour_name ASC";
10602 10602
 		} else {
10603
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10603
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10604 10604
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
10605 10605
 								GROUP BY hour_name 
10606 10606
 								ORDER BY hour_name ASC";
@@ -10612,7 +10612,7 @@  discard block
 block discarded – undo
10612 10612
 		$hour_array = array();
10613 10613
 		$temp_array = array();
10614 10614
         
10615
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10615
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10616 10616
 		{
10617 10617
 			$temp_array['hour_name'] = $row['hour_name'];
10618 10618
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10634,8 +10634,8 @@  discard block
 block discarded – undo
10634 10634
 	public function countAllHoursByIdent($ident, $filters = array())
10635 10635
 	{
10636 10636
 		global $globalTimezone, $globalDBdriver;
10637
-		$filter_query = $this->getFilter($filters,true,true);
10638
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
10637
+		$filter_query = $this->getFilter($filters, true, true);
10638
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
10639 10639
 		if ($globalTimezone != '') {
10640 10640
 			date_default_timezone_set($globalTimezone);
10641 10641
 			$datetime = new DateTime();
@@ -10643,12 +10643,12 @@  discard block
 block discarded – undo
10643 10643
 		} else $offset = '+00:00';
10644 10644
 
10645 10645
 		if ($globalDBdriver == 'mysql') {
10646
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10646
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10647 10647
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10648 10648
 								GROUP BY hour_name 
10649 10649
 								ORDER BY hour_name ASC";
10650 10650
 		} else {
10651
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10651
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10652 10652
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10653 10653
 								GROUP BY hour_name 
10654 10654
 								ORDER BY hour_name ASC";
@@ -10656,12 +10656,12 @@  discard block
 block discarded – undo
10656 10656
       
10657 10657
 		
10658 10658
 		$sth = $this->db->prepare($query);
10659
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
10659
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
10660 10660
       
10661 10661
 		$hour_array = array();
10662 10662
 		$temp_array = array();
10663 10663
         
10664
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10664
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10665 10665
 		{
10666 10666
 			$temp_array['hour_name'] = $row['hour_name'];
10667 10667
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10681,8 +10681,8 @@  discard block
 block discarded – undo
10681 10681
 	public function countAllHoursByOwner($owner, $filters = array())
10682 10682
 	{
10683 10683
 		global $globalTimezone, $globalDBdriver;
10684
-		$filter_query = $this->getFilter($filters,true,true);
10685
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
10684
+		$filter_query = $this->getFilter($filters, true, true);
10685
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
10686 10686
 		if ($globalTimezone != '') {
10687 10687
 			date_default_timezone_set($globalTimezone);
10688 10688
 			$datetime = new DateTime();
@@ -10690,12 +10690,12 @@  discard block
 block discarded – undo
10690 10690
 		} else $offset = '+00:00';
10691 10691
 
10692 10692
 		if ($globalDBdriver == 'mysql') {
10693
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10693
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10694 10694
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10695 10695
 								GROUP BY hour_name 
10696 10696
 								ORDER BY hour_name ASC";
10697 10697
 		} else {
10698
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10698
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10699 10699
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10700 10700
 								GROUP BY hour_name 
10701 10701
 								ORDER BY hour_name ASC";
@@ -10703,12 +10703,12 @@  discard block
 block discarded – undo
10703 10703
       
10704 10704
 		
10705 10705
 		$sth = $this->db->prepare($query);
10706
-		$sth->execute(array(':owner' => $owner,':offset' => $offset));
10706
+		$sth->execute(array(':owner' => $owner, ':offset' => $offset));
10707 10707
       
10708 10708
 		$hour_array = array();
10709 10709
 		$temp_array = array();
10710 10710
         
10711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10712 10712
 		{
10713 10713
 			$temp_array['hour_name'] = $row['hour_name'];
10714 10714
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10728,8 +10728,8 @@  discard block
 block discarded – undo
10728 10728
 	public function countAllHoursByPilot($pilot, $filters = array())
10729 10729
 	{
10730 10730
 		global $globalTimezone, $globalDBdriver;
10731
-		$filter_query = $this->getFilter($filters,true,true);
10732
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
10731
+		$filter_query = $this->getFilter($filters, true, true);
10732
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
10733 10733
 		if ($globalTimezone != '') {
10734 10734
 			date_default_timezone_set($globalTimezone);
10735 10735
 			$datetime = new DateTime();
@@ -10737,12 +10737,12 @@  discard block
 block discarded – undo
10737 10737
 		} else $offset = '+00:00';
10738 10738
 
10739 10739
 		if ($globalDBdriver == 'mysql') {
10740
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10740
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10741 10741
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10742 10742
 								GROUP BY hour_name 
10743 10743
 								ORDER BY hour_name ASC";
10744 10744
 		} else {
10745
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10745
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10746 10746
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10747 10747
 								GROUP BY hour_name 
10748 10748
 								ORDER BY hour_name ASC";
@@ -10750,12 +10750,12 @@  discard block
 block discarded – undo
10750 10750
       
10751 10751
 		
10752 10752
 		$sth = $this->db->prepare($query);
10753
-		$sth->execute(array(':pilot' => $pilot,':offset' => $offset));
10753
+		$sth->execute(array(':pilot' => $pilot, ':offset' => $offset));
10754 10754
       
10755 10755
 		$hour_array = array();
10756 10756
 		$temp_array = array();
10757 10757
         
10758
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10758
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10759 10759
 		{
10760 10760
 			$temp_array['hour_name'] = $row['hour_name'];
10761 10761
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10774,12 +10774,12 @@  discard block
 block discarded – undo
10774 10774
 	* @return Array the hour list
10775 10775
 	*
10776 10776
 	*/
10777
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10777
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
10778 10778
 	{
10779 10779
 		global $globalTimezone, $globalDBdriver;
10780
-		$filter_query = $this->getFilter($filters,true,true);
10781
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
10782
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
10780
+		$filter_query = $this->getFilter($filters, true, true);
10781
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
10782
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
10783 10783
 		if ($globalTimezone != '') {
10784 10784
 			date_default_timezone_set($globalTimezone);
10785 10785
 			$datetime = new DateTime();
@@ -10787,24 +10787,24 @@  discard block
 block discarded – undo
10787 10787
 		} else $offset = '+00:00';
10788 10788
 
10789 10789
 		if ($globalDBdriver == 'mysql') {
10790
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10790
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10791 10791
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10792 10792
 								GROUP BY hour_name 
10793 10793
 								ORDER BY hour_name ASC";
10794 10794
 		} else {
10795
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10795
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10796 10796
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10797 10797
 								GROUP BY hour_name 
10798 10798
 								ORDER BY hour_name ASC";
10799 10799
 		}
10800 10800
 		
10801 10801
 		$sth = $this->db->prepare($query);
10802
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
10802
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
10803 10803
       
10804 10804
 		$hour_array = array();
10805 10805
 		$temp_array = array();
10806 10806
         
10807
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10807
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10808 10808
 		{
10809 10809
 			$temp_array['hour_name'] = $row['hour_name'];
10810 10810
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10825,8 +10825,8 @@  discard block
 block discarded – undo
10825 10825
 	public function countAllHoursByCountry($country, $filters = array())
10826 10826
 	{
10827 10827
 		global $globalTimezone, $globalDBdriver;
10828
-		$filter_query = $this->getFilter($filters,true,true);
10829
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
10828
+		$filter_query = $this->getFilter($filters, true, true);
10829
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
10830 10830
 		if ($globalTimezone != '') {
10831 10831
 			date_default_timezone_set($globalTimezone);
10832 10832
 			$datetime = new DateTime();
@@ -10834,24 +10834,24 @@  discard block
 block discarded – undo
10834 10834
 		} else $offset = '+00:00';
10835 10835
 
10836 10836
 		if ($globalDBdriver == 'mysql') {
10837
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10837
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10838 10838
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10839 10839
 								GROUP BY hour_name 
10840 10840
 								ORDER BY hour_name ASC";
10841 10841
 		} else {
10842
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10842
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10843 10843
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10844 10844
 								GROUP BY hour_name 
10845 10845
 								ORDER BY hour_name ASC";
10846 10846
 		}
10847 10847
 		
10848 10848
 		$sth = $this->db->prepare($query);
10849
-		$sth->execute(array(':country' => $country,':offset' => $offset));
10849
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
10850 10850
       
10851 10851
 		$hour_array = array();
10852 10852
 		$temp_array = array();
10853 10853
         
10854
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10854
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10855 10855
 		{
10856 10856
 			$temp_array['hour_name'] = $row['hour_name'];
10857 10857
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10871,29 +10871,29 @@  discard block
 block discarded – undo
10871 10871
 	* @return Integer the number of aircrafts
10872 10872
 	*
10873 10873
 	*/
10874
-	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10874
+	public function countOverallAircrafts($filters = array(), $year = '', $month = '')
10875 10875
 	{
10876 10876
 		global $globalDBdriver;
10877
-		$filter_query = $this->getFilter($filters,true,true);
10878
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10877
+		$filter_query = $this->getFilter($filters, true, true);
10878
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10879 10879
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
10880 10880
 		$query_values = array();
10881 10881
 		if ($year != '') {
10882 10882
 			if ($globalDBdriver == 'mysql') {
10883 10883
 				$query .= " AND YEAR(spotter_output.date) = :year";
10884
-				$query_values = array_merge($query_values,array(':year' => $year));
10884
+				$query_values = array_merge($query_values, array(':year' => $year));
10885 10885
 			} else {
10886 10886
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10887
-				$query_values = array_merge($query_values,array(':year' => $year));
10887
+				$query_values = array_merge($query_values, array(':year' => $year));
10888 10888
 			}
10889 10889
 		}
10890 10890
 		if ($month != '') {
10891 10891
 			if ($globalDBdriver == 'mysql') {
10892 10892
 				$query .= " AND MONTH(spotter_output.date) = :month";
10893
-				$query_values = array_merge($query_values,array(':month' => $month));
10893
+				$query_values = array_merge($query_values, array(':month' => $month));
10894 10894
 			} else {
10895 10895
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10896
-				$query_values = array_merge($query_values,array(':month' => $month));
10896
+				$query_values = array_merge($query_values, array(':month' => $month));
10897 10897
 			}
10898 10898
 		}
10899 10899
 
@@ -10908,29 +10908,29 @@  discard block
 block discarded – undo
10908 10908
 	* @return Integer the number of aircrafts
10909 10909
 	*
10910 10910
 	*/
10911
-	public function countOverallArrival($filters = array(),$year = '',$month = '')
10911
+	public function countOverallArrival($filters = array(), $year = '', $month = '')
10912 10912
 	{
10913 10913
 		global $globalDBdriver;
10914
-		$filter_query = $this->getFilter($filters,true,true);
10915
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10914
+		$filter_query = $this->getFilter($filters, true, true);
10915
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10916 10916
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
10917 10917
 		$query_values = array();
10918 10918
 		if ($year != '') {
10919 10919
 			if ($globalDBdriver == 'mysql') {
10920 10920
 				$query .= " AND YEAR(spotter_output.date) = :year";
10921
-				$query_values = array_merge($query_values,array(':year' => $year));
10921
+				$query_values = array_merge($query_values, array(':year' => $year));
10922 10922
 			} else {
10923 10923
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10924
-				$query_values = array_merge($query_values,array(':year' => $year));
10924
+				$query_values = array_merge($query_values, array(':year' => $year));
10925 10925
 			}
10926 10926
 		}
10927 10927
 		if ($month != '') {
10928 10928
 			if ($globalDBdriver == 'mysql') {
10929 10929
 				$query .= " AND MONTH(spotter_output.date) = :month";
10930
-				$query_values = array_merge($query_values,array(':month' => $month));
10930
+				$query_values = array_merge($query_values, array(':month' => $month));
10931 10931
 			} else {
10932 10932
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10933
-				$query_values = array_merge($query_values,array(':month' => $month));
10933
+				$query_values = array_merge($query_values, array(':month' => $month));
10934 10934
 			}
10935 10935
 		}
10936 10936
 		
@@ -10945,29 +10945,29 @@  discard block
 block discarded – undo
10945 10945
 	* @return Integer the number of pilots
10946 10946
 	*
10947 10947
 	*/
10948
-	public function countOverallPilots($filters = array(),$year = '',$month = '')
10948
+	public function countOverallPilots($filters = array(), $year = '', $month = '')
10949 10949
 	{
10950 10950
 		global $globalDBdriver;
10951
-		$filter_query = $this->getFilter($filters,true,true);
10952
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10951
+		$filter_query = $this->getFilter($filters, true, true);
10952
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10953 10953
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
10954 10954
 		$query_values = array();
10955 10955
 		if ($year != '') {
10956 10956
 			if ($globalDBdriver == 'mysql') {
10957 10957
 				$query .= " AND YEAR(spotter_output.date) = :year";
10958
-				$query_values = array_merge($query_values,array(':year' => $year));
10958
+				$query_values = array_merge($query_values, array(':year' => $year));
10959 10959
 			} else {
10960 10960
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10961
-				$query_values = array_merge($query_values,array(':year' => $year));
10961
+				$query_values = array_merge($query_values, array(':year' => $year));
10962 10962
 			}
10963 10963
 		}
10964 10964
 		if ($month != '') {
10965 10965
 			if ($globalDBdriver == 'mysql') {
10966 10966
 				$query .= " AND MONTH(spotter_output.date) = :month";
10967
-				$query_values = array_merge($query_values,array(':month' => $month));
10967
+				$query_values = array_merge($query_values, array(':month' => $month));
10968 10968
 			} else {
10969 10969
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10970
-				$query_values = array_merge($query_values,array(':month' => $month));
10970
+				$query_values = array_merge($query_values, array(':month' => $month));
10971 10971
 			}
10972 10972
 		}
10973 10973
 		$sth = $this->db->prepare($query);
@@ -10981,29 +10981,29 @@  discard block
 block discarded – undo
10981 10981
 	* @return Integer the number of owners
10982 10982
 	*
10983 10983
 	*/
10984
-	public function countOverallOwners($filters = array(),$year = '',$month = '')
10984
+	public function countOverallOwners($filters = array(), $year = '', $month = '')
10985 10985
 	{
10986 10986
 		global $globalDBdriver;
10987
-		$filter_query = $this->getFilter($filters,true,true);
10988
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10987
+		$filter_query = $this->getFilter($filters, true, true);
10988
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10989 10989
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
10990 10990
 		$query_values = array();
10991 10991
 		if ($year != '') {
10992 10992
 			if ($globalDBdriver == 'mysql') {
10993 10993
 				$query .= " AND YEAR(spotter_output.date) = :year";
10994
-				$query_values = array_merge($query_values,array(':year' => $year));
10994
+				$query_values = array_merge($query_values, array(':year' => $year));
10995 10995
 			} else {
10996 10996
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10997
-				$query_values = array_merge($query_values,array(':year' => $year));
10997
+				$query_values = array_merge($query_values, array(':year' => $year));
10998 10998
 			}
10999 10999
 		}
11000 11000
 		if ($month != '') {
11001 11001
 			if ($globalDBdriver == 'mysql') {
11002 11002
 				$query .= " AND MONTH(spotter_output.date) = :month";
11003
-				$query_values = array_merge($query_values,array(':month' => $month));
11003
+				$query_values = array_merge($query_values, array(':month' => $month));
11004 11004
 			} else {
11005 11005
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11006
-				$query_values = array_merge($query_values,array(':month' => $month));
11006
+				$query_values = array_merge($query_values, array(':month' => $month));
11007 11007
 			}
11008 11008
 		}
11009 11009
 		$sth = $this->db->prepare($query);
@@ -11018,32 +11018,32 @@  discard block
 block discarded – undo
11018 11018
 	* @return Integer the number of flights
11019 11019
 	*
11020 11020
 	*/
11021
-	public function countOverallFlights($filters = array(),$year = '',$month = '')
11021
+	public function countOverallFlights($filters = array(), $year = '', $month = '')
11022 11022
 	{
11023 11023
 		global $globalDBdriver;
11024
-		$queryi  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11024
+		$queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11025 11025
 		$query_values = array();
11026 11026
 		$query = '';
11027 11027
 		if ($year != '') {
11028 11028
 			if ($globalDBdriver == 'mysql') {
11029 11029
 				$query .= " AND YEAR(spotter_output.date) = :year";
11030
-				$query_values = array_merge($query_values,array(':year' => $year));
11030
+				$query_values = array_merge($query_values, array(':year' => $year));
11031 11031
 			} else {
11032 11032
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11033
-				$query_values = array_merge($query_values,array(':year' => $year));
11033
+				$query_values = array_merge($query_values, array(':year' => $year));
11034 11034
 			}
11035 11035
 		}
11036 11036
 		if ($month != '') {
11037 11037
 			if ($globalDBdriver == 'mysql') {
11038 11038
 				$query .= " AND MONTH(spotter_output.date) = :month";
11039
-				$query_values = array_merge($query_values,array(':month' => $month));
11039
+				$query_values = array_merge($query_values, array(':month' => $month));
11040 11040
 			} else {
11041 11041
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11042
-				$query_values = array_merge($query_values,array(':month' => $month));
11042
+				$query_values = array_merge($query_values, array(':month' => $month));
11043 11043
 			}
11044 11044
 		}
11045 11045
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11046
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11046
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11047 11047
 		
11048 11048
 		$sth = $this->db->prepare($queryi);
11049 11049
 		$sth->execute($query_values);
@@ -11056,29 +11056,29 @@  discard block
 block discarded – undo
11056 11056
 	* @return Integer the number of flights
11057 11057
 	*
11058 11058
 	*/
11059
-	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11059
+	public function countOverallMilitaryFlights($filters = array(), $year = '', $month = '')
11060 11060
 	{
11061 11061
 		global $globalDBdriver;
11062
-		$filter_query = $this->getFilter($filters,true,true);
11063
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11062
+		$filter_query = $this->getFilter($filters, true, true);
11063
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11064 11064
                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'";
11065 11065
 		$query_values = array();
11066 11066
 		if ($year != '') {
11067 11067
 			if ($globalDBdriver == 'mysql') {
11068 11068
 				$query .= " AND YEAR(spotter_output.date) = :year";
11069
-				$query_values = array_merge($query_values,array(':year' => $year));
11069
+				$query_values = array_merge($query_values, array(':year' => $year));
11070 11070
 			} else {
11071 11071
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11072
-				$query_values = array_merge($query_values,array(':year' => $year));
11072
+				$query_values = array_merge($query_values, array(':year' => $year));
11073 11073
 			}
11074 11074
 		}
11075 11075
 		if ($month != '') {
11076 11076
 			if ($globalDBdriver == 'mysql') {
11077 11077
 				$query .= " AND MONTH(spotter_output.date) = :month";
11078
-				$query_values = array_merge($query_values,array(':month' => $month));
11078
+				$query_values = array_merge($query_values, array(':month' => $month));
11079 11079
 			} else {
11080 11080
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11081
-				$query_values = array_merge($query_values,array(':month' => $month));
11081
+				$query_values = array_merge($query_values, array(':month' => $month));
11082 11082
 			}
11083 11083
 		}
11084 11084
       
@@ -11095,10 +11095,10 @@  discard block
 block discarded – undo
11095 11095
 	* @return Integer the number of airlines
11096 11096
 	*
11097 11097
 	*/
11098
-	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11098
+	public function countOverallAirlines($filters = array(), $year = '', $month = '')
11099 11099
 	{
11100 11100
 		global $globalDBdriver;
11101
-		$queryi  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11101
+		$queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11102 11102
 							FROM spotter_output";
11103 11103
       
11104 11104
 		$query_values = array();
@@ -11106,23 +11106,23 @@  discard block
 block discarded – undo
11106 11106
 		if ($year != '') {
11107 11107
 			if ($globalDBdriver == 'mysql') {
11108 11108
 				$query .= " AND YEAR(spotter_output.date) = :year";
11109
-				$query_values = array_merge($query_values,array(':year' => $year));
11109
+				$query_values = array_merge($query_values, array(':year' => $year));
11110 11110
 			} else {
11111 11111
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11112
-				$query_values = array_merge($query_values,array(':year' => $year));
11112
+				$query_values = array_merge($query_values, array(':year' => $year));
11113 11113
 			}
11114 11114
 		}
11115 11115
 		if ($month != '') {
11116 11116
 			if ($globalDBdriver == 'mysql') {
11117 11117
 				$query .= " AND MONTH(spotter_output.date) = :month";
11118
-				$query_values = array_merge($query_values,array(':month' => $month));
11118
+				$query_values = array_merge($query_values, array(':month' => $month));
11119 11119
 			} else {
11120 11120
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11121
-				$query_values = array_merge($query_values,array(':month' => $month));
11121
+				$query_values = array_merge($query_values, array(':month' => $month));
11122 11122
 			}
11123 11123
 		}
11124 11124
                 if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11125
+                else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11126 11126
 
11127 11127
 
11128 11128
 		$sth = $this->db->prepare($queryi);
@@ -11140,7 +11140,7 @@  discard block
 block discarded – undo
11140 11140
 	public function countAllHoursFromToday($filters = array())
11141 11141
 	{
11142 11142
 		global $globalTimezone, $globalDBdriver;
11143
-		$filter_query = $this->getFilter($filters,true,true);
11143
+		$filter_query = $this->getFilter($filters, true, true);
11144 11144
 		if ($globalTimezone != '') {
11145 11145
 			date_default_timezone_set($globalTimezone);
11146 11146
 			$datetime = new DateTime();
@@ -11148,12 +11148,12 @@  discard block
 block discarded – undo
11148 11148
 		} else $offset = '+00:00';
11149 11149
 
11150 11150
 		if ($globalDBdriver == 'mysql') {
11151
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11151
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11152 11152
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
11153 11153
 								GROUP BY hour_name 
11154 11154
 								ORDER BY hour_name ASC";
11155 11155
 		} else {
11156
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11156
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11157 11157
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
11158 11158
 								GROUP BY hour_name 
11159 11159
 								ORDER BY hour_name ASC";
@@ -11165,7 +11165,7 @@  discard block
 block discarded – undo
11165 11165
 		$hour_array = array();
11166 11166
 		$temp_array = array();
11167 11167
         
11168
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11168
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11169 11169
 		{
11170 11170
 			$temp_array['hour_name'] = $row['hour_name'];
11171 11171
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -11184,14 +11184,14 @@  discard block
 block discarded – undo
11184 11184
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11185 11185
 	{
11186 11186
 		global $global_query, $globalDBdriver, $globalTimezone;
11187
-		$filter_query = $this->getFilter($filters,true,true);
11187
+		$filter_query = $this->getFilter($filters, true, true);
11188 11188
 		date_default_timezone_set('UTC');
11189 11189
 		$limit_query = '';
11190 11190
 		if ($limit != "")
11191 11191
 		{
11192 11192
 			$limit_array = explode(",", $limit);
11193
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
11194
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
11193
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
11194
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
11195 11195
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
11196 11196
 			{
11197 11197
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -11244,7 +11244,7 @@  discard block
 block discarded – undo
11244 11244
 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH')
11245 11245
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
11246 11246
 			//echo $query;
11247
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
11247
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
11248 11248
 			/*
11249 11249
 			$sth = $this->db->prepare($query);
11250 11250
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -11263,9 +11263,9 @@  discard block
 block discarded – undo
11263 11263
 	*/
11264 11264
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11265 11265
 	{
11266
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
11266
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
11267 11267
 
11268
-		$query  = "SELECT spotter_output.spotter_id
11268
+		$query = "SELECT spotter_output.spotter_id
11269 11269
 								FROM spotter_output 
11270 11270
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
11271 11271
         
@@ -11273,7 +11273,7 @@  discard block
 block discarded – undo
11273 11273
 		$sth = $this->db->prepare($query);
11274 11274
 		$sth->execute();
11275 11275
 
11276
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11276
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11277 11277
 		{
11278 11278
 			return $row['spotter_id'];
11279 11279
 		}
@@ -11298,23 +11298,23 @@  discard block
 block discarded – undo
11298 11298
 		}
11299 11299
 		
11300 11300
 		$current_date = date("Y-m-d H:i:s");
11301
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
11301
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
11302 11302
 		
11303 11303
 		$diff = abs(strtotime($current_date) - strtotime($date));
11304 11304
 
11305
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
11305
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
11306 11306
 		$years = $time_array['years'];
11307 11307
 		
11308
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
11308
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
11309 11309
 		$months = $time_array['months'];
11310 11310
 		
11311
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
11311
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
11312 11312
 		$days = $time_array['days'];
11313
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
11313
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
11314 11314
 		$hours = $time_array['hours'];
11315
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
11315
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
11316 11316
 		$minutes = $time_array['minutes'];
11317
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11317
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11318 11318
 		
11319 11319
 		return $time_array;	
11320 11320
 	}	
@@ -11340,63 +11340,63 @@  discard block
 block discarded – undo
11340 11340
 			$temp_array['direction_degree'] = $direction;
11341 11341
 			$temp_array['direction_shortname'] = "N";
11342 11342
 			$temp_array['direction_fullname'] = "North";
11343
-		} elseif ($direction >= 22.5 && $direction < 45){
11343
+		} elseif ($direction >= 22.5 && $direction < 45) {
11344 11344
 			$temp_array['direction_degree'] = $direction;
11345 11345
 			$temp_array['direction_shortname'] = "NNE";
11346 11346
 			$temp_array['direction_fullname'] = "North-Northeast";
11347
-		} elseif ($direction >= 45 && $direction < 67.5){
11347
+		} elseif ($direction >= 45 && $direction < 67.5) {
11348 11348
 			$temp_array['direction_degree'] = $direction;
11349 11349
 			$temp_array['direction_shortname'] = "NE";
11350 11350
 			$temp_array['direction_fullname'] = "Northeast";
11351
-		} elseif ($direction >= 67.5 && $direction < 90){
11351
+		} elseif ($direction >= 67.5 && $direction < 90) {
11352 11352
 			$temp_array['direction_degree'] = $direction;
11353 11353
 			$temp_array['direction_shortname'] = "ENE";
11354 11354
 			$temp_array['direction_fullname'] = "East-Northeast";
11355
-		} elseif ($direction >= 90 && $direction < 112.5){
11355
+		} elseif ($direction >= 90 && $direction < 112.5) {
11356 11356
 			$temp_array['direction_degree'] = $direction;
11357 11357
 			$temp_array['direction_shortname'] = "E";
11358 11358
 			$temp_array['direction_fullname'] = "East";
11359
-		} elseif ($direction >= 112.5 && $direction < 135){
11359
+		} elseif ($direction >= 112.5 && $direction < 135) {
11360 11360
 			$temp_array['direction_degree'] = $direction;
11361 11361
 			$temp_array['direction_shortname'] = "ESE";
11362 11362
 			$temp_array['direction_fullname'] = "East-Southeast";
11363
-		} elseif ($direction >= 135 && $direction < 157.5){
11363
+		} elseif ($direction >= 135 && $direction < 157.5) {
11364 11364
 			$temp_array['direction_degree'] = $direction;
11365 11365
 			$temp_array['direction_shortname'] = "SE";
11366 11366
 			$temp_array['direction_fullname'] = "Southeast";
11367
-		} elseif ($direction >= 157.5 && $direction < 180){
11367
+		} elseif ($direction >= 157.5 && $direction < 180) {
11368 11368
 			$temp_array['direction_degree'] = $direction;
11369 11369
 			$temp_array['direction_shortname'] = "SSE";
11370 11370
 			$temp_array['direction_fullname'] = "South-Southeast";
11371
-		} elseif ($direction >= 180 && $direction < 202.5){
11371
+		} elseif ($direction >= 180 && $direction < 202.5) {
11372 11372
 			$temp_array['direction_degree'] = $direction;
11373 11373
 			$temp_array['direction_shortname'] = "S";
11374 11374
 			$temp_array['direction_fullname'] = "South";
11375
-		} elseif ($direction >= 202.5 && $direction < 225){
11375
+		} elseif ($direction >= 202.5 && $direction < 225) {
11376 11376
 			$temp_array['direction_degree'] = $direction;
11377 11377
 			$temp_array['direction_shortname'] = "SSW";
11378 11378
 			$temp_array['direction_fullname'] = "South-Southwest";
11379
-		} elseif ($direction >= 225 && $direction < 247.5){
11379
+		} elseif ($direction >= 225 && $direction < 247.5) {
11380 11380
 			$temp_array['direction_degree'] = $direction;
11381 11381
 			$temp_array['direction_shortname'] = "SW";
11382 11382
 			$temp_array['direction_fullname'] = "Southwest";
11383
-		} elseif ($direction >= 247.5 && $direction < 270){
11383
+		} elseif ($direction >= 247.5 && $direction < 270) {
11384 11384
 			$temp_array['direction_degree'] = $direction;
11385 11385
 			$temp_array['direction_shortname'] = "WSW";
11386 11386
 			$temp_array['direction_fullname'] = "West-Southwest";
11387
-		} elseif ($direction >= 270 && $direction < 292.5){
11387
+		} elseif ($direction >= 270 && $direction < 292.5) {
11388 11388
 			$temp_array['direction_degree'] = $direction;
11389 11389
 			$temp_array['direction_shortname'] = "W";
11390 11390
 			$temp_array['direction_fullname'] = "West";
11391
-		} elseif ($direction >= 292.5 && $direction < 315){
11391
+		} elseif ($direction >= 292.5 && $direction < 315) {
11392 11392
 			$temp_array['direction_degree'] = $direction;
11393 11393
 			$temp_array['direction_shortname'] = "WNW";
11394 11394
 			$temp_array['direction_fullname'] = "West-Northwest";
11395
-		} elseif ($direction >= 315 && $direction < 337.5){
11395
+		} elseif ($direction >= 315 && $direction < 337.5) {
11396 11396
 			$temp_array['direction_degree'] = $direction;
11397 11397
 			$temp_array['direction_shortname'] = "NW";
11398 11398
 			$temp_array['direction_fullname'] = "Northwest";
11399
-		} elseif ($direction >= 337.5 && $direction < 360){
11399
+		} elseif ($direction >= 337.5 && $direction < 360) {
11400 11400
 			$temp_array['direction_degree'] = $direction;
11401 11401
 			$temp_array['direction_shortname'] = "NNW";
11402 11402
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -11449,8 +11449,8 @@  discard block
 block discarded – undo
11449 11449
 	*/
11450 11450
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11451 11451
 	{
11452
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11453
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11452
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11453
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11454 11454
 		if ($source_type == '' || $source_type == 'modes') {
11455 11455
 			$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11456 11456
 		} else {
@@ -11477,10 +11477,10 @@  discard block
 block discarded – undo
11477 11477
 	* @return String the aircraft type
11478 11478
 	*
11479 11479
 	*/
11480
-	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11480
+	public function getAircraftTypeBymodeS($aircraft_modes, $source_type = '')
11481 11481
 	{
11482
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11483
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11482
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11483
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11484 11484
 		if ($source_type == '' || $source_type == 'modes') {
11485 11485
 			$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11486 11486
 		} else {
@@ -11508,11 +11508,11 @@  discard block
 block discarded – undo
11508 11508
 	* @param Float $longitude longitute of the flight
11509 11509
 	* @return String the countrie
11510 11510
 	*/
11511
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11511
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
11512 11512
 	{
11513 11513
 		global $globalDBdriver, $globalDebug;
11514
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11515
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11514
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11515
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11516 11516
 	
11517 11517
 		$Connection = new Connection($this->db);
11518 11518
 		if (!$Connection->tableExists('countries')) return '';
@@ -11552,7 +11552,7 @@  discard block
 block discarded – undo
11552 11552
 	public function getCountryFromISO2($iso2)
11553 11553
 	{
11554 11554
 		global $globalDBdriver, $globalDebug;
11555
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11555
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
11556 11556
 	
11557 11557
 		$Connection = new Connection($this->db);
11558 11558
 		if (!$Connection->tableExists('countries')) return '';
@@ -11584,19 +11584,19 @@  discard block
 block discarded – undo
11584 11584
 	*/
11585 11585
 	public function convertAircraftRegistration($registration)
11586 11586
 	{
11587
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11587
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11588 11588
 		$registration_prefix = '';
11589 11589
 		$registration_1 = substr($registration, 0, 1);
11590 11590
 		$registration_2 = substr($registration, 0, 2);
11591 11591
 
11592 11592
 		//first get the prefix based on two characters
11593
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11593
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11594 11594
       
11595 11595
 		
11596 11596
 		$sth = $this->db->prepare($query);
11597 11597
 		$sth->execute(array(':registration_2' => $registration_2));
11598 11598
         
11599
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11599
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11600 11600
 		{
11601 11601
 			$registration_prefix = $row['registration_prefix'];
11602 11602
 		}
@@ -11604,11 +11604,11 @@  discard block
 block discarded – undo
11604 11604
 		//if we didn't find a two chracter prefix lets just search the one with one character
11605 11605
 		if ($registration_prefix == '')
11606 11606
 		{
11607
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11607
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11608 11608
 			$sth = $this->db->prepare($query);
11609 11609
 			$sth->execute(array(':registration_1' => $registration_1));
11610 11610
 	        
11611
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11611
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11612 11612
 			{
11613 11613
 				$registration_prefix = $row['registration_prefix'];
11614 11614
 			}
@@ -11622,7 +11622,7 @@  discard block
 block discarded – undo
11622 11622
 			} else {
11623 11623
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
11624 11624
 			}
11625
-		} else if(strlen($registration_prefix) == 2){
11625
+		} else if (strlen($registration_prefix) == 2) {
11626 11626
 			if (0 === strpos($registration, 'N')) {
11627 11627
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
11628 11628
 			} else {
@@ -11641,17 +11641,17 @@  discard block
 block discarded – undo
11641 11641
 	*/
11642 11642
 	public function countryFromAircraftRegistration($registration)
11643 11643
 	{
11644
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11644
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11645 11645
 		
11646 11646
 		$registration_prefix = '';
11647
-		$registration_test = explode('-',$registration);
11647
+		$registration_test = explode('-', $registration);
11648 11648
 		$country = '';
11649 11649
 		if ($registration_test[0] != $registration) {
11650 11650
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11651 11651
 	      
11652 11652
 			$sth = $this->db->prepare($query);
11653 11653
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11654
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11654
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11655 11655
 			{
11656 11656
 				//$registration_prefix = $row['registration_prefix'];
11657 11657
 				$country = $row['country'];
@@ -11662,13 +11662,13 @@  discard block
 block discarded – undo
11662 11662
 
11663 11663
 			$country = '';
11664 11664
 			//first get the prefix based on two characters
11665
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11665
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11666 11666
       
11667 11667
 			
11668 11668
 			$sth = $this->db->prepare($query);
11669 11669
 			$sth->execute(array(':registration_2' => $registration_2));
11670 11670
         
11671
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11671
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11672 11672
 			{
11673 11673
 				$registration_prefix = $row['registration_prefix'];
11674 11674
 				$country = $row['country'];
@@ -11677,12 +11677,12 @@  discard block
 block discarded – undo
11677 11677
 			//if we didn't find a two chracter prefix lets just search the one with one character
11678 11678
 			if ($registration_prefix == "")
11679 11679
 			{
11680
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11680
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11681 11681
 	      
11682 11682
 				$sth = $this->db->prepare($query);
11683 11683
 				$sth->execute(array(':registration_1' => $registration_1));
11684 11684
 	        
11685
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11685
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11686 11686
 				{
11687 11687
 					//$registration_prefix = $row['registration_prefix'];
11688 11688
 					$country = $row['country'];
@@ -11702,17 +11702,17 @@  discard block
 block discarded – undo
11702 11702
 	*/
11703 11703
 	public function registrationPrefixFromAircraftRegistration($registration)
11704 11704
 	{
11705
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11705
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11706 11706
 		
11707 11707
 		$registration_prefix = '';
11708
-		$registration_test = explode('-',$registration);
11708
+		$registration_test = explode('-', $registration);
11709 11709
 		//$country = '';
11710 11710
 		if ($registration_test[0] != $registration) {
11711
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11711
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11712 11712
 	      
11713 11713
 			$sth = $this->db->prepare($query);
11714 11714
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11715
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11715
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11716 11716
 			{
11717 11717
 				$registration_prefix = $row['registration_prefix'];
11718 11718
 				//$country = $row['country'];
@@ -11722,13 +11722,13 @@  discard block
 block discarded – undo
11722 11722
 		        $registration_2 = substr($registration, 0, 2);
11723 11723
 
11724 11724
 			//first get the prefix based on two characters
11725
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11725
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11726 11726
       
11727 11727
 			
11728 11728
 			$sth = $this->db->prepare($query);
11729 11729
 			$sth->execute(array(':registration_2' => $registration_2));
11730 11730
         
11731
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11731
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11732 11732
 			{
11733 11733
 				$registration_prefix = $row['registration_prefix'];
11734 11734
 				//$country = $row['country'];
@@ -11737,12 +11737,12 @@  discard block
 block discarded – undo
11737 11737
 			//if we didn't find a two chracter prefix lets just search the one with one character
11738 11738
 			if ($registration_prefix == "")
11739 11739
 			{
11740
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11740
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11741 11741
 	      
11742 11742
 				$sth = $this->db->prepare($query);
11743 11743
 				$sth->execute(array(':registration_1' => $registration_1));
11744 11744
 	        
11745
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11745
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11746 11746
 				{
11747 11747
 					$registration_prefix = $row['registration_prefix'];
11748 11748
 					//$country = $row['country'];
@@ -11763,13 +11763,13 @@  discard block
 block discarded – undo
11763 11763
 	*/
11764 11764
 	public function countryFromAircraftRegistrationCode($registration)
11765 11765
 	{
11766
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11766
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11767 11767
 		
11768 11768
 		$country = '';
11769
-		$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11769
+		$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11770 11770
 		$sth = $this->db->prepare($query);
11771 11771
 		$sth->execute(array(':registration' => $registration));
11772
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11772
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11773 11773
 		{
11774 11774
 			$country = $row['country'];
11775 11775
 		}
@@ -11782,9 +11782,9 @@  discard block
 block discarded – undo
11782 11782
 	* @param String $flightaware_id flightaware_id from spotter_output table
11783 11783
 	* @param String $highlight New highlight value
11784 11784
 	*/
11785
-	public function setHighlightFlight($flightaware_id,$highlight) {
11785
+	public function setHighlightFlight($flightaware_id, $highlight) {
11786 11786
 		
11787
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11787
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11788 11788
 		$sth = $this->db->prepare($query);
11789 11789
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
11790 11790
 	}
@@ -11796,13 +11796,13 @@  discard block
 block discarded – undo
11796 11796
 	* @param String $date Date of spotted aircraft
11797 11797
 	* @param String $highlight New highlight value
11798 11798
 	*/
11799
-	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11799
+	public function setHighlightFlightByRegistration($registration, $highlight, $date = '') {
11800 11800
 		if ($date == '') {
11801 11801
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
11802 11802
 			$query_values = array(':registration' => $registration, ':highlight' => $highlight);
11803 11803
 		} else {
11804 11804
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date";
11805
-			$query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date);
11805
+			$query_values = array(':registration' => $registration, ':highlight' => $highlight, ':date' => $date);
11806 11806
 		}
11807 11807
 		$sth = $this->db->prepare($query);
11808 11808
 		$sth->execute($query_values);
@@ -11832,7 +11832,7 @@  discard block
 block discarded – undo
11832 11832
 		
11833 11833
 		$bitly_data = json_decode($bitly_data);
11834 11834
 		$bitly_url = '';
11835
-		if ($bitly_data->status_txt = "OK"){
11835
+		if ($bitly_data->status_txt = "OK") {
11836 11836
 			$bitly_url = $bitly_data->data->url;
11837 11837
 		}
11838 11838
 
@@ -11842,7 +11842,7 @@  discard block
 block discarded – undo
11842 11842
 
11843 11843
 	public function getOrderBy()
11844 11844
 	{
11845
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
11845
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
11846 11846
 		
11847 11847
 		return $orderby;
11848 11848
 		
@@ -11976,14 +11976,14 @@  discard block
 block discarded – undo
11976 11976
 		}
11977 11977
 		$sth = $this->db->prepare($query);
11978 11978
 		$sth->execute();
11979
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11979
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11980 11980
 		{
11981 11981
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
11982 11982
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
11983 11983
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
11984
-				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
11984
+				$update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
11985 11985
 				$sthu = $this->db->prepare($update_query);
11986
-				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country']));
11986
+				$sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country']));
11987 11987
 			}
11988 11988
 		}
11989 11989
 		
@@ -11996,7 +11996,7 @@  discard block
 block discarded – undo
11996 11996
 		}
11997 11997
 		$sth = $this->db->prepare($query);
11998 11998
 		$sth->execute();
11999
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11999
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12000 12000
 		{
12001 12001
 			if (is_numeric(substr($row['ident'], -1, 1)))
12002 12002
 			{
@@ -12005,11 +12005,11 @@  discard block
 block discarded – undo
12005 12005
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12006 12006
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12007 12007
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12008
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12008
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
12009 12009
 				if (isset($airline_array[0]['name'])) {
12010
-					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
12010
+					$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
12011 12011
 					$sthu = $this->db->prepare($update_query);
12012
-					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
12012
+					$sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
12013 12013
 				}
12014 12014
 			}
12015 12015
 		}
@@ -12029,18 +12029,18 @@  discard block
 block discarded – undo
12029 12029
 		}
12030 12030
 		$sth = $this->db->prepare($query);
12031 12031
 		$sth->execute();
12032
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12032
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12033 12033
 		{
12034 12034
 			if ($row['aircraft_icao'] != '') {
12035 12035
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
12036
-				if ($row['registration'] != ""){
12036
+				if ($row['registration'] != "") {
12037 12037
 					$image_array = $Image->getSpotterImage($row['registration']);
12038 12038
 					if (!isset($image_array[0]['registration'])) {
12039 12039
 						$Image->addSpotterImage($row['registration']);
12040 12040
 					}
12041 12041
 				}
12042 12042
 				if (count($aircraft_name) > 0) {
12043
-					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
12043
+					$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
12044 12044
 					$sthu = $this->db->prepare($update_query);
12045 12045
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
12046 12046
 				}
@@ -12055,10 +12055,10 @@  discard block
 block discarded – undo
12055 12055
 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output";
12056 12056
 		$sth = $this->db->prepare($query);
12057 12057
 		$sth->execute();
12058
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12058
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12059 12059
 		{
12060 12060
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
12061
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
12061
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
12062 12062
 				$airport_icao = '';
12063 12063
 				 if (isset($closestAirports[0])) {
12064 12064
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -12072,7 +12072,7 @@  discard block
 block discarded – undo
12072 12072
 								break;
12073 12073
 							}
12074 12074
 						}
12075
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12075
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
12076 12076
 						$airport_icao = $closestAirports[0]['icao'];
12077 12077
 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12078 12078
 					} else {
@@ -12083,28 +12083,28 @@  discard block
 block discarded – undo
12083 12083
 				}
12084 12084
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12085 12085
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12086
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12086
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12087 12087
 					$sthu = $this->db->prepare($update_query);
12088
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
12088
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
12089 12089
 				}
12090 12090
 			}
12091 12091
 		}
12092 12092
 	}
12093 12093
 	
12094
-	public function closestAirports($origLat,$origLon,$dist = 10) {
12094
+	public function closestAirports($origLat, $origLon, $dist = 10) {
12095 12095
 		global $globalDBdriver;
12096
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
12096
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
12097 12097
 /*
12098 12098
 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12099 12099
                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12100 12100
                       having distance < $dist ORDER BY distance limit 100;";
12101 12101
 */
12102 12102
 		if ($globalDBdriver == 'mysql') {
12103
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12103
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12104 12104
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12105 12105
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12106 12106
                 } else {
12107
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
12107
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
12108 12108
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12109 12109
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12110 12110
     		}
Please login to merge, or discard this patch.
Braces   +735 added lines, -257 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
 		if (isset($filter[0]['source'])) {
73 73
 			$filters = array_merge($filters,$filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) {
76
+			$filter = array_merge($filter,$globalFilter);
77
+		}
76 78
 		$filter_query_join = '';
77 79
 		$filter_query_where = '';
78 80
 		foreach($filters as $flt) {
@@ -156,8 +158,11 @@  discard block
 block discarded – undo
156 158
 				$filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
157 159
 			}
158 160
 		}
159
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161
+		if ($filter_query_where == '' && $where) {
162
+			$filter_query_where = ' WHERE';
163
+		} elseif ($filter_query_where != '' && $and) {
164
+			$filter_query_where .= ' AND';
165
+		}
161 166
 		if ($filter_query_where != '') {
162 167
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
163 168
 		}
@@ -180,10 +185,18 @@  discard block
 block discarded – undo
180 185
 		$Image = new Image($this->db);
181 186
 		$Schedule = new Schedule($this->db);
182 187
 		$ACARS = new ACARS($this->db);
183
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
184
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
185
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
186
-		if (!isset($globalVAM)) $globalVAM = FALSE;
188
+		if (!isset($globalIVAO)) {
189
+			$globalIVAO = FALSE;
190
+		}
191
+		if (!isset($globalVATSIM)) {
192
+			$globalVATSIM = FALSE;
193
+		}
194
+		if (!isset($globalphpVMS)) {
195
+			$globalphpVMS = FALSE;
196
+		}
197
+		if (!isset($globalVAM)) {
198
+			$globalVAM = FALSE;
199
+		}
187 200
 		date_default_timezone_set('UTC');
188 201
 		
189 202
 		if (!is_string($query))
@@ -230,21 +243,35 @@  discard block
 block discarded – undo
230 243
 			} else {
231 244
 				$temp_array['spotter_id'] = '';
232 245
 			}
233
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
234
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
246
+			if (isset($row['flightaware_id'])) {
247
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
248
+			}
249
+			if (isset($row['modes'])) {
250
+				$temp_array['modes'] = $row['modes'];
251
+			}
235 252
 			$temp_array['ident'] = $row['ident'];
236 253
 			if (isset($row['registration']) && $row['registration'] != '') {
237 254
 				$temp_array['registration'] = $row['registration'];
238 255
 			} elseif (isset($temp_array['modes'])) {
239 256
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
240
-			} else $temp_array['registration'] = '';
241
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
257
+			} else {
258
+				$temp_array['registration'] = '';
259
+			}
260
+			if (isset($row['aircraft_icao'])) {
261
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
262
+			}
242 263
 			
243 264
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
244 265
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
245
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
246
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
247
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
266
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
267
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
268
+			}
269
+			if (isset($row['latitude'])) {
270
+				$temp_array['latitude'] = $row['latitude'];
271
+			}
272
+			if (isset($row['longitude'])) {
273
+				$temp_array['longitude'] = $row['longitude'];
274
+			}
248 275
 			/*
249 276
 			if (Connection->tableExists('countries')) {
250 277
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -254,8 +281,12 @@  discard block
 block discarded – undo
254 281
 				}
255 282
 			}
256 283
 			*/
257
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
258
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
284
+			if (isset($row['waypoints'])) {
285
+				$temp_array['waypoints'] = $row['waypoints'];
286
+			}
287
+			if (isset($row['format_source'])) {
288
+				$temp_array['format_source'] = $row['format_source'];
289
+			}
259 290
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 291
 				$temp_array['route_stop'] = $row['route_stop'];
261 292
 				$allroute = explode(' ',$row['route_stop']);
@@ -271,13 +302,19 @@  discard block
 block discarded – undo
271 302
 					}
272 303
 				}
273 304
 			}
274
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
305
+			if (isset($row['altitude'])) {
306
+				$temp_array['altitude'] = $row['altitude'];
307
+			}
275 308
 			if (isset($row['heading'])) {
276 309
 				$temp_array['heading'] = $row['heading'];
277 310
 				$heading_direction = $this->parseDirection($row['heading']);
278
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
311
+				if (isset($heading_direction[0]['direction_fullname'])) {
312
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
313
+				}
314
+			}
315
+			if (isset($row['ground_speed'])) {
316
+				$temp_array['ground_speed'] = $row['ground_speed'];
279 317
 			}
280
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
281 318
 			$temp_array['image'] = "";
282 319
 			$temp_array['image_thumbnail'] = "";
283 320
 			$temp_array['image_source'] = "";
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
  
286 323
 			if (isset($row['highlight'])) {
287 324
 				$temp_array['highlight'] = $row['highlight'];
288
-			} else $temp_array['highlight'] = '';
325
+			} else {
326
+				$temp_array['highlight'] = '';
327
+			}
289 328
 			
290 329
 			if (isset($row['date'])) {
291 330
 				$dateArray = $this->parseDateString($row['date']);
@@ -341,7 +380,9 @@  discard block
 block discarded – undo
341 380
 				
342 381
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 382
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344
-					} else $temp_array['aircraft_shadow'] = 'default.png';
383
+					} else {
384
+						$temp_array['aircraft_shadow'] = 'default.png';
385
+					}
345 386
                                 } else {
346 387
                             		$temp_array['aircraft_shadow'] = 'default.png';
347 388
 					$temp_array['aircraft_name'] = 'N/A';
@@ -349,11 +390,17 @@  discard block
 block discarded – undo
349 390
                             	}
350 391
 			}
351 392
 			$fromsource = NULL;
352
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
353
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
354
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
355
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
356
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
393
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
394
+				$fromsource = $globalAirlinesSource;
395
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
398
+				$fromsource = 'ivao';
399
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
400
+				$fromsource = 'vatsim';
401
+			} elseif (isset($globalIVAO) && $globalIVAO) {
402
+				$fromsource = 'ivao';
403
+			}
357 404
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 405
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 406
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -376,12 +423,18 @@  discard block
 block discarded – undo
376 423
 				}
377 424
 			} else {
378 425
 				$temp_array['airline_icao'] = $row['airline_icao'];
379
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
380
-				else $temp_array['airline_iata'] = 'N/A';
426
+				if (isset($row['airline_iata'])) {
427
+					$temp_array['airline_iata'] = $row['airline_iata'];
428
+				} else {
429
+					$temp_array['airline_iata'] = 'N/A';
430
+				}
381 431
 				$temp_array['airline_name'] = $row['airline_name'];
382 432
 				$temp_array['airline_country'] = $row['airline_country'];
383
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
384
-				else $temp_array['airline_callsign'] = 'N/A';
433
+				if (isset($row['airline_callsign'])) {
434
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
435
+				} else {
436
+					$temp_array['airline_callsign'] = 'N/A';
437
+				}
385 438
 				$temp_array['airline_type'] = $row['airline_type'];
386 439
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
387 440
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -408,7 +461,9 @@  discard block
 block discarded – undo
408 461
 			}
409 462
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
410 463
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
411
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
464
+				if ($owner_info['owner'] != '') {
465
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
466
+				}
412 467
 				$temp_array['aircraft_base'] = $owner_info['base'];
413 468
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 469
 			}
@@ -416,9 +471,14 @@  discard block
 block discarded – undo
416 471
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 472
 			{
418 473
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
421
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
474
+					if (isset($temp_array['airline_icao'])) {
475
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
476
+					} else {
477
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
478
+					}
479
+				} else {
480
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
481
+				}
422 482
 				if (count($image_array) > 0) {
423 483
 					$temp_array['image'] = $image_array[0]['image'];
424 484
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -470,7 +530,9 @@  discard block
 block discarded – undo
470 530
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
471 531
 			if ($row['departure_airport_icao'] != '') {
472 532
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
473
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
533
+				if (!isset($departure_airport_array[0]['name'])) {
534
+					$departure_airport_array = $this->getAllAirportInfo('NA');
535
+				}
474 536
 			/*
475 537
 			} elseif ($row['departure_airport_name'] != '') {
476 538
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -478,7 +540,9 @@  discard block
 block discarded – undo
478 540
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
479 541
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
480 542
 			*/
481
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
543
+			} else {
544
+				$departure_airport_array = $this->getAllAirportInfo('NA');
545
+			}
482 546
 			if (isset($departure_airport_array[0]['name'])) {
483 547
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
484 548
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -498,8 +562,12 @@  discard block
 block discarded – undo
498 562
 			
499 563
 			if ($row['arrival_airport_icao'] != '') {
500 564
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
501
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
502
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
565
+				if (count($arrival_airport_array) == 0) {
566
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
567
+				}
568
+			} else {
569
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
570
+			}
503 571
 			if (isset($arrival_airport_array[0]['name'])) {
504 572
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
505 573
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -515,27 +583,45 @@  discard block
 block discarded – undo
515 583
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
516 584
 			}
517 585
 			*/
518
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
519
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
520
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
521
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
522
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
586
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
587
+				$temp_array['pilot_id'] = $row['pilot_id'];
588
+			}
589
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
590
+				$temp_array['pilot_name'] = $row['pilot_name'];
591
+			}
592
+			if (isset($row['source_name']) && $row['source_name'] != '') {
593
+				$temp_array['source_name'] = $row['source_name'];
594
+			}
595
+			if (isset($row['over_country']) && $row['over_country'] != '') {
596
+				$temp_array['over_country'] = $row['over_country'];
597
+			}
598
+			if (isset($row['distance']) && $row['distance'] != '') {
599
+				$temp_array['distance'] = $row['distance'];
600
+			}
523 601
 			if (isset($row['squawk'])) {
524 602
 				$temp_array['squawk'] = $row['squawk'];
525 603
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526 604
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
605
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
606
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
607
+					}
528 608
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529 609
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
610
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
611
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
612
+					}
613
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
614
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
615
+				}
532 616
 			}
533 617
     			
534 618
 			$temp_array['query_number_rows'] = $num_rows;
535 619
 			
536 620
 			$spotter_array[] = $temp_array;
537 621
 		}
538
-		if ($num_rows == 0) return array();
622
+		if ($num_rows == 0) {
623
+			return array();
624
+		}
539 625
 		$spotter_array[0]['query_number_rows'] = $num_rows;
540 626
 		return $spotter_array;
541 627
 	}	
@@ -568,7 +654,9 @@  discard block
 block discarded – undo
568 654
 				foreach ($q_array as $q_item){
569 655
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
570 656
 					$additional_query .= " AND (";
571
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
657
+					if (is_int($q_item)) {
658
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
659
+					}
572 660
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
573 661
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
574 662
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -589,7 +677,9 @@  discard block
 block discarded – undo
589 677
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
590 678
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
591 679
 					$translate = $Translation->ident2icao($q_item);
592
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
680
+					if ($translate != $q_item) {
681
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
682
+					}
593 683
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
594 684
 					$additional_query .= ")";
595 685
 				}
@@ -816,7 +906,9 @@  discard block
 block discarded – undo
816 906
 				date_default_timezone_set($globalTimezone);
817 907
 				$datetime = new DateTime();
818 908
 				$offset = $datetime->format('P');
819
-			} else $offset = '+00:00';
909
+			} else {
910
+				$offset = '+00:00';
911
+			}
820 912
 
821 913
 			if ($date_array[1] != "")
822 914
 			{
@@ -848,8 +940,12 @@  discard block
 block discarded – undo
848 940
 			{
849 941
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
850 942
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
851
-			} else $limit_query = "";
852
-		} else $limit_query = "";
943
+			} else {
944
+				$limit_query = "";
945
+			}
946
+		} else {
947
+			$limit_query = "";
948
+		}
853 949
 
854 950
 
855 951
 		if ($sort != "")
@@ -917,8 +1013,12 @@  discard block
 block discarded – undo
917 1013
 			{
918 1014
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
919 1015
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
920
-			} else $limit_query = "";
921
-		} else $limit_query = "";
1016
+			} else {
1017
+				$limit_query = "";
1018
+			}
1019
+		} else {
1020
+			$limit_query = "";
1021
+		}
922 1022
 		
923 1023
 		if ($sort != "")
924 1024
 		{
@@ -1242,7 +1342,9 @@  discard block
 block discarded – undo
1242 1342
 		global $global_query;
1243 1343
 		
1244 1344
 		date_default_timezone_set('UTC');
1245
-		if ($id == '') return array();
1345
+		if ($id == '') {
1346
+			return array();
1347
+		}
1246 1348
 		$additional_query = "spotter_output.spotter_id = :id";
1247 1349
 		$query_values = array(':id' => $id);
1248 1350
 
@@ -1357,8 +1459,11 @@  discard block
 block discarded – undo
1357 1459
 		if ($sort != "")
1358 1460
 		{
1359 1461
 			$search_orderby_array = $this->getOrderBy();
1360
-			if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql'];
1361
-			else $orderby_query = " ORDER BY spotter_output.date DESC";
1462
+			if (isset($search_orderby_array[$sort]['sql'])) {
1463
+				$orderby_query = $search_orderby_array[$sort]['sql'];
1464
+			} else {
1465
+				$orderby_query = " ORDER BY spotter_output.date DESC";
1466
+			}
1362 1467
 		} else {
1363 1468
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1364 1469
 		}
@@ -1983,7 +2088,9 @@  discard block
 block discarded – undo
1983 2088
 		{
1984 2089
 			$highlight = $row['highlight'];
1985 2090
 		}
1986
-		if (isset($highlight)) return $highlight;
2091
+		if (isset($highlight)) {
2092
+			return $highlight;
2093
+		}
1987 2094
 	}
1988 2095
 
1989 2096
 	
@@ -2011,7 +2118,9 @@  discard block
 block discarded – undo
2011 2118
 		$sth->closeCursor();
2012 2119
 		if (count($row) > 0) {
2013 2120
 			return $row['usage'];
2014
-		} else return '';
2121
+		} else {
2122
+			return '';
2123
+		}
2015 2124
 	}
2016 2125
 
2017 2126
 	/**
@@ -2036,7 +2145,9 @@  discard block
 block discarded – undo
2036 2145
 		$sth->closeCursor();
2037 2146
 		if (count($row) > 0) {
2038 2147
 			return $row['icao'];
2039
-		} else return '';
2148
+		} else {
2149
+			return '';
2150
+		}
2040 2151
 	}
2041 2152
 
2042 2153
 	/**
@@ -2064,7 +2175,9 @@  discard block
 block discarded – undo
2064 2175
 			$airport_longitude = $row['longitude'];
2065 2176
 			$Common = new Common();
2066 2177
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2067
-		} else return '';
2178
+		} else {
2179
+			return '';
2180
+		}
2068 2181
 	}
2069 2182
 	
2070 2183
 	/**
@@ -2176,7 +2289,9 @@  discard block
 block discarded – undo
2176 2289
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177 2290
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178 2291
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2179
-		} else return array();
2292
+		} else {
2293
+			return array();
2294
+		}
2180 2295
 		if ($globalDBdriver == 'mysql') {
2181 2296
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2182 2297
 		} else {
@@ -2211,7 +2326,9 @@  discard block
 block discarded – undo
2211 2326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212 2327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213 2328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2214
-		} else return array();
2329
+		} else {
2330
+			return array();
2331
+		}
2215 2332
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216 2333
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2217 2334
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2246,7 +2363,9 @@  discard block
 block discarded – undo
2246 2363
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2364
 	{
2248 2365
 		global $globalUseRealAirlines;
2249
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2366
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2367
+			$fromsource = NULL;
2368
+		}
2250 2369
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2251 2370
 		if ($airline_icao == 'NA') {
2252 2371
 			$airline_array = array();
@@ -2315,7 +2434,9 @@  discard block
 block discarded – undo
2315 2434
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2435
 	{
2317 2436
 		global $globalUseRealAirlines;
2318
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2437
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2438
+			$fromsource = NULL;
2439
+		}
2319 2440
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320 2441
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2442
 		$sth = $this->db->prepare($query);
@@ -2331,7 +2452,9 @@  discard block
 block discarded – undo
2331 2452
 			$sth->execute(array(':fromsource' => $fromsource));
2332 2453
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2333 2454
 			$sth->closeCursor();
2334
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2455
+			if ($row['nb'] == 0) {
2456
+				$result = $this->getAllAirlineInfoByName($airline_name);
2457
+			}
2335 2458
 		}
2336 2459
 		return $result;
2337 2460
 	}
@@ -2394,15 +2517,20 @@  discard block
 block discarded – undo
2394 2517
 				'A320-211' => 'A320',
2395 2518
 				'747-8i' => 'B748',
2396 2519
 				'A380' => 'A388');
2397
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2520
+		if (isset($all_aircraft[$aircraft_type])) {
2521
+			return $all_aircraft[$aircraft_type];
2522
+		}
2398 2523
 
2399 2524
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2525
 		$aircraft_type = strtoupper($aircraft_type);
2401 2526
 		$sth = $this->db->prepare($query);
2402 2527
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2403 2528
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405
-		else return '';
2529
+		if (isset($result[0]['icao'])) {
2530
+			return $result[0]['icao'];
2531
+		} else {
2532
+			return '';
2533
+		}
2406 2534
 	}
2407 2535
 	
2408 2536
 	/**
@@ -2430,11 +2558,15 @@  discard block
 block discarded – undo
2430 2558
 		$sth->closeCursor();
2431 2559
 		if (isset($row['icaotypecode'])) {
2432 2560
 			$icao = $row['icaotypecode'];
2433
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2561
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2562
+				$icao = $this->aircraft_correct_icaotype[$icao];
2563
+			}
2434 2564
 			return $icao;
2435 2565
 		} elseif ($source_type == 'flarm') {
2436 2566
 			return $this->getAllAircraftType($aircraft_modes);
2437
-		} else  return '';
2567
+		} else {
2568
+			return '';
2569
+		}
2438 2570
 	}
2439 2571
 
2440 2572
 	/**
@@ -2457,7 +2589,9 @@  discard block
 block discarded – undo
2457 2589
 		$sth->closeCursor();
2458 2590
 		if (isset($row['icaotypecode'])) {
2459 2591
 			return $row['icaotypecode'];
2460
-		} else return '';
2592
+		} else {
2593
+			return '';
2594
+		}
2461 2595
 	}
2462 2596
 
2463 2597
 	/**
@@ -2503,7 +2637,9 @@  discard block
 block discarded – undo
2503 2637
 		$sth->closeCursor();
2504 2638
 		if (isset($row['operator_correct'])) {
2505 2639
 			return $row['operator_correct'];
2506
-		} else return $operator;
2640
+		} else {
2641
+			return $operator;
2642
+		}
2507 2643
 	}
2508 2644
 
2509 2645
 	/**
@@ -2516,7 +2652,9 @@  discard block
 block discarded – undo
2516 2652
 	public function getRouteInfo($callsign)
2517 2653
 	{
2518 2654
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2655
+                if ($callsign == '') {
2656
+                	return array();
2657
+                }
2520 2658
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2521 2659
 		
2522 2660
 		$sth = $this->db->prepare($query);
@@ -2526,7 +2664,9 @@  discard block
 block discarded – undo
2526 2664
 		$sth->closeCursor();
2527 2665
 		if (count($row) > 0) {
2528 2666
 			return $row;
2529
-		} else return array();
2667
+		} else {
2668
+			return array();
2669
+		}
2530 2670
 	}
2531 2671
 	
2532 2672
 	/**
@@ -2579,7 +2719,9 @@  discard block
 block discarded – undo
2579 2719
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2580 2720
 			$sth->closeCursor();
2581 2721
 			return $result;
2582
-		} else return array();
2722
+		} else {
2723
+			return array();
2724
+		}
2583 2725
 	}
2584 2726
 	
2585 2727
   
@@ -2738,8 +2880,11 @@  discard block
 block discarded – undo
2738 2880
 		$query .= " ORDER BY spotter_output.source_name ASC";
2739 2881
 
2740 2882
 		$sth = $this->db->prepare($query);
2741
-		if (!empty($query_values)) $sth->execute($query_values);
2742
-		else $sth->execute();
2883
+		if (!empty($query_values)) {
2884
+			$sth->execute($query_values);
2885
+		} else {
2886
+			$sth->execute();
2887
+		}
2743 2888
 
2744 2889
 		$source_array = array();
2745 2890
 		$temp_array = array();
@@ -2772,9 +2917,13 @@  discard block
 block discarded – undo
2772 2917
 								WHERE spotter_output.airline_icao <> '' 
2773 2918
 								ORDER BY spotter_output.airline_name ASC";
2774 2919
 			*/
2775
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2776
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2777
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2920
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2921
+				$forsource = $globalAirlinesSource;
2922
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2923
+				$forsource = 'vatsim';
2924
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2925
+				$forsource = 'ivao';
2926
+			}
2778 2927
 			if ($forsource === NULL) {
2779 2928
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2780 2929
 				$query_data = array();
@@ -2817,9 +2966,13 @@  discard block
 block discarded – undo
2817 2966
 	{
2818 2967
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819 2968
 		$filter_query = $this->getFilter($filters,true,true);
2820
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2969
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2970
+			$forsource = $globalAirlinesSource;
2971
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2972
+			$forsource = 'vatsim';
2973
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2974
+			$forsource = 'ivao';
2975
+		}
2823 2976
 		if ($forsource === NULL) {
2824 2977
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2825 2978
 			$query_data = array();
@@ -3130,7 +3283,9 @@  discard block
 block discarded – undo
3130 3283
 			date_default_timezone_set($globalTimezone);
3131 3284
 			$datetime = new DateTime();
3132 3285
 			$offset = $datetime->format('P');
3133
-		} else $offset = '+00:00';
3286
+		} else {
3287
+			$offset = '+00:00';
3288
+		}
3134 3289
 		if ($airport_icao == '') {
3135 3290
 			if ($globalDBdriver == 'mysql') {
3136 3291
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3162,7 +3317,9 @@  discard block
 block discarded – undo
3162 3317
 			date_default_timezone_set($globalTimezone);
3163 3318
 			$datetime = new DateTime();
3164 3319
 			$offset = $datetime->format('P');
3165
-		} else $offset = '+00:00';
3320
+		} else {
3321
+			$offset = '+00:00';
3322
+		}
3166 3323
 		if ($airport_icao == '') {
3167 3324
 			if ($globalDBdriver == 'mysql') {
3168 3325
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3195,7 +3352,9 @@  discard block
 block discarded – undo
3195 3352
 			date_default_timezone_set($globalTimezone);
3196 3353
 			$datetime = new DateTime();
3197 3354
 			$offset = $datetime->format('P');
3198
-		} else $offset = '+00:00';
3355
+		} else {
3356
+			$offset = '+00:00';
3357
+		}
3199 3358
 		if ($airport_icao == '') {
3200 3359
 			if ($globalDBdriver == 'mysql') {
3201 3360
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3234,7 +3393,9 @@  discard block
 block discarded – undo
3234 3393
 			date_default_timezone_set($globalTimezone);
3235 3394
 			$datetime = new DateTime();
3236 3395
 			$offset = $datetime->format('P');
3237
-		} else $offset = '+00:00';
3396
+		} else {
3397
+			$offset = '+00:00';
3398
+		}
3238 3399
 		if ($airport_icao == '') {
3239 3400
 			if ($globalDBdriver == 'mysql') {
3240 3401
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3279,7 +3440,9 @@  discard block
 block discarded – undo
3279 3440
 			date_default_timezone_set($globalTimezone);
3280 3441
 			$datetime = new DateTime();
3281 3442
 			$offset = $datetime->format('P');
3282
-		} else $offset = '+00:00';
3443
+		} else {
3444
+			$offset = '+00:00';
3445
+		}
3283 3446
 		if ($airport_icao == '') {
3284 3447
 			if ($globalDBdriver == 'mysql') {
3285 3448
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3314,7 +3477,9 @@  discard block
 block discarded – undo
3314 3477
 			date_default_timezone_set($globalTimezone);
3315 3478
 			$datetime = new DateTime();
3316 3479
 			$offset = $datetime->format('P');
3317
-		} else $offset = '+00:00';
3480
+		} else {
3481
+			$offset = '+00:00';
3482
+		}
3318 3483
 		if ($airport_icao == '') {
3319 3484
 			if ($globalDBdriver == 'mysql') {
3320 3485
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3356,7 +3521,9 @@  discard block
 block discarded – undo
3356 3521
 			date_default_timezone_set($globalTimezone);
3357 3522
 			$datetime = new DateTime();
3358 3523
 			$offset = $datetime->format('P');
3359
-		} else $offset = '+00:00';
3524
+		} else {
3525
+			$offset = '+00:00';
3526
+		}
3360 3527
 		if ($airport_icao == '') {
3361 3528
 			if ($globalDBdriver == 'mysql') {
3362 3529
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3390,7 +3557,9 @@  discard block
 block discarded – undo
3390 3557
 			date_default_timezone_set($globalTimezone);
3391 3558
 			$datetime = new DateTime();
3392 3559
 			$offset = $datetime->format('P');
3393
-		} else $offset = '+00:00';
3560
+		} else {
3561
+			$offset = '+00:00';
3562
+		}
3394 3563
 		if ($airport_icao == '') {
3395 3564
 			if ($globalDBdriver == 'mysql') {
3396 3565
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3438,7 +3607,9 @@  discard block
 block discarded – undo
3438 3607
 			date_default_timezone_set($globalTimezone);
3439 3608
 			$datetime = new DateTime();
3440 3609
 			$offset = $datetime->format('P');
3441
-		} else $offset = '+00:00';
3610
+		} else {
3611
+			$offset = '+00:00';
3612
+		}
3442 3613
 
3443 3614
 		if ($globalDBdriver == 'mysql') {
3444 3615
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3558,7 +3729,9 @@  discard block
 block discarded – undo
3558 3729
 	*/	
3559 3730
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3731
 	{
3561
-		if ($groundspeed == '') $groundspeed = NULL;
3732
+		if ($groundspeed == '') {
3733
+			$groundspeed = NULL;
3734
+		}
3562 3735
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3563 3736
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3564 3737
 
@@ -3608,10 +3781,18 @@  discard block
 block discarded – undo
3608 3781
 		$Image = new Image($this->db);
3609 3782
 		$Common = new Common();
3610 3783
 		
3611
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3612
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3613
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3614
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3784
+		if (!isset($globalIVAO)) {
3785
+			$globalIVAO = FALSE;
3786
+		}
3787
+		if (!isset($globalVATSIM)) {
3788
+			$globalVATSIM = FALSE;
3789
+		}
3790
+		if (!isset($globalphpVMS)) {
3791
+			$globalphpVMS = FALSE;
3792
+		}
3793
+		if (!isset($globalVAM)) {
3794
+			$globalVAM = FALSE;
3795
+		}
3615 3796
 		date_default_timezone_set('UTC');
3616 3797
 		
3617 3798
 		//getting the registration
@@ -3624,23 +3805,33 @@  discard block
 block discarded – undo
3624 3805
 				if ($ModeS != '') {
3625 3806
 					$timeelapsed = microtime(true);
3626 3807
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3808
+					if ($globalDebugTimeElapsed) {
3809
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3810
+					}
3628 3811
 				} else {
3629 3812
 					$myhex = explode('-',$flightaware_id);
3630 3813
 					if (count($myhex) > 0) {
3631 3814
 						$timeelapsed = microtime(true);
3632 3815
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+						if ($globalDebugTimeElapsed) {
3817
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+						}
3634 3819
 					}
3635 3820
 				}
3636 3821
 			}
3637 3822
 		}
3638 3823
 		$fromsource = NULL;
3639
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3640
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3641
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3642
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3643
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3824
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3825
+			$fromsource = $globalAirlinesSource;
3826
+		} elseif ($format_source == 'vatsimtxt') {
3827
+			$fromsource = 'vatsim';
3828
+		} elseif ($format_source == 'whazzup') {
3829
+			$fromsource = 'ivao';
3830
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3831
+			$fromsource = 'vatsim';
3832
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3833
+			$fromsource = 'ivao';
3834
+		}
3644 3835
 		//getting the airline information
3645 3836
 		if ($ident != "")
3646 3837
 		{
@@ -3664,15 +3855,21 @@  discard block
 block discarded – undo
3664 3855
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3665 3856
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3857
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858
+					if ($globalDebugTimeElapsed) {
3859
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3860
+					}
3668 3861
 
3669 3862
 				} else {
3670 3863
 					$timeelapsed = microtime(true);
3671 3864
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3865
+					if ($globalDebugTimeElapsed) {
3866
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3867
+					}
3673 3868
 				}
3674 3869
 			}
3675
-		} else $airline_array = array();
3870
+		} else {
3871
+			$airline_array = array();
3872
+		}
3676 3873
 		
3677 3874
 		//getting the aircraft information
3678 3875
 		$aircraft_array = array();
@@ -3686,27 +3883,37 @@  discard block
 block discarded – undo
3686 3883
 				{
3687 3884
 					$timeelapsed = microtime(true);
3688 3885
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3886
+					if ($globalDebugTimeElapsed) {
3887
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3888
+					}
3690 3889
 				} else {
3691 3890
 					$timeelapsed = microtime(true);
3692 3891
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3892
+					if ($globalDebugTimeElapsed) {
3893
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3894
+					}
3694 3895
 				}
3695 3896
 			}
3696 3897
 		} else {
3697 3898
 			if ($ModeS != '') {
3698 3899
 				$timeelapsed = microtime(true);
3699 3900
 				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3901
+				if ($globalDebugTimeElapsed) {
3902
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3903
+				}
3701 3904
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3905
 				{
3703 3906
 					$timeelapsed = microtime(true);
3704 3907
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3908
+					if ($globalDebugTimeElapsed) {
3909
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3910
+					}
3706 3911
 				} else {
3707 3912
 					$timeelapsed = microtime(true);
3708 3913
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3914
+					if ($globalDebugTimeElapsed) {
3915
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3916
+					}
3710 3917
 				}
3711 3918
 			}
3712 3919
 		}
@@ -3722,7 +3929,9 @@  discard block
 block discarded – undo
3722 3929
 			} else {
3723 3930
 				$timeelapsed = microtime(true);
3724 3931
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3932
+				if ($globalDebugTimeElapsed) {
3933
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3934
+				}
3726 3935
 			}
3727 3936
 		}
3728 3937
 		
@@ -3737,7 +3946,9 @@  discard block
 block discarded – undo
3737 3946
 			} else {
3738 3947
 				$timeelapsed = microtime(true);
3739 3948
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3949
+				if ($globalDebugTimeElapsed) {
3950
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3951
+				}
3741 3952
 			}
3742 3953
 		}
3743 3954
 
@@ -3771,7 +3982,9 @@  discard block
 block discarded – undo
3771 3982
 			{
3772 3983
 				return false;
3773 3984
 			}
3774
-		} else $altitude = 0;
3985
+		} else {
3986
+			$altitude = 0;
3987
+		}
3775 3988
 		
3776 3989
 		if ($heading != "")
3777 3990
 		{
@@ -3800,7 +4013,9 @@  discard block
 block discarded – undo
3800 4013
 		{
3801 4014
 			$timeelapsed = microtime(true);
3802 4015
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4016
+			if ($globalDebugTimeElapsed) {
4017
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4018
+			}
3804 4019
 			if (!isset($image_array[0]['registration']))
3805 4020
 			{
3806 4021
 				//echo "Add image !!!! \n";
@@ -3808,14 +4023,21 @@  discard block
 block discarded – undo
3808 4023
 			}
3809 4024
 			$timeelapsed = microtime(true);
3810 4025
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
4026
+			if ($globalDebugTimeElapsed) {
4027
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4028
+			}
4029
+			if ($owner_info['owner'] != '') {
4030
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
4031
+			}
3813 4032
 		}
3814 4033
     
3815 4034
 		if ($globalIVAO && $aircraft_icao != '')
3816 4035
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
4036
+            		if (isset($airline_array[0]['icao'])) {
4037
+            			$airline_icao = $airline_array[0]['icao'];
4038
+            		} else {
4039
+            			$airline_icao = '';
4040
+            		}
3819 4041
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 4042
 			if (!isset($image_array[0]['registration']))
3821 4043
 			{
@@ -3860,16 +4082,28 @@  discard block
 block discarded – undo
3860 4082
                 {
3861 4083
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3862 4084
                 }
3863
-                if ($registration == '') $registration = 'NA';
4085
+                if ($registration == '') {
4086
+                	$registration = 'NA';
4087
+                }
3864 4088
                 if ($latitude == '' && $longitude == '') {
3865 4089
             		$latitude = 0;
3866 4090
             		$longitude = 0;
3867 4091
             	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4092
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4093
+                	$squawk = NULL;
4094
+                }
4095
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4096
+                	$verticalrate = NULL;
4097
+                }
4098
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4099
+                	$heading = 0;
4100
+                }
4101
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4102
+                	$groundspeed = 0;
4103
+                }
4104
+                if (!isset($aircraft_owner)) {
4105
+                	$aircraft_owner = NULL;
4106
+                }
3873 4107
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3874 4108
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3875 4109
 
@@ -3880,9 +4114,13 @@  discard block
 block discarded – undo
3880 4114
 		if ($airline_type == '') {
3881 4115
 			$timeelapsed = microtime(true);
3882 4116
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4117
+			if ($globalDebugTimeElapsed) {
4118
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4119
+			}
4120
+		}
4121
+		if ($airline_type == null) {
4122
+			$airline_type = '';
3884 4123
 		}
3885
-		if ($airline_type == null) $airline_type = '';
3886 4124
                 $aircraft_type = $aircraft_array[0]['type'];
3887 4125
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888 4126
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -4046,7 +4284,9 @@  discard block
 block discarded – undo
4046 4284
 			}
4047 4285
 		}
4048 4286
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
4049
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4287
+		if ($limit) {
4288
+			$query .= " LIMIT 10 OFFSET 0";
4289
+		}
4050 4290
 
4051 4291
 		$sth = $this->db->prepare($query);
4052 4292
 		$sth->execute($query_values);
@@ -4119,7 +4359,9 @@  discard block
 block discarded – undo
4119 4359
 		}
4120 4360
 		
4121 4361
 		$query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4122
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4362
+		if ($limit) {
4363
+			$query .= " LIMIT 10 OFFSET 0";
4364
+		}
4123 4365
       
4124 4366
 		
4125 4367
 		$sth = $this->db->prepare($query);
@@ -4163,7 +4405,9 @@  discard block
 block discarded – undo
4163 4405
 			}
4164 4406
 		}
4165 4407
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4408
+		if ($limit) {
4409
+			$query .= " LIMIT 10 OFFSET 0";
4410
+		}
4167 4411
       
4168 4412
 		
4169 4413
 		$sth = $this->db->prepare($query);
@@ -4239,7 +4483,9 @@  discard block
 block discarded – undo
4239 4483
 			}
4240 4484
 		}
4241 4485
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4242
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4486
+		if ($limit) {
4487
+			$query .= " LIMIT 10 OFFSET 0";
4488
+		}
4243 4489
 		
4244 4490
 		$sth = $this->db->prepare($query);
4245 4491
 		$sth->execute($query_values);
@@ -4281,7 +4527,9 @@  discard block
 block discarded – undo
4281 4527
 			}
4282 4528
 		}
4283 4529
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4284
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4530
+		if ($limit) {
4531
+			$query .= " LIMIT 10 OFFSET 0";
4532
+		}
4285 4533
       
4286 4534
 		
4287 4535
 		$sth = $this->db->prepare($query);
@@ -4524,7 +4772,9 @@  discard block
 block discarded – undo
4524 4772
 			date_default_timezone_set($globalTimezone);
4525 4773
 			$datetime = new DateTime($date);
4526 4774
 			$offset = $datetime->format('P');
4527
-		} else $offset = '+00:00';
4775
+		} else {
4776
+			$offset = '+00:00';
4777
+		}
4528 4778
 
4529 4779
 		if ($globalDBdriver == 'mysql') {
4530 4780
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4572,7 +4822,9 @@  discard block
 block discarded – undo
4572 4822
 			date_default_timezone_set($globalTimezone);
4573 4823
 			$datetime = new DateTime($date);
4574 4824
 			$offset = $datetime->format('P');
4575
-		} else $offset = '+00:00';
4825
+		} else {
4826
+			$offset = '+00:00';
4827
+		}
4576 4828
 		
4577 4829
 		if ($globalDBdriver == 'mysql') {
4578 4830
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4692,9 +4944,13 @@  discard block
 block discarded – undo
4692 4944
 		$sth = $this->db->prepare($query);
4693 4945
 		$sth->execute($query_values);
4694 4946
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4695
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4696
-		elseif ($result[0]['duration'] == '') return 0;
4697
-		else return $result[0]['duration'];
4947
+		if (is_numeric($result[0]['duration'])) {
4948
+			return gmdate('H:i:s',$result[0]['duration']);
4949
+		} elseif ($result[0]['duration'] == '') {
4950
+			return 0;
4951
+		} else {
4952
+			return $result[0]['duration'];
4953
+		}
4698 4954
 	}
4699 4955
 
4700 4956
 	/**
@@ -4783,8 +5039,11 @@  discard block
 block discarded – undo
4783 5039
 		$sth = $this->db->prepare($query);
4784 5040
 		$sth->execute($query_values);
4785 5041
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4786
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4787
-		else return $result[0]['duration'];
5042
+		if (is_int($result[0]['duration'])) {
5043
+			return gmdate('H:i:s',$result[0]['duration']);
5044
+		} else {
5045
+			return $result[0]['duration'];
5046
+		}
4788 5047
 	}
4789 5048
 
4790 5049
 	/**
@@ -4989,7 +5248,9 @@  discard block
 block discarded – undo
4989 5248
 		}
4990 5249
 		$query .= " GROUP BY spotter_output.airline_country
4991 5250
 					ORDER BY airline_country_count DESC";
4992
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5251
+		if ($limit) {
5252
+			$query .= " LIMIT 10 OFFSET 0";
5253
+		}
4993 5254
       
4994 5255
 		$sth = $this->db->prepare($query);
4995 5256
 		$sth->execute($query_values);
@@ -5017,7 +5278,9 @@  discard block
 block discarded – undo
5017 5278
 		global $globalDBdriver;
5018 5279
 		//$filter_query = $this->getFilter($filters,true,true);
5019 5280
 		$Connection= new Connection($this->db);
5020
-		if (!$Connection->tableExists('countries')) return array();
5281
+		if (!$Connection->tableExists('countries')) {
5282
+			return array();
5283
+		}
5021 5284
 		/*
5022 5285
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
5023 5286
 					FROM countries c, spotter_output s
@@ -5049,7 +5312,9 @@  discard block
 block discarded – undo
5049 5312
 		}
5050 5313
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
5051 5314
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
5052
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5315
+		if ($limit) {
5316
+			$query .= " LIMIT 10 OFFSET 0";
5317
+		}
5053 5318
       
5054 5319
 		
5055 5320
 		$sth = $this->db->prepare($query);
@@ -5126,7 +5391,9 @@  discard block
 block discarded – undo
5126 5391
 		}
5127 5392
 
5128 5393
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5129
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5394
+		if ($limit) {
5395
+			$query .= " LIMIT 10 OFFSET 0";
5396
+		}
5130 5397
  
5131 5398
 		$sth = $this->db->prepare($query);
5132 5399
 		$sth->execute($query_values);
@@ -5200,7 +5467,9 @@  discard block
 block discarded – undo
5200 5467
 		}
5201 5468
 
5202 5469
 		$query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5203
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5470
+		if ($limit) {
5471
+			$query .= " LIMIT 10 OFFSET 0";
5472
+		}
5204 5473
  
5205 5474
 		$sth = $this->db->prepare($query);
5206 5475
 		$sth->execute($query_values);
@@ -5247,7 +5516,9 @@  discard block
 block discarded – undo
5247 5516
 		}
5248 5517
 
5249 5518
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5250
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5519
+		if ($limit) {
5520
+			$query .= " LIMIT 10 OFFSET 0";
5521
+		}
5251 5522
  
5252 5523
 		$sth = $this->db->prepare($query);
5253 5524
 		$sth->execute();
@@ -5300,7 +5571,9 @@  discard block
 block discarded – undo
5300 5571
 			if($row['registration'] != "")
5301 5572
 			{
5302 5573
 				$image_array = $Image->getSpotterImage($row['registration']);
5303
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5574
+				if (isset($image_array[0]['image_thumbnail'])) {
5575
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5576
+				}
5304 5577
 			}
5305 5578
 			$temp_array['registration_count'] = $row['registration_count'];
5306 5579
 
@@ -5375,7 +5648,9 @@  discard block
 block discarded – undo
5375 5648
 			if($row['registration'] != "")
5376 5649
 			{
5377 5650
 				$image_array = $Image->getSpotterImage($row['registration']);
5378
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5651
+				if (isset($image_array[0]['image_thumbnail'])) {
5652
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5653
+				}
5379 5654
 			}
5380 5655
 			$temp_array['registration_count'] = $row['registration_count'];
5381 5656
 
@@ -5482,7 +5757,9 @@  discard block
 block discarded – undo
5482 5757
 			if($row['registration'] != "")
5483 5758
 			{
5484 5759
 				$image_array = $Image->getSpotterImage($row['registration']);
5485
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5760
+				if (isset($image_array[0]['image_thumbnail'])) {
5761
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5762
+				}
5486 5763
 			}
5487 5764
 			$temp_array['registration_count'] = $row['registration_count'];
5488 5765
 			$aircraft_array[] = $temp_array;
@@ -5607,7 +5884,9 @@  discard block
 block discarded – undo
5607 5884
 			date_default_timezone_set($globalTimezone);
5608 5885
 			$datetime = new DateTime($date);
5609 5886
 			$offset = $datetime->format('P');
5610
-		} else $offset = '+00:00';
5887
+		} else {
5888
+			$offset = '+00:00';
5889
+		}
5611 5890
 
5612 5891
 		if ($globalDBdriver == 'mysql') {
5613 5892
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5654,7 +5933,9 @@  discard block
 block discarded – undo
5654 5933
 			date_default_timezone_set($globalTimezone);
5655 5934
 			$datetime = new DateTime($date);
5656 5935
 			$offset = $datetime->format('P');
5657
-		} else $offset = '+00:00';
5936
+		} else {
5937
+			$offset = '+00:00';
5938
+		}
5658 5939
 
5659 5940
 		if ($globalDBdriver == 'mysql') {
5660 5941
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -5683,7 +5964,9 @@  discard block
 block discarded – undo
5683 5964
 			if($row['registration'] != "")
5684 5965
 			{
5685 5966
 				$image_array = $Image->getSpotterImage($row['registration']);
5686
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5967
+				if (isset($image_array[0]['image_thumbnail'])) {
5968
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5969
+				}
5687 5970
 			}
5688 5971
 			$temp_array['registration_count'] = $row['registration_count'];
5689 5972
  
@@ -5708,7 +5991,9 @@  discard block
 block discarded – undo
5708 5991
 			date_default_timezone_set($globalTimezone);
5709 5992
 			$datetime = new DateTime($date);
5710 5993
 			$offset = $datetime->format('P');
5711
-		} else $offset = '+00:00';
5994
+		} else {
5995
+			$offset = '+00:00';
5996
+		}
5712 5997
 
5713 5998
 		if ($globalDBdriver == 'mysql') {
5714 5999
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5904,8 +6189,11 @@  discard block
 block discarded – undo
5904 6189
 			if($row['registration'] != "")
5905 6190
 			{
5906 6191
 				$image_array = $Image->getSpotterImage($row['registration']);
5907
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5908
-				else $temp_array['image_thumbnail'] = '';
6192
+				if (isset($image_array[0]['image_thumbnail'])) {
6193
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6194
+				} else {
6195
+					$temp_array['image_thumbnail'] = '';
6196
+				}
5909 6197
 			}
5910 6198
 			$temp_array['registration_count'] = $row['registration_count'];
5911 6199
 			$aircraft_array[] = $temp_array;
@@ -5979,8 +6267,11 @@  discard block
 block discarded – undo
5979 6267
 			if($row['registration'] != "")
5980 6268
 			{
5981 6269
 				$image_array = $Image->getSpotterImage($row['registration']);
5982
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5983
-				else $temp_array['image_thumbnail'] = '';
6270
+				if (isset($image_array[0]['image_thumbnail'])) {
6271
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6272
+				} else {
6273
+					$temp_array['image_thumbnail'] = '';
6274
+				}
5984 6275
 			}
5985 6276
 			$temp_array['registration_count'] = $row['registration_count'];
5986 6277
 			$aircraft_array[] = $temp_array;
@@ -6054,8 +6345,11 @@  discard block
 block discarded – undo
6054 6345
 			if($row['registration'] != "")
6055 6346
 			{
6056 6347
 				$image_array = $Image->getSpotterImage($row['registration']);
6057
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6058
-				else $temp_array['image_thumbnail'] = '';
6348
+				if (isset($image_array[0]['image_thumbnail'])) {
6349
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6350
+				} else {
6351
+					$temp_array['image_thumbnail'] = '';
6352
+				}
6059 6353
 			}
6060 6354
 			$temp_array['registration_count'] = $row['registration_count'];
6061 6355
 			$aircraft_array[] = $temp_array;
@@ -6266,7 +6560,9 @@  discard block
 block discarded – undo
6266 6560
 			if($row['registration'] != "")
6267 6561
 			{
6268 6562
 				$image_array = $Image->getSpotterImage($row['registration']);
6269
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6563
+				if (isset($image_array[0]['image_thumbnail'])) {
6564
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6565
+				}
6270 6566
 			}
6271 6567
 			$temp_array['registration_count'] = $row['registration_count'];
6272 6568
           
@@ -6383,7 +6679,9 @@  discard block
 block discarded – undo
6383 6679
 			if($row['registration'] != "")
6384 6680
 			{
6385 6681
 				$image_array = $Image->getSpotterImage($row['registration']);
6386
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6682
+				if (isset($image_array[0]['image_thumbnail'])) {
6683
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6684
+				}
6387 6685
 			}
6388 6686
 			$temp_array['registration_count'] = $row['registration_count'];
6389 6687
           
@@ -6549,7 +6847,9 @@  discard block
 block discarded – undo
6549 6847
 			}
6550 6848
 		}
6551 6849
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6552
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6850
+		if ($limit) {
6851
+			$query .= " LIMIT 10 OFFSET 0";
6852
+		}
6553 6853
 		
6554 6854
 		$sth = $this->db->prepare($query);
6555 6855
 		$sth->execute($query_values);
@@ -6568,7 +6868,9 @@  discard block
 block discarded – undo
6568 6868
 			if($row['registration'] != "")
6569 6869
 			{
6570 6870
 				$image_array = $Image->getSpotterImage($row['registration']);
6571
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6871
+				if (isset($image_array[0]['image_thumbnail'])) {
6872
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6873
+				}
6572 6874
 			}
6573 6875
           
6574 6876
 			$aircraft_array[] = $temp_array;
@@ -6609,7 +6911,9 @@  discard block
 block discarded – undo
6609 6911
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6912
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611 6913
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6612
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6914
+		if ($limit) {
6915
+			$query .= " LIMIT 10 OFFSET 0";
6916
+		}
6613 6917
 		
6614 6918
 		$sth = $this->db->prepare($query);
6615 6919
 		$sth->execute();
@@ -6629,7 +6933,9 @@  discard block
 block discarded – undo
6629 6933
 			if($row['registration'] != "")
6630 6934
 			{
6631 6935
 				$image_array = $Image->getSpotterImage($row['registration']);
6632
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6936
+				if (isset($image_array[0]['image_thumbnail'])) {
6937
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6938
+				}
6633 6939
 			}
6634 6940
           
6635 6941
 			$aircraft_array[] = $temp_array;
@@ -6695,7 +7001,9 @@  discard block
 block discarded – undo
6695 7001
 		}
6696 7002
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 7003
 				ORDER BY airport_departure_icao_count DESC";
6698
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7004
+		if ($limit) {
7005
+			$query .= " LIMIT 10 OFFSET 0";
7006
+		}
6699 7007
 
6700 7008
 		$sth = $this->db->prepare($query);
6701 7009
 		$sth->execute($query_values);
@@ -6746,7 +7054,9 @@  discard block
 block discarded – undo
6746 7054
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747 7055
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6748 7056
 				ORDER BY airport_departure_icao_count DESC";
6749
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7057
+		if ($limit) {
7058
+			$query .= " LIMIT 10 OFFSET 0";
7059
+		}
6750 7060
       
6751 7061
 		$sth = $this->db->prepare($query);
6752 7062
 		$sth->execute();
@@ -6824,7 +7134,9 @@  discard block
 block discarded – undo
6824 7134
 		}
6825 7135
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 7136
 				ORDER BY airport_departure_icao_count DESC";
6827
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7137
+		if ($limit) {
7138
+			$query .= " LIMIT 10 OFFSET 0";
7139
+		}
6828 7140
     		//echo $query;
6829 7141
 		$sth = $this->db->prepare($query);
6830 7142
 		$sth->execute($query_values);
@@ -6876,7 +7188,9 @@  discard block
 block discarded – undo
6876 7188
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877 7189
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 7190
 				ORDER BY airport_departure_icao_count DESC";
6879
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7191
+		if ($limit) {
7192
+			$query .= " LIMIT 10 OFFSET 0";
7193
+		}
6880 7194
       
6881 7195
 		$sth = $this->db->prepare($query);
6882 7196
 		$sth->execute();
@@ -7271,7 +7585,9 @@  discard block
 block discarded – undo
7271 7585
 			date_default_timezone_set($globalTimezone);
7272 7586
 			$datetime = new DateTime($date);
7273 7587
 			$offset = $datetime->format('P');
7274
-		} else $offset = '+00:00';
7588
+		} else {
7589
+			$offset = '+00:00';
7590
+		}
7275 7591
 
7276 7592
 		if ($globalDBdriver == 'mysql') {
7277 7593
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -7321,7 +7637,9 @@  discard block
 block discarded – undo
7321 7637
 			date_default_timezone_set($globalTimezone);
7322 7638
 			$datetime = new DateTime($date);
7323 7639
 			$offset = $datetime->format('P');
7324
-		} else $offset = '+00:00';
7640
+		} else {
7641
+			$offset = '+00:00';
7642
+		}
7325 7643
 
7326 7644
 		if ($globalDBdriver == 'mysql') {
7327 7645
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7670,7 +7988,9 @@  discard block
 block discarded – undo
7670 7988
 		}
7671 7989
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7990
 					ORDER BY airport_arrival_icao_count DESC";
7673
-		if ($limit) $query .= " LIMIT 10";
7991
+		if ($limit) {
7992
+			$query .= " LIMIT 10";
7993
+		}
7674 7994
       
7675 7995
 		
7676 7996
 		$sth = $this->db->prepare($query);
@@ -7690,7 +8010,9 @@  discard block
 block discarded – undo
7690 8010
 			if ($icaoaskey) {
7691 8011
 				$icao = $row['arrival_airport_icao'];
7692 8012
 				$airport_array[$icao] = $temp_array;
7693
-			} else $airport_array[] = $temp_array;
8013
+			} else {
8014
+				$airport_array[] = $temp_array;
8015
+			}
7694 8016
 		}
7695 8017
 
7696 8018
 		return $airport_array;
@@ -7727,7 +8049,9 @@  discard block
 block discarded – undo
7727 8049
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728 8050
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7729 8051
 					ORDER BY airport_arrival_icao_count DESC";
7730
-		if ($limit) $query .= " LIMIT 10";
8052
+		if ($limit) {
8053
+			$query .= " LIMIT 10";
8054
+		}
7731 8055
       
7732 8056
 		
7733 8057
 		$sth = $this->db->prepare($query);
@@ -7748,7 +8072,9 @@  discard block
 block discarded – undo
7748 8072
 			if ($icaoaskey) {
7749 8073
 				$icao = $row['arrival_airport_icao'];
7750 8074
 				$airport_array[$icao] = $temp_array;
7751
-			} else $airport_array[] = $temp_array;
8075
+			} else {
8076
+				$airport_array[] = $temp_array;
8077
+			}
7752 8078
 		}
7753 8079
 
7754 8080
 		return $airport_array;
@@ -7811,7 +8137,9 @@  discard block
 block discarded – undo
7811 8137
 		}
7812 8138
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 8139
 					ORDER BY airport_arrival_icao_count DESC";
7814
-		if ($limit) $query .= " LIMIT 10";
8140
+		if ($limit) {
8141
+			$query .= " LIMIT 10";
8142
+		}
7815 8143
       
7816 8144
 		
7817 8145
 		$sth = $this->db->prepare($query);
@@ -7830,7 +8158,9 @@  discard block
 block discarded – undo
7830 8158
 			if ($icaoaskey) {
7831 8159
 				$icao = $row['arrival_airport_icao'];
7832 8160
 				$airport_array[$icao] = $temp_array;
7833
-			} else $airport_array[] = $temp_array;
8161
+			} else {
8162
+				$airport_array[] = $temp_array;
8163
+			}
7834 8164
 		}
7835 8165
 
7836 8166
 		return $airport_array;
@@ -7867,7 +8197,9 @@  discard block
 block discarded – undo
7867 8197
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868 8198
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 8199
 					ORDER BY airport_arrival_icao_count DESC";
7870
-		if ($limit) $query .= " LIMIT 10";
8200
+		if ($limit) {
8201
+			$query .= " LIMIT 10";
8202
+		}
7871 8203
       
7872 8204
 		
7873 8205
 		$sth = $this->db->prepare($query);
@@ -7888,7 +8220,9 @@  discard block
 block discarded – undo
7888 8220
 			if ($icaoaskey) {
7889 8221
 				$icao = $row['arrival_airport_icao'];
7890 8222
 				$airport_array[$icao] = $temp_array;
7891
-			} else $airport_array[] = $temp_array;
8223
+			} else {
8224
+				$airport_array[] = $temp_array;
8225
+			}
7892 8226
 		}
7893 8227
 
7894 8228
 		return $airport_array;
@@ -8269,7 +8603,9 @@  discard block
 block discarded – undo
8269 8603
 			date_default_timezone_set($globalTimezone);
8270 8604
 			$datetime = new DateTime($date);
8271 8605
 			$offset = $datetime->format('P');
8272
-		} else $offset = '+00:00';
8606
+		} else {
8607
+			$offset = '+00:00';
8608
+		}
8273 8609
 
8274 8610
 		if ($globalDBdriver == 'mysql') {
8275 8611
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -8319,7 +8655,9 @@  discard block
 block discarded – undo
8319 8655
 			date_default_timezone_set($globalTimezone);
8320 8656
 			$datetime = new DateTime($date);
8321 8657
 			$offset = $datetime->format('P');
8322
-		} else $offset = '+00:00';
8658
+		} else {
8659
+			$offset = '+00:00';
8660
+		}
8323 8661
 
8324 8662
 		if ($globalDBdriver == 'mysql') {
8325 8663
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8710,7 +9048,9 @@  discard block
 block discarded – undo
8710 9048
 		}
8711 9049
 		$query .= " GROUP BY spotter_output.arrival_airport_country
8712 9050
 					ORDER BY airport_arrival_country_count DESC";
8713
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9051
+		if ($limit) {
9052
+			$query .= " LIMIT 10 OFFSET 0";
9053
+		}
8714 9054
       
8715 9055
 		
8716 9056
 		$sth = $this->db->prepare($query);
@@ -8997,7 +9337,9 @@  discard block
 block discarded – undo
8997 9337
 			date_default_timezone_set($globalTimezone);
8998 9338
 			$datetime = new DateTime($date);
8999 9339
 			$offset = $datetime->format('P');
9000
-		} else $offset = '+00:00';
9340
+		} else {
9341
+			$offset = '+00:00';
9342
+		}
9001 9343
 		
9002 9344
 		if ($globalDBdriver == 'mysql') {
9003 9345
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -9253,12 +9595,18 @@  discard block
 block discarded – undo
9253 9595
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9254 9596
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9255 9597
 		 if ($olderthanmonths > 0) {
9256
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9257
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9598
+			if ($globalDBdriver == 'mysql') {
9599
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9600
+			} else {
9601
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9602
+			}
9258 9603
 		}
9259 9604
 		if ($sincedate != '') {
9260
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
9261
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9605
+			if ($globalDBdriver == 'mysql') {
9606
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9607
+			} else {
9608
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9609
+			}
9262 9610
 		}
9263 9611
 		$query_values = array();
9264 9612
 		if ($year != '') {
@@ -9289,7 +9637,9 @@  discard block
 block discarded – undo
9289 9637
 			}
9290 9638
 		}
9291 9639
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9292
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9640
+		if ($limit) {
9641
+			$query .= " LIMIT 10 OFFSET 0";
9642
+		}
9293 9643
       		
9294 9644
 		$sth = $this->db->prepare($query);
9295 9645
 		$sth->execute($query_values);
@@ -9323,15 +9673,23 @@  discard block
 block discarded – undo
9323 9673
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9324 9674
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9325 9675
 		 if ($olderthanmonths > 0) {
9326
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9327
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9676
+			if ($globalDBdriver == 'mysql') {
9677
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9678
+			} else {
9679
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9680
+			}
9328 9681
 		}
9329 9682
 		if ($sincedate != '') {
9330
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
9331
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9683
+			if ($globalDBdriver == 'mysql') {
9684
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9685
+			} else {
9686
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9687
+			}
9332 9688
 		}
9333 9689
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9334
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9690
+		if ($limit) {
9691
+			$query .= " LIMIT 10 OFFSET 0";
9692
+		}
9335 9693
       		
9336 9694
 		$sth = $this->db->prepare($query);
9337 9695
 		$sth->execute();
@@ -9368,7 +9726,9 @@  discard block
 block discarded – undo
9368 9726
 			date_default_timezone_set($globalTimezone);
9369 9727
 			$datetime = new DateTime();
9370 9728
 			$offset = $datetime->format('P');
9371
-		} else $offset = '+00:00';
9729
+		} else {
9730
+			$offset = '+00:00';
9731
+		}
9372 9732
 
9373 9733
 		if ($globalDBdriver == 'mysql') {
9374 9734
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9417,7 +9777,9 @@  discard block
 block discarded – undo
9417 9777
 			date_default_timezone_set($globalTimezone);
9418 9778
 			$datetime = new DateTime();
9419 9779
 			$offset = $datetime->format('P');
9420
-		} else $offset = '+00:00';
9780
+		} else {
9781
+			$offset = '+00:00';
9782
+		}
9421 9783
 		$filter_query = $this->getFilter($filters,true,true);
9422 9784
 		if ($globalDBdriver == 'mysql') {
9423 9785
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9466,7 +9828,9 @@  discard block
 block discarded – undo
9466 9828
 			date_default_timezone_set($globalTimezone);
9467 9829
 			$datetime = new DateTime();
9468 9830
 			$offset = $datetime->format('P');
9469
-		} else $offset = '+00:00';
9831
+		} else {
9832
+			$offset = '+00:00';
9833
+		}
9470 9834
 		$filter_query = $this->getFilter($filters,true,true);
9471 9835
 		if ($globalDBdriver == 'mysql') {
9472 9836
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9512,7 +9876,9 @@  discard block
 block discarded – undo
9512 9876
 			date_default_timezone_set($globalTimezone);
9513 9877
 			$datetime = new DateTime();
9514 9878
 			$offset = $datetime->format('P');
9515
-		} else $offset = '+00:00';
9879
+		} else {
9880
+			$offset = '+00:00';
9881
+		}
9516 9882
 		$filter_query = $this->getFilter($filters,true,true);
9517 9883
 		if ($globalDBdriver == 'mysql') {
9518 9884
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9560,7 +9926,9 @@  discard block
 block discarded – undo
9560 9926
 			date_default_timezone_set($globalTimezone);
9561 9927
 			$datetime = new DateTime();
9562 9928
 			$offset = $datetime->format('P');
9563
-		} else $offset = '+00:00';
9929
+		} else {
9930
+			$offset = '+00:00';
9931
+		}
9564 9932
 		
9565 9933
 		if ($globalDBdriver == 'mysql') {
9566 9934
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9608,7 +9976,9 @@  discard block
 block discarded – undo
9608 9976
 			date_default_timezone_set($globalTimezone);
9609 9977
 			$datetime = new DateTime();
9610 9978
 			$offset = $datetime->format('P');
9611
-		} else $offset = '+00:00';
9979
+		} else {
9980
+			$offset = '+00:00';
9981
+		}
9612 9982
 
9613 9983
 		if ($globalDBdriver == 'mysql') {
9614 9984
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9655,7 +10025,9 @@  discard block
 block discarded – undo
9655 10025
 			date_default_timezone_set($globalTimezone);
9656 10026
 			$datetime = new DateTime();
9657 10027
 			$offset = $datetime->format('P');
9658
-		} else $offset = '+00:00';
10028
+		} else {
10029
+			$offset = '+00:00';
10030
+		}
9659 10031
 
9660 10032
 		if ($globalDBdriver == 'mysql') {
9661 10033
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9703,7 +10075,9 @@  discard block
 block discarded – undo
9703 10075
 			date_default_timezone_set($globalTimezone);
9704 10076
 			$datetime = new DateTime();
9705 10077
 			$offset = $datetime->format('P');
9706
-		} else $offset = '+00:00';
10078
+		} else {
10079
+			$offset = '+00:00';
10080
+		}
9707 10081
 		$filter_query = $this->getFilter($filters,true,true);
9708 10082
 		if ($globalDBdriver == 'mysql') {
9709 10083
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9748,7 +10122,9 @@  discard block
 block discarded – undo
9748 10122
 			date_default_timezone_set($globalTimezone);
9749 10123
 			$datetime = new DateTime();
9750 10124
 			$offset = $datetime->format('P');
9751
-		} else $offset = '+00:00';
10125
+		} else {
10126
+			$offset = '+00:00';
10127
+		}
9752 10128
 		$filter_query = $this->getFilter($filters,true,true);
9753 10129
 
9754 10130
 		if ($globalDBdriver == 'mysql') {
@@ -9795,7 +10171,9 @@  discard block
 block discarded – undo
9795 10171
 			date_default_timezone_set($globalTimezone);
9796 10172
 			$datetime = new DateTime();
9797 10173
 			$offset = $datetime->format('P');
9798
-		} else $offset = '+00:00';
10174
+		} else {
10175
+			$offset = '+00:00';
10176
+		}
9799 10177
 
9800 10178
 		if ($globalDBdriver == 'mysql') {
9801 10179
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -9841,7 +10219,9 @@  discard block
 block discarded – undo
9841 10219
 			date_default_timezone_set($globalTimezone);
9842 10220
 			$datetime = new DateTime();
9843 10221
 			$offset = $datetime->format('P');
9844
-		} else $offset = '+00:00';
10222
+		} else {
10223
+			$offset = '+00:00';
10224
+		}
9845 10225
 		$filter_query = $this->getFilter($filters,true,true);
9846 10226
 
9847 10227
 		if ($globalDBdriver == 'mysql') {
@@ -9888,7 +10268,9 @@  discard block
 block discarded – undo
9888 10268
 			date_default_timezone_set($globalTimezone);
9889 10269
 			$datetime = new DateTime();
9890 10270
 			$offset = $datetime->format('P');
9891
-		} else $offset = '+00:00';
10271
+		} else {
10272
+			$offset = '+00:00';
10273
+		}
9892 10274
 
9893 10275
 		if ($globalDBdriver == 'mysql') {
9894 10276
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -9935,7 +10317,9 @@  discard block
 block discarded – undo
9935 10317
 			date_default_timezone_set($globalTimezone);
9936 10318
 			$datetime = new DateTime();
9937 10319
 			$offset = $datetime->format('P');
9938
-		} else $offset = '+00:00';
10320
+		} else {
10321
+			$offset = '+00:00';
10322
+		}
9939 10323
 
9940 10324
 		if ($globalDBdriver == 'mysql') {
9941 10325
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -9980,7 +10364,9 @@  discard block
 block discarded – undo
9980 10364
 			date_default_timezone_set($globalTimezone);
9981 10365
 			$datetime = new DateTime();
9982 10366
 			$offset = $datetime->format('P');
9983
-		} else $offset = '+00:00';
10367
+		} else {
10368
+			$offset = '+00:00';
10369
+		}
9984 10370
 		$filter_query = $this->getFilter($filters,true,true);
9985 10371
 
9986 10372
 		if ($globalDBdriver == 'mysql') {
@@ -10028,7 +10414,9 @@  discard block
 block discarded – undo
10028 10414
 			date_default_timezone_set($globalTimezone);
10029 10415
 			$datetime = new DateTime();
10030 10416
 			$offset = $datetime->format('P');
10031
-		} else $offset = '+00:00';
10417
+		} else {
10418
+			$offset = '+00:00';
10419
+		}
10032 10420
 
10033 10421
 		if ($globalDBdriver == 'mysql') {
10034 10422
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -10074,7 +10462,9 @@  discard block
 block discarded – undo
10074 10462
 			date_default_timezone_set($globalTimezone);
10075 10463
 			$datetime = new DateTime();
10076 10464
 			$offset = $datetime->format('P');
10077
-		} else $offset = '+00:00';
10465
+		} else {
10466
+			$offset = '+00:00';
10467
+		}
10078 10468
 		$filter_query = $this->getFilter($filters,true,true);
10079 10469
 
10080 10470
 		if ($globalDBdriver == 'mysql') {
@@ -10122,7 +10512,9 @@  discard block
 block discarded – undo
10122 10512
 			date_default_timezone_set($globalTimezone);
10123 10513
 			$datetime = new DateTime();
10124 10514
 			$offset = $datetime->format('P');
10125
-		} else $offset = '+00:00';
10515
+		} else {
10516
+			$offset = '+00:00';
10517
+		}
10126 10518
 
10127 10519
 		if ($globalDBdriver == 'mysql') {
10128 10520
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -10169,7 +10561,9 @@  discard block
 block discarded – undo
10169 10561
 			date_default_timezone_set($globalTimezone);
10170 10562
 			$datetime = new DateTime();
10171 10563
 			$offset = $datetime->format('P');
10172
-		} else $offset = '+00:00';
10564
+		} else {
10565
+			$offset = '+00:00';
10566
+		}
10173 10567
 		$filter_query = $this->getFilter($filters,true,true);
10174 10568
 		if ($globalDBdriver == 'mysql') {
10175 10569
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -10218,7 +10612,9 @@  discard block
 block discarded – undo
10218 10612
 			date_default_timezone_set($globalTimezone);
10219 10613
 			$datetime = new DateTime();
10220 10614
 			$offset = $datetime->format('P');
10221
-		} else $offset = '+00:00';
10615
+		} else {
10616
+			$offset = '+00:00';
10617
+		}
10222 10618
 
10223 10619
 		$orderby_sql = '';
10224 10620
 		if ($orderby == "hour")
@@ -10284,7 +10680,9 @@  discard block
 block discarded – undo
10284 10680
 			date_default_timezone_set($globalTimezone);
10285 10681
 			$datetime = new DateTime();
10286 10682
 			$offset = $datetime->format('P');
10287
-		} else $offset = '+00:00';
10683
+		} else {
10684
+			$offset = '+00:00';
10685
+		}
10288 10686
 
10289 10687
 		$orderby_sql = '';
10290 10688
 		if ($orderby == "hour")
@@ -10351,7 +10749,9 @@  discard block
 block discarded – undo
10351 10749
 			date_default_timezone_set($globalTimezone);
10352 10750
 			$datetime = new DateTime();
10353 10751
 			$offset = $datetime->format('P');
10354
-		} else $offset = '+00:00';
10752
+		} else {
10753
+			$offset = '+00:00';
10754
+		}
10355 10755
 
10356 10756
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10357 10757
 
@@ -10402,7 +10802,9 @@  discard block
 block discarded – undo
10402 10802
 			date_default_timezone_set($globalTimezone);
10403 10803
 			$datetime = new DateTime();
10404 10804
 			$offset = $datetime->format('P');
10405
-		} else $offset = '+00:00';
10805
+		} else {
10806
+			$offset = '+00:00';
10807
+		}
10406 10808
 
10407 10809
 		if ($globalDBdriver == 'mysql') {
10408 10810
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10449,7 +10851,9 @@  discard block
 block discarded – undo
10449 10851
 			date_default_timezone_set($globalTimezone);
10450 10852
 			$datetime = new DateTime();
10451 10853
 			$offset = $datetime->format('P');
10452
-		} else $offset = '+00:00';
10854
+		} else {
10855
+			$offset = '+00:00';
10856
+		}
10453 10857
 
10454 10858
 		if ($globalDBdriver == 'mysql') {
10455 10859
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10496,7 +10900,9 @@  discard block
 block discarded – undo
10496 10900
 			date_default_timezone_set($globalTimezone);
10497 10901
 			$datetime = new DateTime();
10498 10902
 			$offset = $datetime->format('P');
10499
-		} else $offset = '+00:00';
10903
+		} else {
10904
+			$offset = '+00:00';
10905
+		}
10500 10906
 
10501 10907
 		if ($globalDBdriver == 'mysql') {
10502 10908
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10544,7 +10950,9 @@  discard block
 block discarded – undo
10544 10950
 			date_default_timezone_set($globalTimezone);
10545 10951
 			$datetime = new DateTime();
10546 10952
 			$offset = $datetime->format('P');
10547
-		} else $offset = '+00:00';
10953
+		} else {
10954
+			$offset = '+00:00';
10955
+		}
10548 10956
 
10549 10957
 		if ($globalDBdriver == 'mysql') {
10550 10958
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10592,7 +11000,9 @@  discard block
 block discarded – undo
10592 11000
 			date_default_timezone_set($globalTimezone);
10593 11001
 			$datetime = new DateTime($date);
10594 11002
 			$offset = $datetime->format('P');
10595
-		} else $offset = '+00:00';
11003
+		} else {
11004
+			$offset = '+00:00';
11005
+		}
10596 11006
 
10597 11007
 		if ($globalDBdriver == 'mysql') {
10598 11008
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10640,7 +11050,9 @@  discard block
 block discarded – undo
10640 11050
 			date_default_timezone_set($globalTimezone);
10641 11051
 			$datetime = new DateTime();
10642 11052
 			$offset = $datetime->format('P');
10643
-		} else $offset = '+00:00';
11053
+		} else {
11054
+			$offset = '+00:00';
11055
+		}
10644 11056
 
10645 11057
 		if ($globalDBdriver == 'mysql') {
10646 11058
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10687,7 +11099,9 @@  discard block
 block discarded – undo
10687 11099
 			date_default_timezone_set($globalTimezone);
10688 11100
 			$datetime = new DateTime();
10689 11101
 			$offset = $datetime->format('P');
10690
-		} else $offset = '+00:00';
11102
+		} else {
11103
+			$offset = '+00:00';
11104
+		}
10691 11105
 
10692 11106
 		if ($globalDBdriver == 'mysql') {
10693 11107
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10734,7 +11148,9 @@  discard block
 block discarded – undo
10734 11148
 			date_default_timezone_set($globalTimezone);
10735 11149
 			$datetime = new DateTime();
10736 11150
 			$offset = $datetime->format('P');
10737
-		} else $offset = '+00:00';
11151
+		} else {
11152
+			$offset = '+00:00';
11153
+		}
10738 11154
 
10739 11155
 		if ($globalDBdriver == 'mysql') {
10740 11156
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10784,7 +11200,9 @@  discard block
 block discarded – undo
10784 11200
 			date_default_timezone_set($globalTimezone);
10785 11201
 			$datetime = new DateTime();
10786 11202
 			$offset = $datetime->format('P');
10787
-		} else $offset = '+00:00';
11203
+		} else {
11204
+			$offset = '+00:00';
11205
+		}
10788 11206
 
10789 11207
 		if ($globalDBdriver == 'mysql') {
10790 11208
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10831,7 +11249,9 @@  discard block
 block discarded – undo
10831 11249
 			date_default_timezone_set($globalTimezone);
10832 11250
 			$datetime = new DateTime();
10833 11251
 			$offset = $datetime->format('P');
10834
-		} else $offset = '+00:00';
11252
+		} else {
11253
+			$offset = '+00:00';
11254
+		}
10835 11255
 
10836 11256
 		if ($globalDBdriver == 'mysql') {
10837 11257
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11042,8 +11462,11 @@  discard block
 block discarded – undo
11042 11462
 				$query_values = array_merge($query_values,array(':month' => $month));
11043 11463
 			}
11044 11464
 		}
11045
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11046
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11465
+		if (empty($query_values)) {
11466
+			$queryi .= $this->getFilter($filters);
11467
+		} else {
11468
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11469
+		}
11047 11470
 		
11048 11471
 		$sth = $this->db->prepare($queryi);
11049 11472
 		$sth->execute($query_values);
@@ -11121,8 +11544,11 @@  discard block
 block discarded – undo
11121 11544
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11545
 			}
11123 11546
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11547
+                if ($query == '') {
11548
+                	$queryi .= $this->getFilter($filters);
11549
+                } else {
11550
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11551
+                }
11126 11552
 
11127 11553
 
11128 11554
 		$sth = $this->db->prepare($queryi);
@@ -11145,7 +11571,9 @@  discard block
 block discarded – undo
11145 11571
 			date_default_timezone_set($globalTimezone);
11146 11572
 			$datetime = new DateTime();
11147 11573
 			$offset = $datetime->format('P');
11148
-		} else $offset = '+00:00';
11574
+		} else {
11575
+			$offset = '+00:00';
11576
+		}
11149 11577
 
11150 11578
 		if ($globalDBdriver == 'mysql') {
11151 11579
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11331,7 +11759,9 @@  discard block
 block discarded – undo
11331 11759
 	*/
11332 11760
 	public function parseDirection($direction = 0)
11333 11761
 	{
11334
-		if ($direction == '') $direction = 0;
11762
+		if ($direction == '') {
11763
+			$direction = 0;
11764
+		}
11335 11765
 		$direction_array = array();
11336 11766
 		$temp_array = array();
11337 11767
 
@@ -11432,7 +11862,9 @@  discard block
 block discarded – undo
11432 11862
 		if (isset($result->AirlineFlightInfoResult))
11433 11863
 		{
11434 11864
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11435
-		} else return '';
11865
+		} else {
11866
+			return '';
11867
+		}
11436 11868
 		
11437 11869
 		$registration = $this->convertAircraftRegistration($registration);
11438 11870
 		
@@ -11466,7 +11898,9 @@  discard block
 block discarded – undo
11466 11898
 		    return $row['registration'];
11467 11899
 		} elseif ($source_type == 'flarm') {
11468 11900
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469
-		} else return '';
11901
+		} else {
11902
+			return '';
11903
+		}
11470 11904
 	
11471 11905
 	}
11472 11906
 
@@ -11493,11 +11927,16 @@  discard block
 block discarded – undo
11493 11927
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11494 11928
 		$sth->closeCursor();
11495 11929
 		if (count($row) > 0) {
11496
-			if ($row['type_flight'] == null) return '';
11497
-			else return $row['type_flight'];
11930
+			if ($row['type_flight'] == null) {
11931
+				return '';
11932
+			} else {
11933
+				return $row['type_flight'];
11934
+			}
11498 11935
 		} elseif ($source_type == 'flarm') {
11499 11936
 			return $this->getAircraftTypeBymodeS($aircraft_modes);
11500
-		} else return '';
11937
+		} else {
11938
+			return '';
11939
+		}
11501 11940
 	
11502 11941
 	}
11503 11942
 
@@ -11515,7 +11954,9 @@  discard block
 block discarded – undo
11515 11954
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11516 11955
 	
11517 11956
 		$Connection = new Connection($this->db);
11518
-		if (!$Connection->tableExists('countries')) return '';
11957
+		if (!$Connection->tableExists('countries')) {
11958
+			return '';
11959
+		}
11519 11960
 	
11520 11961
 		try {
11521 11962
 			/*
@@ -11535,9 +11976,13 @@  discard block
 block discarded – undo
11535 11976
 			$sth->closeCursor();
11536 11977
 			if (count($row) > 0) {
11537 11978
 				return $row;
11538
-			} else return '';
11979
+			} else {
11980
+				return '';
11981
+			}
11539 11982
 		} catch (PDOException $e) {
11540
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11983
+			if (isset($globalDebug) && $globalDebug) {
11984
+				echo 'Error : '.$e->getMessage()."\n";
11985
+			}
11541 11986
 			return '';
11542 11987
 		}
11543 11988
 	
@@ -11555,7 +12000,9 @@  discard block
 block discarded – undo
11555 12000
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11556 12001
 	
11557 12002
 		$Connection = new Connection($this->db);
11558
-		if (!$Connection->tableExists('countries')) return '';
12003
+		if (!$Connection->tableExists('countries')) {
12004
+			return '';
12005
+		}
11559 12006
 	
11560 12007
 		try {
11561 12008
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11567,9 +12014,13 @@  discard block
 block discarded – undo
11567 12014
 			$sth->closeCursor();
11568 12015
 			if (count($row) > 0) {
11569 12016
 				return $row;
11570
-			} else return '';
12017
+			} else {
12018
+				return '';
12019
+			}
11571 12020
 		} catch (PDOException $e) {
11572
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
12021
+			if (isset($globalDebug) && $globalDebug) {
12022
+				echo 'Error : '.$e->getMessage()."\n";
12023
+			}
11573 12024
 			return '';
11574 12025
 		}
11575 12026
 	
@@ -11819,7 +12270,9 @@  discard block
 block discarded – undo
11819 12270
 	{
11820 12271
 		global $globalBitlyAccessToken;
11821 12272
 		
11822
-		if ($globalBitlyAccessToken == '') return $url;
12273
+		if ($globalBitlyAccessToken == '') {
12274
+			return $url;
12275
+		}
11823 12276
         
11824 12277
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11825 12278
 		
@@ -11968,7 +12421,9 @@  discard block
 block discarded – undo
11968 12421
 		
11969 12422
 
11970 12423
 		// routes
11971
-		if ($globalDebug) print "Routes...\n";
12424
+		if ($globalDebug) {
12425
+			print "Routes...\n";
12426
+		}
11972 12427
 		if ($globalDBdriver == 'mysql') {
11973 12428
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
11974 12429
 		} else {
@@ -11987,7 +12442,9 @@  discard block
 block discarded – undo
11987 12442
 			}
11988 12443
 		}
11989 12444
 		
11990
-		if ($globalDebug) print "Airlines...\n";
12445
+		if ($globalDebug) {
12446
+			print "Airlines...\n";
12447
+		}
11991 12448
 		//airlines
11992 12449
 		if ($globalDBdriver == 'mysql') {
11993 12450
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -12001,10 +12458,15 @@  discard block
 block discarded – undo
12001 12458
 			if (is_numeric(substr($row['ident'], -1, 1)))
12002 12459
 			{
12003 12460
 				$fromsource = NULL;
12004
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
12005
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12006
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12007
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12461
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12462
+					$fromsource = 'vatsim';
12463
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12464
+					$fromsource = 'ivao';
12465
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12466
+					$fromsource = 'vatsim';
12467
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12468
+					$fromsource = 'ivao';
12469
+				}
12008 12470
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12009 12471
 				if (isset($airline_array[0]['name'])) {
12010 12472
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -12014,13 +12476,17 @@  discard block
 block discarded – undo
12014 12476
 			}
12015 12477
 		}
12016 12478
 
12017
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12479
+		if ($globalDebug) {
12480
+			print "Remove Duplicate in aircraft_modes...\n";
12481
+		}
12018 12482
 		//duplicate modes
12019 12483
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
12020 12484
 		$sth = $this->db->prepare($query);
12021 12485
 		$sth->execute();
12022 12486
 		
12023
-		if ($globalDebug) print "Aircraft...\n";
12487
+		if ($globalDebug) {
12488
+			print "Aircraft...\n";
12489
+		}
12024 12490
 		//aircraft
12025 12491
 		if ($globalDBdriver == 'mysql') {
12026 12492
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -12063,26 +12529,38 @@  discard block
 block discarded – undo
12063 12529
 				 if (isset($closestAirports[0])) {
12064 12530
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
12065 12531
 						$airport_icao = $closestAirports[0]['icao'];
12066
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12532
+						if ($globalDebug) {
12533
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12534
+						}
12067 12535
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
12068 12536
 						foreach ($closestAirports as $airport) {
12069 12537
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
12070 12538
 								$airport_icao = $airport['icao'];
12071
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12539
+								if ($globalDebug) {
12540
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12541
+								}
12072 12542
 								break;
12073 12543
 							}
12074 12544
 						}
12075 12545
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12076 12546
 						$airport_icao = $closestAirports[0]['icao'];
12077
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12547
+						if ($globalDebug) {
12548
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12549
+						}
12078 12550
 					} else {
12079
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12551
+						if ($globalDebug) {
12552
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12553
+						}
12080 12554
 					}
12081 12555
 				} else {
12082
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12556
+					if ($globalDebug) {
12557
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12558
+					}
12083 12559
 				}
12084 12560
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12085
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12561
+					if ($globalDebug) {
12562
+						echo "Updating airport to ".$airport_icao."...\n";
12563
+					}
12086 12564
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12087 12565
 					$sthu = $this->db->prepare($update_query);
12088 12566
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.MarineImport.php 3 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class MarineImport {
12
-    private $all_tracked = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
12
+	private $all_tracked = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20 20
 
21
-    public function __construct($dbc = null) {
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -40,50 +40,50 @@  discard block
 block discarded – undo
40 40
 	    }
41 41
 	}
42 42
 	*/
43
-    }
43
+	}
44 44
 
45
-    public function checkAll() {
45
+	public function checkAll() {
46 46
 	global $globalDebug;
47 47
 	if ($globalDebug) echo "Update last seen tracked data...\n";
48 48
 	foreach ($this->all_tracked as $key => $flight) {
49
-	    if (isset($this->all_tracked[$key]['id'])) {
49
+		if (isset($this->all_tracked[$key]['id'])) {
50 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
51
-    		$Marine = new Marine($this->db);
52
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
-            }
51
+			$Marine = new Marine($this->db);
52
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
+			}
54
+	}
54 55
 	}
55
-    }
56 56
 
57
-    public function del() {
57
+	public function del() {
58 58
 	global $globalDebug;
59 59
 	// Delete old infos
60 60
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
61 61
 	foreach ($this->all_tracked as $key => $flight) {
62
-    	    if (isset($flight['lastupdate'])) {
63
-        	if ($flight['lastupdate'] < (time()-3000)) {
64
-            	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
62
+			if (isset($flight['lastupdate'])) {
63
+			if ($flight['lastupdate'] < (time()-3000)) {
64
+					if (isset($this->all_tracked[$key]['id'])) {
65
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
66 66
 			/*
67 67
 			$MarineLive = new MarineLive();
68 68
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
69 69
 			$MarineLive->db = null;
70 70
 			*/
71
-            		//$real_arrival = $this->arrival($key);
72
-            		$Marine = new Marine($this->db);
73
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
71
+					//$real_arrival = $this->arrival($key);
72
+					$Marine = new Marine($this->db);
73
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 74
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
75 75
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
76 76
 			}
77 77
 			// Put in archive
78 78
 //			$Marine->db = null;
79
-            	    }
80
-            	    unset($this->all_tracked[$key]);
81
-    	        }
82
-	    }
83
-        }
84
-    }
79
+					}
80
+					unset($this->all_tracked[$key]);
81
+				}
82
+		}
83
+		}
84
+	}
85 85
 
86
-    public function add($line) {
86
+	public function add($line) {
87 87
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88 88
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
89 89
 	date_default_timezone_set('UTC');
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	
93 93
 	// SBS format is CSV format
94 94
 	if(is_array($line) && isset($line['mmsi'])) {
95
-	    //print_r($line);
96
-  	    if (isset($line['mmsi'])) {
95
+		//print_r($line);
96
+  		if (isset($line['mmsi'])) {
97 97
 
98 98
 		/*
99 99
 		// Increment message number
@@ -109,69 +109,69 @@  discard block
 block discarded – undo
109 109
 		*/
110 110
 		
111 111
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
113
-	        else $id = trim($line['id']);
112
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
113
+			else $id = trim($line['id']);
114 114
 		
115 115
 		if (!isset($this->all_tracked[$id])) {
116
-		    $this->all_tracked[$id] = array();
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','type' => '','status' => ''));
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
-		    if (!isset($line['id'])) {
116
+			$this->all_tracked[$id] = array();
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','type' => '','status' => ''));
119
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
+			if (!isset($line['id'])) {
121 121
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
122 122
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
123
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
+			if ($globalAllTracked !== FALSE) $dataFound = true;
125 125
 		}
126 126
 		
127 127
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
128
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
129
-		    $Marine = new Marine($this->db);
130
-		    $identity = $Marine->getIdentity($line['mmsi']);
131
-		    if (!empty($identity)) {
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
129
+			$Marine = new Marine($this->db);
130
+			$identity = $Marine->getIdentity($line['mmsi']);
131
+			if (!empty($identity)) {
132 132
 			$this->all_tracked[$id]['ident'] = $identity['ship_name'];
133 133
 			$this->all_tracked[$id]['type'] = $identity['type'];
134
-		    }
135
-		    //print_r($identity);
136
-		    unset($Marine);
137
-		    //$dataFound = true;
134
+			}
135
+			//print_r($identity);
136
+			unset($Marine);
137
+			//$dataFound = true;
138 138
 		}
139 139
 
140 140
 
141 141
 		//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'])) {
142 142
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
144
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
144
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
145 145
 			$timeelapsed = microtime(true);
146
-            		$Marine = new Marine($this->db);
147
-            		$fromsource = NULL;
148
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
146
+					$Marine = new Marine($this->db);
147
+					$fromsource = NULL;
148
+					$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
149 149
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
150 150
 			$Marine->db = null;
151 151
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
152
-		    }
153
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
152
+			}
153
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
154 154
 		}
155 155
 
156 156
 		if (isset($line['speed']) && $line['speed'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
159 159
 		} 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'])) {
160
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
161
-		    if ($distance > 1000 && $distance < 10000) {
160
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
161
+			if ($distance > 1000 && $distance < 10000) {
162 162
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
163 163
 			$speed = $speed*3.6;
164 164
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
165 165
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
166
-		    }
166
+			}
167 167
 		}
168 168
 
169
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
170
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
171
-	    	    else unset($timediff);
172
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($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')))) {
169
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
170
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
171
+				else unset($timediff);
172
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($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')))) {
173 173
 			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'])) {
174
-			    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'])) {
174
+				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'])) {
175 175
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
176 176
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
177 177
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -185,76 +185,76 @@  discard block
 block discarded – undo
185 185
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
186 186
 				$this->tmd = 0;
187 187
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
188
-			    }
188
+				}
189 189
 			}
190 190
 
191 191
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
192 192
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
193 193
 				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') {
194
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
195
-				    $dataFound = true;
196
-				    $this->all_tracked[$id]['time_last_coord'] = time();
194
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
195
+					$dataFound = true;
196
+					$this->all_tracked[$id]['time_last_coord'] = time();
197 197
 				}
198 198
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
199 199
 			}
200 200
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
201
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
201
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
202 202
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
203 203
 				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') {
204
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
205
-				    $dataFound = true;
206
-				    $this->all_tracked[$id]['time_last_coord'] = time();
204
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
205
+					$dataFound = true;
206
+					$this->all_tracked[$id]['time_last_coord'] = time();
207 207
 				}
208 208
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
209 209
 			}
210 210
 
211
-		    } else if ($globalDebug && $timediff > 20) {
211
+			} else if ($globalDebug && $timediff > 20) {
212 212
 			$this->tmd = $this->tmd + 1;
213 213
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
214 214
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
215 215
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
216 216
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
217
-		    }
217
+			}
218 218
 		}
219 219
 		if (isset($line['last_update']) && $line['last_update'] != '') {
220
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
221
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
220
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
221
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
222 222
 		}
223 223
 		if (isset($line['format_source']) && $line['format_source'] != '') {
224
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
224
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
225 225
 		}
226 226
 		if (isset($line['source_name']) && $line['source_name'] != '') {
227
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
227
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
228 228
 		}
229 229
 		if (isset($line['status']) && $line['status'] != '') {
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
231 231
 		}
232 232
 
233 233
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
234
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
234
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
235 235
 		}
236 236
 		
237 237
 		if (isset($line['heading']) && $line['heading'] != '') {
238
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
240
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
241
-		    //$dataFound = true;
238
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
240
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
241
+			//$dataFound = true;
242 242
   		} 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']) {
243
-  		    $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']);
244
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
245
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
246
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
243
+  			$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']);
244
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
245
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
246
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
247 247
   		}
248 248
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
249 249
 
250 250
 		if (isset($line['datetime'])) {
251
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
251
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
252 252
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
253
-		    } else {
253
+			} else {
254 254
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
255 255
 				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]['hex']." - format : ".$line['format_source']."\n";
256 256
 				return '';
257
-		    }
257
+			}
258 258
 		} else {
259 259
 			date_default_timezone_set('UTC');
260 260
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -262,45 +262,45 @@  discard block
 block discarded – undo
262 262
 
263 263
 
264 264
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
265
-		    $this->all_tracked[$id]['lastupdate'] = time();
266
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
267
-		        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'])) {
268
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
265
+			$this->all_tracked[$id]['lastupdate'] = time();
266
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
267
+				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'])) {
268
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
269 269
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
270 270
 				$timeelapsed = microtime(true);
271 271
 				$MarineLive = new MarineLive($this->db);
272 272
 				if (isset($line['id'])) {
273
-				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
274
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
273
+					$recent_ident = $MarineLive->checkIdRecent($line['id']);
274
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
275 275
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
276
-				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
277
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
276
+					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
277
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
278 278
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
279
-				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
279
+					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
280
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281 281
 				} else $recent_ident = '';
282 282
 				$MarineLive->db=null;
283 283
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
284 284
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
285
-			    } else {
285
+				} else {
286 286
 				$recent_ident = '';
287 287
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
288
-			    }
289
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
290
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
291
-			    {
288
+				}
289
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
290
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
291
+				{
292 292
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
293 293
 				//adds the spotter data for the archive
294
-				    $highlight = '';
295
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
296
-				    $timeelapsed = microtime(true);
297
-				    $Marine = new Marine($this->db);
298
-				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
299
-				    $Marine->db = null;
300
-				    if ($globalDebug && isset($result)) echo $result."\n";
301
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+					$highlight = '';
295
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
296
+					$timeelapsed = microtime(true);
297
+					$Marine = new Marine($this->db);
298
+					$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
299
+					$Marine->db = null;
300
+					if ($globalDebug && isset($result)) echo $result."\n";
301
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302 302
 				    
303
-				    /*
303
+					/*
304 304
 				    // Add source stat in DB
305 305
 				    $Stats = new Stats($this->db);
306 306
 				    if (!empty($this->stats)) {
@@ -327,20 +327,20 @@  discard block
 block discarded – undo
327 327
 				    }
328 328
 				    $Stats->db = null;
329 329
 				    */
330
-				    $this->del();
330
+					$this->del();
331 331
 				//$ignoreImport = false;
332 332
 				$this->all_tracked[$id]['addedMarine'] = 1;
333 333
 				//print_r($this->all_tracked[$id]);
334 334
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
335
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
336
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
337
-				    $MarineLive = new MarineLive($this->db);
338
-				    $MarineLive->deleteLiveMarineData();
339
-				    $MarineLive->db=null;
340
-				    if ($globalDebug) echo " Done\n";
341
-				    $this->last_delete = time();
335
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
336
+					//MarineLive->deleteLiveMarineDataNotUpdated();
337
+					$MarineLive = new MarineLive($this->db);
338
+					$MarineLive->deleteLiveMarineData();
339
+					$MarineLive->db=null;
340
+					if ($globalDebug) echo " Done\n";
341
+					$this->last_delete = time();
342 342
 				}
343
-			    } elseif ($recent_ident != '') {
343
+				} elseif ($recent_ident != '') {
344 344
 				$this->all_tracked[$id]['id'] = $recent_ident;
345 345
 				$this->all_tracked[$id]['addedMarine'] = 1;
346 346
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
 					$Marine->db = null;
350 350
 				}
351 351
 				
352
-			    }
352
+				}
353
+			}
353 354
 			}
354
-		    }
355
-		    //adds the spotter LIVE data
356
-		    if ($globalDebug) {
355
+			//adds the spotter LIVE data
356
+			if ($globalDebug) {
357 357
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
358
-		    }
359
-		    $ignoreImport = false;
358
+			}
359
+			$ignoreImport = false;
360 360
 
361
-		    if (!$ignoreImport) {
361
+			if (!$ignoreImport) {
362 362
 			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'])) {
363 363
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
364 364
 				$timeelapsed = microtime(true);
@@ -430,22 +430,22 @@  discard block
 block discarded – undo
430 430
 			
431 431
 			
432 432
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
433
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
434
-			    $MarineLive = new MarineLive($this->db);
435
-			    $MarineLive->deleteLiveMarineDataNotUpdated();
436
-			    $MarineLive->db = null;
437
-			    //MarineLive->deleteLiveMarineData();
438
-			    if ($globalDebug) echo " Done\n";
439
-			    $this->last_delete_hourly = time();
433
+				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
434
+				$MarineLive = new MarineLive($this->db);
435
+				$MarineLive->deleteLiveMarineDataNotUpdated();
436
+				$MarineLive->db = null;
437
+				//MarineLive->deleteLiveMarineData();
438
+				if ($globalDebug) echo " Done\n";
439
+				$this->last_delete_hourly = time();
440 440
 			}
441 441
 			
442
-		    }
443
-		    //$ignoreImport = false;
442
+			}
443
+			//$ignoreImport = false;
444 444
 		}
445 445
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
446 446
 		if ($send) return $this->all_tracked[$id];
447
-	    }
447
+		}
448
+	}
448 449
 	}
449
-    }
450 450
 }
451 451
 ?>
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	    if (isset($this->all_tracked[$key]['id'])) {
50 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
51 51
     		$Marine = new Marine($this->db);
52
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
52
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
53 53
             }
54 54
 	}
55 55
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
61 61
 	foreach ($this->all_tracked as $key => $flight) {
62 62
     	    if (isset($flight['lastupdate'])) {
63
-        	if ($flight['lastupdate'] < (time()-3000)) {
63
+        	if ($flight['lastupdate'] < (time() - 3000)) {
64 64
             	    if (isset($this->all_tracked[$key]['id'])) {
65 65
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
66 66
 			/*
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             		//$real_arrival = $this->arrival($key);
72 72
             		$Marine = new Marine($this->db);
73 73
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
74
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']);
75 75
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
76 76
 			}
77 77
 			// Put in archive
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	$send = false;
92 92
 	
93 93
 	// SBS format is CSV format
94
-	if(is_array($line) && isset($line['mmsi'])) {
94
+	if (is_array($line) && isset($line['mmsi'])) {
95 95
 	    //print_r($line);
96 96
   	    if (isset($line['mmsi'])) {
97 97
 
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 		
115 115
 		if (!isset($this->all_tracked[$id])) {
116 116
 		    $this->all_tracked[$id] = array();
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','type' => '','status' => ''));
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'type' => '', 'status' => ''));
119
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
120 120
 		    if (!isset($line['id'])) {
121 121
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
122
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
123
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
124 124
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
125 125
 		}
126 126
 		
127 127
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
128
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
128
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
129 129
 		    $Marine = new Marine($this->db);
130 130
 		    $identity = $Marine->getIdentity($line['mmsi']);
131 131
 		    if (!empty($identity)) {
@@ -140,38 +140,38 @@  discard block
 block discarded – undo
140 140
 
141 141
 		//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'])) {
142 142
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
143
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
144 144
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
145 145
 			$timeelapsed = microtime(true);
146 146
             		$Marine = new Marine($this->db);
147 147
             		$fromsource = NULL;
148
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
148
+            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
149 149
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
150 150
 			$Marine->db = null;
151
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
151
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
152 152
 		    }
153
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
153
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
154 154
 		}
155 155
 
156 156
 		if (isset($line['speed']) && $line['speed'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
158
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
159 159
 		} 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'])) {
160
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
160
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
161 161
 		    if ($distance > 1000 && $distance < 10000) {
162 162
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
163 163
 			$speed = $speed*3.6;
164
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
164
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
165 165
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
166 166
 		    }
167 167
 		}
168 168
 
169 169
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
170
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
170
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
171 171
 	    	    else unset($timediff);
172
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($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')))) {
172
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($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')))) {
173 173
 			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'])) {
174
-			    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'])) {
174
+			    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'])) {
175 175
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
176 176
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
177 177
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
180 180
 				$timeelapsed = microtime(true);
181 181
 				$Marine = new Marine($this->db);
182
-				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
182
+				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
183 183
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
184 184
 				$Marine->db = null;
185
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
185
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
186 186
 				$this->tmd = 0;
187 187
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
188 188
 			    }
@@ -190,66 +190,66 @@  discard block
 block discarded – undo
190 190
 
191 191
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
192 192
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
193
-				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') {
193
+				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') {
194 194
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
195 195
 				    $dataFound = true;
196 196
 				    $this->all_tracked[$id]['time_last_coord'] = time();
197 197
 				}
198
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
198
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
199 199
 			}
200 200
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
201 201
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
202 202
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
203
-				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') {
203
+				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') {
204 204
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
205 205
 				    $dataFound = true;
206 206
 				    $this->all_tracked[$id]['time_last_coord'] = time();
207 207
 				}
208
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
208
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
209 209
 			}
210 210
 
211 211
 		    } else if ($globalDebug && $timediff > 20) {
212 212
 			$this->tmd = $this->tmd + 1;
213 213
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
214
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
215
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
214
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
215
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
216 216
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
217 217
 		    }
218 218
 		}
219 219
 		if (isset($line['last_update']) && $line['last_update'] != '') {
220 220
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
221
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
221
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
222 222
 		}
223 223
 		if (isset($line['format_source']) && $line['format_source'] != '') {
224
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
224
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
225 225
 		}
226 226
 		if (isset($line['source_name']) && $line['source_name'] != '') {
227
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
227
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
228 228
 		}
229 229
 		if (isset($line['status']) && $line['status'] != '') {
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
231 231
 		}
232 232
 
233 233
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
234
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
234
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
235 235
 		}
236 236
 		
237 237
 		if (isset($line['heading']) && $line['heading'] != '') {
238
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
240
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
238
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
240
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
241 241
 		    //$dataFound = true;
242 242
   		} 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']) {
243
-  		    $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']);
244
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
245
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
243
+  		    $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']);
244
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
245
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
246 246
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
247 247
   		}
248 248
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
249 249
 
250 250
 		if (isset($line['datetime'])) {
251 251
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
252
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
252
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
253 253
 		    } else {
254 254
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
255 255
 				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]['hex']." - format : ".$line['format_source']."\n";
@@ -257,48 +257,48 @@  discard block
 block discarded – undo
257 257
 		    }
258 258
 		} else {
259 259
 			date_default_timezone_set('UTC');
260
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
260
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
261 261
 		}
262 262
 
263 263
 
264 264
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
265 265
 		    $this->all_tracked[$id]['lastupdate'] = time();
266 266
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
267
-		        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'])) {
267
+		        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'])) {
268 268
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
269 269
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
270 270
 				$timeelapsed = microtime(true);
271 271
 				$MarineLive = new MarineLive($this->db);
272 272
 				if (isset($line['id'])) {
273 273
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
274
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
274
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
275 275
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
276 276
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
277
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
277
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
278 278
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
279 279
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
280
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
281 281
 				} else $recent_ident = '';
282
-				$MarineLive->db=null;
282
+				$MarineLive->db = null;
283 283
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
284 284
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
285 285
 			    } else {
286 286
 				$recent_ident = '';
287
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
287
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
288 288
 			    }
289 289
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
290
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
290
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
291 291
 			    {
292 292
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
293 293
 				//adds the spotter data for the archive
294 294
 				    $highlight = '';
295
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
295
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
296 296
 				    $timeelapsed = microtime(true);
297 297
 				    $Marine = new Marine($this->db);
298
-				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
298
+				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
299 299
 				    $Marine->db = null;
300 300
 				    if ($globalDebug && isset($result)) echo $result."\n";
301
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
302 302
 				    
303 303
 				    /*
304 304
 				    // Add source stat in DB
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
337 337
 				    $MarineLive = new MarineLive($this->db);
338 338
 				    $MarineLive->deleteLiveMarineData();
339
-				    $MarineLive->db=null;
339
+				    $MarineLive->db = null;
340 340
 				    if ($globalDebug) echo " Done\n";
341 341
 				    $this->last_delete = time();
342 342
 				}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				$this->all_tracked[$id]['addedMarine'] = 1;
346 346
 				if (isset($globalDaemon) && !$globalDaemon) {
347 347
 					$Marine = new Marine($this->db);
348
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
348
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
349 349
 					$Marine->db = null;
350 350
 				}
351 351
 				
@@ -359,14 +359,14 @@  discard block
 block discarded – undo
359 359
 		    $ignoreImport = false;
360 360
 
361 361
 		    if (!$ignoreImport) {
362
-			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'])) {
362
+			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'])) {
363 363
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
364 364
 				$timeelapsed = microtime(true);
365 365
 				$MarineLive = new MarineLive($this->db);
366
-				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
366
+				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
367 367
 				$MarineLive->db = null;
368 368
 				$this->all_tracked[$id]['putinarchive'] = false;
369
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
370 370
 
371 371
 				// Put statistics in $this->stats variable
372 372
 				/*
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 				$this->all_tracked[$id]['lastupdate'] = time();
426 426
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
427 427
 				if ($globalDebug) echo $result."\n";
428
-			} 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";
428
+			} 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";
429 429
 			//$this->del();
430 430
 			
431 431
 			
Please login to merge, or discard this patch.
Braces   +149 added lines, -51 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function checkAll() {
46 46
 	global $globalDebug;
47
-	if ($globalDebug) echo "Update last seen tracked data...\n";
47
+	if ($globalDebug) {
48
+		echo "Update last seen tracked data...\n";
49
+	}
48 50
 	foreach ($this->all_tracked as $key => $flight) {
49 51
 	    if (isset($this->all_tracked[$key]['id'])) {
50 52
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -57,12 +59,16 @@  discard block
 block discarded – undo
57 59
     public function del() {
58 60
 	global $globalDebug;
59 61
 	// Delete old infos
60
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Delete old values and update latest data...'."\n";
64
+	}
61 65
 	foreach ($this->all_tracked as $key => $flight) {
62 66
     	    if (isset($flight['lastupdate'])) {
63 67
         	if ($flight['lastupdate'] < (time()-3000)) {
64 68
             	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		if ($globalDebug) {
70
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
71
+            		}
66 72
 			/*
67 73
 			$MarineLive = new MarineLive();
68 74
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -72,7 +78,9 @@  discard block
 block discarded – undo
72 78
             		$Marine = new Marine($this->db);
73 79
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 80
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
75
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
81
+				if ($globalDebug && $result != 'success') {
82
+					echo '!!! ERROR : '.$result."\n";
83
+				}
76 84
 			}
77 85
 			// Put in archive
78 86
 //			$Marine->db = null;
@@ -85,7 +93,9 @@  discard block
 block discarded – undo
85 93
 
86 94
     public function add($line) {
87 95
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
96
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
97
+		$globalCoordMinChange = '0.02';
98
+	}
89 99
 	date_default_timezone_set('UTC');
90 100
 	$dataFound = false;
91 101
 	$send = false;
@@ -109,8 +119,11 @@  discard block
 block discarded – undo
109 119
 		*/
110 120
 		
111 121
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
113
-	        else $id = trim($line['id']);
122
+	        if (!isset($line['id'])) {
123
+	        	$id = trim($line['mmsi']);
124
+	        } else {
125
+	        	$id = trim($line['id']);
126
+	        }
114 127
 		
115 128
 		if (!isset($this->all_tracked[$id])) {
116 129
 		    $this->all_tracked[$id] = array();
@@ -118,10 +131,16 @@  discard block
 block discarded – undo
118 131
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','type' => '','status' => ''));
119 132
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120 133
 		    if (!isset($line['id'])) {
121
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
+			if (!isset($globalDaemon)) {
135
+				$globalDaemon = TRUE;
136
+			}
122 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+		     } else {
139
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
140
+		     }
141
+		    if ($globalAllTracked !== FALSE) {
142
+		    	$dataFound = true;
143
+		    }
125 144
 		}
126 145
 		
127 146
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -146,11 +165,17 @@  discard block
 block discarded – undo
146 165
             		$Marine = new Marine($this->db);
147 166
             		$fromsource = NULL;
148 167
             		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
149
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
168
+			if ($globalDebug && $result != 'success') {
169
+				echo '!!! ERROR : '.$result."\n";
170
+			}
150 171
 			$Marine->db = null;
151
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
172
+			if ($globalDebugTimeElapsed) {
173
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
174
+			}
175
+		    }
176
+		    if (!isset($this->all_tracked[$id]['id'])) {
177
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
152 178
 		    }
153
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
154 179
 		}
155 180
 
156 181
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -161,14 +186,21 @@  discard block
 block discarded – undo
161 186
 		    if ($distance > 1000 && $distance < 10000) {
162 187
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
163 188
 			$speed = $speed*3.6;
164
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
165
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
189
+			if ($speed < 1000) {
190
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
191
+			}
192
+  			if ($globalDebug) {
193
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
194
+  			}
166 195
 		    }
167 196
 		}
168 197
 
169 198
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
170
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
171
-	    	    else unset($timediff);
199
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
200
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
201
+	    	    } else {
202
+	    	    	unset($timediff);
203
+	    	    }
172 204
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($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')))) {
173 205
 			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'])) {
174 206
 			    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'])) {
@@ -176,20 +208,30 @@  discard block
 block discarded – undo
176 208
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
177 209
 				$this->all_tracked[$id]['putinarchive'] = true;
178 210
 				
179
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
211
+				if ($globalDebug) {
212
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
213
+				}
180 214
 				$timeelapsed = microtime(true);
181 215
 				$Marine = new Marine($this->db);
182 216
 				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
183
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
217
+				if (!empty($all_country)) {
218
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
219
+				}
184 220
 				$Marine->db = null;
185
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
221
+				if ($globalDebugTimeElapsed) {
222
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
223
+				}
186 224
 				$this->tmd = 0;
187
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
225
+				if ($globalDebug) {
226
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
227
+				}
188 228
 			    }
189 229
 			}
190 230
 
191 231
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
192
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
232
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
233
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
234
+				}
193 235
 				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') {
194 236
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
195 237
 				    $dataFound = true;
@@ -198,8 +240,12 @@  discard block
 block discarded – undo
198 240
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
199 241
 			}
200 242
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
201
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
202
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
243
+			    if ($line['longitude'] > 180) {
244
+			    	$line['longitude'] = $line['longitude'] - 360;
245
+			    }
246
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
247
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
248
+				}
203 249
 				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') {
204 250
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
205 251
 				    $dataFound = true;
@@ -217,7 +263,9 @@  discard block
 block discarded – undo
217 263
 		    }
218 264
 		}
219 265
 		if (isset($line['last_update']) && $line['last_update'] != '') {
220
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
266
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
267
+		    	$dataFound = true;
268
+		    }
221 269
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
222 270
 		}
223 271
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -235,15 +283,21 @@  discard block
 block discarded – undo
235 283
 		}
236 284
 		
237 285
 		if (isset($line['heading']) && $line['heading'] != '') {
238
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
286
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
287
+		    	$this->all_tracked[$id]['putinarchive'] = true;
288
+		    }
239 289
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
240 290
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
241 291
 		    //$dataFound = true;
242 292
   		} 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']) {
243 293
   		    $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']);
244 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
245
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
246
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
295
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
296
+		    	$this->all_tracked[$id]['putinarchive'] = true;
297
+		    }
298
+  		    if ($globalDebug) {
299
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
300
+  		    }
247 301
   		}
248 302
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
249 303
 
@@ -251,8 +305,11 @@  discard block
 block discarded – undo
251 305
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
252 306
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
253 307
 		    } else {
254
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
255
-				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]['hex']." - format : ".$line['format_source']."\n";
308
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
309
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
310
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
311
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
312
+				}
256 313
 				return '';
257 314
 		    }
258 315
 		} else {
@@ -266,22 +323,35 @@  discard block
 block discarded – undo
266 323
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
267 324
 		        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'])) {
268 325
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
269
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
326
+				if ($globalDebug) {
327
+					echo "Check if aircraft is already in DB...";
328
+				}
270 329
 				$timeelapsed = microtime(true);
271 330
 				$MarineLive = new MarineLive($this->db);
272 331
 				if (isset($line['id'])) {
273 332
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
274
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
333
+				    if ($globalDebugTimeElapsed) {
334
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
335
+				    }
275 336
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
276 337
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
277
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
338
+				    if ($globalDebugTimeElapsed) {
339
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
340
+				    }
278 341
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
279 342
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281
-				} else $recent_ident = '';
343
+				    if ($globalDebugTimeElapsed) {
344
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345
+				    }
346
+				} else {
347
+					$recent_ident = '';
348
+				}
282 349
 				$MarineLive->db=null;
283
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
284
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
350
+				if ($globalDebug && $recent_ident == '') {
351
+					echo " Not in DB.\n";
352
+				} elseif ($globalDebug && $recent_ident != '') {
353
+					echo " Already in DB.\n";
354
+				}
285 355
 			    } else {
286 356
 				$recent_ident = '';
287 357
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -289,16 +359,24 @@  discard block
 block discarded – undo
289 359
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
290 360
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
291 361
 			    {
292
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
362
+				if ($globalDebug) {
363
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
364
+				}
293 365
 				//adds the spotter data for the archive
294 366
 				    $highlight = '';
295
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
367
+				    if (!isset($this->all_tracked[$id]['id'])) {
368
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
369
+				    }
296 370
 				    $timeelapsed = microtime(true);
297 371
 				    $Marine = new Marine($this->db);
298 372
 				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
299 373
 				    $Marine->db = null;
300
-				    if ($globalDebug && isset($result)) echo $result."\n";
301
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+				    if ($globalDebug && isset($result)) {
375
+				    	echo $result."\n";
376
+				    }
377
+				    if ($globalDebugTimeElapsed) {
378
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
379
+				    }
302 380
 				    
303 381
 				    /*
304 382
 				    // Add source stat in DB
@@ -332,12 +410,16 @@  discard block
 block discarded – undo
332 410
 				$this->all_tracked[$id]['addedMarine'] = 1;
333 411
 				//print_r($this->all_tracked[$id]);
334 412
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
335
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
413
+				    if ($globalDebug) {
414
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
415
+				    }
336 416
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
337 417
 				    $MarineLive = new MarineLive($this->db);
338 418
 				    $MarineLive->deleteLiveMarineData();
339 419
 				    $MarineLive->db=null;
340
-				    if ($globalDebug) echo " Done\n";
420
+				    if ($globalDebug) {
421
+				    	echo " Done\n";
422
+				    }
341 423
 				    $this->last_delete = time();
342 424
 				}
343 425
 			    } elseif ($recent_ident != '') {
@@ -360,13 +442,17 @@  discard block
 block discarded – undo
360 442
 
361 443
 		    if (!$ignoreImport) {
362 444
 			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'])) {
363
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
445
+				if ($globalDebug) {
446
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
447
+				}
364 448
 				$timeelapsed = microtime(true);
365 449
 				$MarineLive = new MarineLive($this->db);
366 450
 				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
367 451
 				$MarineLive->db = null;
368 452
 				$this->all_tracked[$id]['putinarchive'] = false;
369
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+				if ($globalDebugTimeElapsed) {
454
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
+				}
370 456
 
371 457
 				// Put statistics in $this->stats variable
372 458
 				/*
@@ -423,19 +509,29 @@  discard block
 block discarded – undo
423 509
 				*/
424 510
 
425 511
 				$this->all_tracked[$id]['lastupdate'] = time();
426
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
427
-				if ($globalDebug) echo $result."\n";
428
-			} 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";
512
+				if ($this->all_tracked[$id]['putinarchive']) {
513
+					$send = true;
514
+				}
515
+				if ($globalDebug) {
516
+					echo $result."\n";
517
+				}
518
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
519
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
520
+			}
429 521
 			//$this->del();
430 522
 			
431 523
 			
432 524
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
433
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
525
+			    if ($globalDebug) {
526
+			    	echo "---- Deleting Live Marine data Not updated since 2 hour...";
527
+			    }
434 528
 			    $MarineLive = new MarineLive($this->db);
435 529
 			    $MarineLive->deleteLiveMarineDataNotUpdated();
436 530
 			    $MarineLive->db = null;
437 531
 			    //MarineLive->deleteLiveMarineData();
438
-			    if ($globalDebug) echo " Done\n";
532
+			    if ($globalDebug) {
533
+			    	echo " Done\n";
534
+			    }
439 535
 			    $this->last_delete_hourly = time();
440 536
 			}
441 537
 			
@@ -443,7 +539,9 @@  discard block
 block discarded – undo
443 539
 		    //$ignoreImport = false;
444 540
 		}
445 541
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
446
-		if ($send) return $this->all_tracked[$id];
542
+		if ($send) {
543
+			return $this->all_tracked[$id];
544
+		}
447 545
 	    }
448 546
 	}
449 547
     }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    public function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+	public function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -60,42 +60,42 @@  discard block
 block discarded – undo
60 60
 	$operator = $Spotter->getOperator($ident);
61 61
 	$scheduleexist = false;
62 62
 	if ($Schedule->checkSchedule($operator) == 0) {
63
-	    $operator = $Translation->checkTranslation($ident);
64
-	    if ($Schedule->checkSchedule($operator) == 0) {
63
+		$operator = $Translation->checkTranslation($ident);
64
+		if ($Schedule->checkSchedule($operator) == 0) {
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70
-		    // Should also check if route schedule = route from DB
71
-		    if ($schedule['DepartureAirportIATA'] != '') {
67
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70
+			// Should also check if route schedule = route from DB
71
+			if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
73
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74
-			    if (trim($airport_icao) != '') {
73
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74
+				if (trim($airport_icao) != '') {
75 75
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76 76
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
77
-			    }
77
+				}
78
+			}
78 79
 			}
79
-		    }
80
-		    if ($schedule['ArrivalAirportIATA'] != '') {
80
+			if ($schedule['ArrivalAirportIATA'] != '') {
81 81
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
82
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83
-			    if (trim($airport_icao) != '') {
82
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83
+				if (trim($airport_icao) != '') {
84 84
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85 85
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
86
-			    }
86
+				}
87
+			}
87 88
 			}
88
-		    }
89
-		    $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']);
89
+			$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']);
90 90
 		}
91
-	    } else $scheduleexist = true;
91
+		} else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
93 93
 	// close connection, at least one way will work ?
94
-       if ($scheduleexist) {
94
+	   if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96
-    		$sch = $Schedule->getSchedule($operator);
96
+			$sch = $Schedule->getSchedule($operator);
97 97
 		$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']));
98
-       }
98
+	   }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
101 101
 	$Translation->db = null;
@@ -110,92 +110,92 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 	  */
112 112
 	}
113
-    }
113
+	}
114 114
 
115
-    public function checkAll() {
115
+	public function checkAll() {
116 116
 	global $globalDebug;
117 117
 	if ($globalDebug) echo "Update last seen flights data...\n";
118 118
 	foreach ($this->all_flights as $key => $flight) {
119
-	    if (isset($this->all_flights[$key]['id'])) {
119
+		if (isset($this->all_flights[$key]['id'])) {
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121
-    		$Spotter = new Spotter($this->db);
122
-        	$real_arrival = $this->arrival($key);
123
-        	$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']);
124
-            }
121
+			$Spotter = new Spotter($this->db);
122
+			$real_arrival = $this->arrival($key);
123
+			$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']);
124
+			}
125
+	}
125 126
 	}
126
-    }
127 127
 
128
-    public function arrival($key) {
128
+	public function arrival($key) {
129 129
 	global $globalClosestMinDist, $globalDebug;
130 130
 	if ($globalDebug) echo 'Update arrival...'."\n";
131 131
 	$Spotter = new Spotter($this->db);
132
-        $airport_icao = '';
133
-        $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
132
+		$airport_icao = '';
133
+		$airport_time = '';
134
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137
-    	    if (isset($closestAirports[0])) {
138
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139
-        	    $airport_icao = $closestAirports[0]['icao'];
140
-        	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
142
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143
-        	    foreach ($closestAirports as $airport) {
144
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145
-        		    $airport_icao = $airport['icao'];
146
-        		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
148
-        		    break;
149
-        		}
150
-        	    }
151
-        	} 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))) {
152
-        		$airport_icao = $closestAirports[0]['icao'];
153
-        		$airport_time = $this->all_flights[$key]['datetime'];
154
-        	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
156
-        	}
157
-    	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
159
-    	    }
160
-
161
-        } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163
-        }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165
-    }
166
-
167
-
168
-
169
-    public function del() {
136
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137
+			if (isset($closestAirports[0])) {
138
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139
+				$airport_icao = $closestAirports[0]['icao'];
140
+				$airport_time = $this->all_flights[$key]['datetime'];
141
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
142
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143
+				foreach ($closestAirports as $airport) {
144
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145
+					$airport_icao = $airport['icao'];
146
+					$airport_time = $this->all_flights[$key]['datetime'];
147
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
148
+					break;
149
+				}
150
+				}
151
+			} 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))) {
152
+				$airport_icao = $closestAirports[0]['icao'];
153
+				$airport_time = $this->all_flights[$key]['datetime'];
154
+			} else {
155
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
156
+			}
157
+			} else {
158
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
159
+			}
160
+
161
+		} else {
162
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163
+		}
164
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165
+	}
166
+
167
+
168
+
169
+	public function del() {
170 170
 	global $globalDebug;
171 171
 	// Delete old infos
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174
-    	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
176
-            	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
174
+			if (isset($flight['lastupdate'])) {
175
+			if ($flight['lastupdate'] < (time()-3000)) {
176
+					if (isset($this->all_flights[$key]['id'])) {
177
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
179 179
 			$SpotterLive = new SpotterLive();
180 180
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
181 181
 			$SpotterLive->db = null;
182 182
 			*/
183
-            		$real_arrival = $this->arrival($key);
184
-            		$Spotter = new Spotter($this->db);
185
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
183
+					$real_arrival = $this->arrival($key);
184
+					$Spotter = new Spotter($this->db);
185
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 186
 				$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']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
190 190
 //			$Spotter->db = null;
191
-            	    }
192
-            	    unset($this->all_flights[$key]);
193
-    	        }
194
-	    }
195
-        }
196
-    }
197
-
198
-    public function add($line) {
191
+					}
192
+					unset($this->all_flights[$key]);
193
+				}
194
+		}
195
+		}
196
+	}
197
+
198
+	public function add($line) {
199 199
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 200
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201 201
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 	
221 221
 	// SBS format is CSV format
222 222
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
223
-	    //print_r($line);
224
-  	    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)) {
223
+		//print_r($line);
224
+  		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)) {
225 225
 
226 226
 		// Increment message number
227 227
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228
-		    $current_date = date('Y-m-d');
229
-		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
231
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
228
+			$current_date = date('Y-m-d');
229
+			$source = $line['source_name'];
230
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
231
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
232
+				$this->stats[$current_date][$source]['msg']['date'] = time();
233
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
235 235
 		}
236 236
 		
237 237
 		/*
@@ -247,34 +247,34 @@  discard block
 block discarded – undo
247 247
 		//$this->db = $dbc;
248 248
 
249 249
 		//$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
250
+			if (!isset($line['id'])) $id = trim($line['hex']);
251
+			else $id = trim($line['id']);
252 252
 		
253 253
 		if (!isset($this->all_flights[$id])) {
254
-		    $this->all_flights[$id] = array();
255
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
257
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
258
-		    if (!isset($line['id'])) {
254
+			$this->all_flights[$id] = array();
255
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
257
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
258
+			if (!isset($line['id'])) {
259 259
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
260 260
 //			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')));
261 261
 //			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')));
262 262
 			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')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
263
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
264
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
265
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
263
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
264
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
265
+			if ($globalAllFlights !== FALSE) $dataFound = true;
266 266
 		}
267 267
 		if (isset($line['source_type']) && $line['source_type'] != '') {
268
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
268
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
269 269
 		}
270 270
 		
271 271
 		//print_r($this->all_flights);
272 272
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
273
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
274
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
273
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
274
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
275 275
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
276
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
277
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
276
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
277
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
278 278
 			$timeelapsed = microtime(true);
279 279
 			$Spotter = new Spotter($this->db);
280 280
 			if (isset($this->all_flights[$id]['source_type'])) {
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 			$Spotter->db = null;
286 286
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
288
-		    }
289
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
290
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
288
+			}
289
+			if ($globalAllFlights !== FALSE) $dataFound = true;
290
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
291 291
 		}
292 292
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
293 293
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
313 313
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
314
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
314
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
315 315
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
316
-		    } else {
316
+			} else {
317 317
 				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";
318 318
 				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";
319 319
 				/*
@@ -322,41 +322,41 @@  discard block
 block discarded – undo
322 322
 				print_r($line);
323 323
 				*/
324 324
 				return '';
325
-		    }
325
+			}
326 326
 		} else {
327 327
 			date_default_timezone_set('UTC');
328 328
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
329 329
 		}
330 330
 
331 331
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
332
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
332
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
333 333
 		}
334 334
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
335
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
335
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
336 336
 		}
337 337
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
338
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
339 339
 		}
340 340
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
341
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
341
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
342 342
 		}
343 343
  
344 344
 		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'])) {
345
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
346
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
345
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
346
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
347 347
 			$timeelapsed = microtime(true);
348
-            		$Spotter = new Spotter($this->db);
349
-            		$fromsource = NULL;
350
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
351
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
348
+					$Spotter = new Spotter($this->db);
349
+					$fromsource = NULL;
350
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
351
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
352 352
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
353 353
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
354 354
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
355
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
355
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
356 356
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
357 357
 			$Spotter->db = null;
358 358
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
-		    }
359
+			}
360 360
 
361 361
 /*
362 362
 		    if (!isset($line['id'])) {
@@ -366,26 +366,26 @@  discard block
 block discarded – undo
366 366
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
367 367
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
368 368
   */
369
-		    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']));
369
+			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']));
370 370
 
371
-		    //$putinarchive = true;
372
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
371
+			//$putinarchive = true;
372
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
373 373
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
374
-		    }
375
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
374
+			}
375
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
376 376
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
377
-		    }
378
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
379
-		    		$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' => ''));
380
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
377
+			}
378
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
379
+					$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' => ''));
380
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
381 381
 				$timeelapsed = microtime(true);
382 382
 				$Spotter = new Spotter($this->db);
383 383
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
384 384
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
385
-		    		$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' => ''));
385
+					$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' => ''));
386 386
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
387 387
 
388
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
388
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
389 389
 			$timeelapsed = microtime(true);
390 390
 			$Spotter = new Spotter($this->db);
391 391
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -399,43 +399,43 @@  discard block
 block discarded – undo
399 399
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
400 400
 
401 401
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
402
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
403
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
402
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
403
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
404 404
 				//    $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']));
405
-		    		$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']));
406
-		    	    }
405
+					$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']));
406
+					}
407 407
 			}
408 408
 			if (!isset($globalFork)) $globalFork = TRUE;
409 409
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
410 410
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
411 411
 			}
412
-		    }
412
+			}
413 413
 		}
414 414
 
415 415
 		if (isset($line['speed']) && $line['speed'] != '') {
416 416
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
417
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
418
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
419
-		    //$dataFound = true;
417
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
418
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
419
+			//$dataFound = true;
420 420
 		} 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'])) {
421
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
422
-		    if ($distance > 1000 && $distance < 10000) {
423
-		    // use datetime
421
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
422
+			if ($distance > 1000 && $distance < 10000) {
423
+			// use datetime
424 424
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
425 425
 			$speed = $speed*3.6;
426 426
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
427 427
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
428
-		    }
428
+			}
429 429
 		}
430 430
 
431 431
 
432 432
 
433
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
434
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
435
-	    	    else unset($timediff);
436
-	    	    if ($this->tmd > 5 || (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')))) {
433
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
434
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
435
+				else unset($timediff);
436
+				if ($this->tmd > 5 || (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')))) {
437 437
 			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'])) {
438
-			    if (!$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'])) {
438
+				if (!$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'])) {
439 439
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
440 440
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
441 441
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450 450
 				$this->tmd = 0;
451 451
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
452
-			    }
452
+				}
453 453
 			}
454 454
 
455 455
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
456
-			    //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) {
456
+				//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) {
457 457
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
458 458
 				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') {
459
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
460
-				    $dataFound = true;
461
-				    $this->all_flights[$id]['time_last_coord'] = time();
459
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
460
+					$dataFound = true;
461
+					$this->all_flights[$id]['time_last_coord'] = time();
462 462
 				}
463 463
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
464 464
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -469,20 +469,20 @@  discard block
 block discarded – undo
469 469
 				    //$putinarchive = true;
470 470
 				}
471 471
 				*/
472
-			    /*
472
+				/*
473 473
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
474 474
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
475 475
 			    }
476 476
 			    */
477 477
 			}
478 478
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
479
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
480
-			    //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) {
479
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
480
+				//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) {
481 481
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
482 482
 				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') {
483
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
484
-				    $dataFound = true;
485
-				    $this->all_flights[$id]['time_last_coord'] = time();
483
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
484
+					$dataFound = true;
485
+					$this->all_flights[$id]['time_last_coord'] = time();
486 486
 				}
487 487
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
488 488
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -500,54 +500,54 @@  discard block
 block discarded – undo
500 500
 			    */
501 501
 			}
502 502
 
503
-		    } else if ($globalDebug && $timediff > 20) {
503
+			} else if ($globalDebug && $timediff > 20) {
504 504
 			$this->tmd = $this->tmd + 1;
505 505
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
506 506
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
507 507
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
508 508
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
509
-		    }
509
+			}
510 510
 		}
511 511
 		if (isset($line['last_update']) && $line['last_update'] != '') {
512
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
513
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
512
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
513
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
514 514
 		}
515 515
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
516
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
517
-		    //$dataFound = true;
516
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
517
+			//$dataFound = true;
518 518
 		}
519 519
 		if (isset($line['format_source']) && $line['format_source'] != '') {
520
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
520
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
521 521
 		}
522 522
 		if (isset($line['source_name']) && $line['source_name'] != '') {
523
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
523
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
524 524
 		}
525 525
 		if (isset($line['emergency']) && $line['emergency'] != '') {
526
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
527
-		    //$dataFound = true;
526
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
527
+			//$dataFound = true;
528 528
 		}
529 529
 		if (isset($line['ground']) && $line['ground'] != '') {
530
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
530
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
531 531
 			// Here we force archive of flight because after ground it's a new one (or should be)
532 532
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
533 533
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
534 534
 			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'].'-'.date('YmdGi')));
535
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
535
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
536 536
 			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']));
537
-		    }
538
-		    if ($line['ground'] != 1) $line['ground'] = 0;
539
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
540
-		    //$dataFound = true;
537
+			}
538
+			if ($line['ground'] != 1) $line['ground'] = 0;
539
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
540
+			//$dataFound = true;
541 541
 		}
542 542
 		if (isset($line['squawk']) && $line['squawk'] != '') {
543
-		    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'])) {
544
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
545
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
546
-			    $highlight = '';
547
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
548
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
549
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
550
-			    if ($highlight != '') {
543
+			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'])) {
544
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
545
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
546
+				$highlight = '';
547
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
548
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
549
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
550
+				if ($highlight != '') {
551 551
 				$timeelapsed = microtime(true);
552 552
 				$Spotter = new Spotter($this->db);
553 553
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -556,38 +556,38 @@  discard block
 block discarded – undo
556 556
 
557 557
 				//$putinarchive = true;
558 558
 				//$highlight = '';
559
-			    }
559
+				}
560 560
 			    
561
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
562
-		    //$dataFound = true;
561
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
562
+			//$dataFound = true;
563 563
 		}
564 564
 
565 565
 		if (isset($line['altitude']) && $line['altitude'] != '') {
566
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
566
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
567 567
 			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;
568 568
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
569 569
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
570 570
 			//$dataFound = true;
571
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
571
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
572 572
   		}
573 573
 
574 574
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
575
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
575
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
576 576
 		}
577 577
 		
578 578
 		if (isset($line['heading']) && $line['heading'] != '') {
579
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
580
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
581
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
582
-		    //$dataFound = true;
579
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
580
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
581
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
582
+			//$dataFound = true;
583 583
   		} 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']) {
584
-  		    $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']);
585
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
586
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
587
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
584
+  			$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']);
585
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
586
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
587
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
588 588
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
589
-  		    // If not enough messages and ACARS set heading to 0
590
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
589
+  			// If not enough messages and ACARS set heading to 0
590
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
591 591
   		}
592 592
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
593 593
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -598,119 +598,119 @@  discard block
 block discarded – undo
598 598
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
599 599
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
600 600
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
601
-		    $this->all_flights[$id]['lastupdate'] = time();
602
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
603
-		        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'])) {
604
-			    //print_r($this->all_flights);
605
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
606
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
607
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
601
+			$this->all_flights[$id]['lastupdate'] = time();
602
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
603
+				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'])) {
604
+				//print_r($this->all_flights);
605
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
606
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
607
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
608 608
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
609 609
 				$timeelapsed = microtime(true);
610 610
 				$SpotterLive = new SpotterLive($this->db);
611 611
 				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')) {
612
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
613
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
612
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
613
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
614 614
 				} elseif (isset($line['id'])) {
615
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
616
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
615
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
616
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
617 617
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
618
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
619
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
618
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
619
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
620 620
 				} else $recent_ident = '';
621 621
 				$SpotterLive->db=null;
622 622
 
623 623
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
624 624
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
625
-			    } else {
625
+				} else {
626 626
 				$recent_ident = '';
627 627
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
628
-			    }
629
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
630
-			    if($recent_ident == "")
631
-			    {
628
+				}
629
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
630
+				if($recent_ident == "")
631
+				{
632 632
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
633 633
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
634 634
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
635 635
 				//adds the spotter data for the archive
636 636
 				$ignoreImport = false;
637 637
 				foreach($globalAirportIgnore as $airportIgnore) {
638
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
638
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
639 639
 					$ignoreImport = true;
640
-				    }
640
+					}
641 641
 				}
642 642
 				if (count($globalAirportAccept) > 0) {
643
-				    $ignoreImport = true;
644
-				    foreach($globalAirportIgnore as $airportIgnore) {
643
+					$ignoreImport = true;
644
+					foreach($globalAirportIgnore as $airportIgnore) {
645 645
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
646
-					    $ignoreImport = false;
646
+						$ignoreImport = false;
647
+					}
647 648
 					}
648
-				    }
649 649
 				}
650 650
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
651
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
651
+					foreach($globalAirlineIgnore as $airlineIgnore) {
652 652
 					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)) {
653
-					    $ignoreImport = true;
653
+						$ignoreImport = true;
654
+					}
654 655
 					}
655
-				    }
656 656
 				}
657 657
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
658
-				    $ignoreImport = true;
659
-				    foreach($globalAirlineAccept as $airlineAccept) {
658
+					$ignoreImport = true;
659
+					foreach($globalAirlineAccept as $airlineAccept) {
660 660
 					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)) {
661
-					    $ignoreImport = false;
661
+						$ignoreImport = false;
662
+					}
662 663
 					}
663
-				    }
664 664
 				}
665 665
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
666
-				    $ignoreImport = true;
667
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
666
+					$ignoreImport = true;
667
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
668 668
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
669
-					    $ignoreImport = false;
669
+						$ignoreImport = false;
670
+					}
670 671
 					}
671
-				    }
672 672
 				}
673 673
 				
674 674
 				if (!$ignoreImport) {
675
-				    $highlight = '';
676
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
677
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
678
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
679
-				    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')));
680
-				    $timeelapsed = microtime(true);
681
-				    $Spotter = new Spotter($this->db);
682
-				    $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]['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']);
683
-				    $Spotter->db = null;
684
-				    if ($globalDebug && isset($result)) echo $result."\n";
685
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
675
+					$highlight = '';
676
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
677
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
678
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
679
+					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')));
680
+					$timeelapsed = microtime(true);
681
+					$Spotter = new Spotter($this->db);
682
+					$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]['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']);
683
+					$Spotter->db = null;
684
+					if ($globalDebug && isset($result)) echo $result."\n";
685
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
686 686
 				    
687
-				    // Add source stat in DB
688
-				    $Stats = new Stats($this->db);
689
-				    if (!empty($this->stats)) {
687
+					// Add source stat in DB
688
+					$Stats = new Stats($this->db);
689
+					if (!empty($this->stats)) {
690 690
 					if ($globalDebug) echo 'Add source stats : ';
691
-				        foreach($this->stats as $date => $data) {
692
-					    foreach($data as $source => $sourced) {
693
-					        //print_r($sourced);
694
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
695
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
696
-				    		if (isset($sourced['msg'])) {
697
-				    		    if (time() - $sourced['msg']['date'] > 10) {
698
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
699
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
700
-			    			        unset($this->stats[$date][$source]['msg']);
701
-			    			    }
702
-			    			}
703
-			    		    }
704
-			    		    if ($date != date('Y-m-d')) {
705
-			    			unset($this->stats[$date]);
706
-			    		    }
707
-				    	}
708
-				    	if ($globalDebug) echo 'Done'."\n";
709
-
710
-				    }
711
-				    $Stats->db = null;
691
+						foreach($this->stats as $date => $data) {
692
+						foreach($data as $source => $sourced) {
693
+							//print_r($sourced);
694
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
695
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
696
+							if (isset($sourced['msg'])) {
697
+								if (time() - $sourced['msg']['date'] > 10) {
698
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
699
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
700
+									unset($this->stats[$date][$source]['msg']);
701
+								}
702
+							}
703
+							}
704
+							if ($date != date('Y-m-d')) {
705
+							unset($this->stats[$date]);
706
+							}
707
+						}
708
+						if ($globalDebug) echo 'Done'."\n";
709
+
710
+					}
711
+					$Stats->db = null;
712 712
 				    
713
-				    $this->del();
713
+					$this->del();
714 714
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
715 715
 				//$ignoreImport = false;
716 716
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -728,18 +728,18 @@  discard block
 block discarded – undo
728 728
 			*/
729 729
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
730 730
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
731
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
732
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
733
-				    $SpotterLive = new SpotterLive($this->db);
734
-				    $SpotterLive->deleteLiveSpotterData();
735
-				    $SpotterLive->db=null;
736
-				    if ($globalDebug) echo " Done\n";
737
-				    $this->last_delete = time();
731
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
732
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
733
+					$SpotterLive = new SpotterLive($this->db);
734
+					$SpotterLive->deleteLiveSpotterData();
735
+					$SpotterLive->db=null;
736
+					if ($globalDebug) echo " Done\n";
737
+					$this->last_delete = time();
738 738
 				}
739
-			    } else {
739
+				} else {
740 740
 				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')) {
741
-				    $this->all_flights[$id]['id'] = $recent_ident;
742
-				    $this->all_flights[$id]['addedSpotter'] = 1;
741
+					$this->all_flights[$id]['id'] = $recent_ident;
742
+					$this->all_flights[$id]['addedSpotter'] = 1;
743 743
 				}
744 744
 				if (isset($globalDaemon) && !$globalDaemon) {
745 745
 					$Spotter = new Spotter($this->db);
@@ -747,14 +747,14 @@  discard block
 block discarded – undo
747 747
 					$Spotter->db = null;
748 748
 				}
749 749
 				
750
-			    }
750
+				}
751 751
 			}
752
-		    }
753
-		    //adds the spotter LIVE data
754
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
755
-		    //echo "\nAdd in Live !! \n";
756
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
757
-		    if ($globalDebug) {
752
+			}
753
+			//adds the spotter LIVE data
754
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
755
+			//echo "\nAdd in Live !! \n";
756
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
757
+			if ($globalDebug) {
758 758
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
759 759
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
760 760
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -762,49 +762,49 @@  discard block
 block discarded – undo
762 762
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
763 763
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
764 764
 			}
765
-		    }
766
-		    $ignoreImport = false;
767
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
768
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
765
+			}
766
+			$ignoreImport = false;
767
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
768
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
769 769
 
770
-		    foreach($globalAirportIgnore as $airportIgnore) {
771
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
772
-			    $ignoreImport = true;
770
+			foreach($globalAirportIgnore as $airportIgnore) {
771
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
772
+				$ignoreImport = true;
773
+			}
773 774
 			}
774
-		    }
775
-		    if (count($globalAirportAccept) > 0) {
776
-		        $ignoreImport = true;
777
-		        foreach($globalAirportIgnore as $airportIgnore) {
778
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
775
+			if (count($globalAirportAccept) > 0) {
776
+				$ignoreImport = true;
777
+				foreach($globalAirportIgnore as $airportIgnore) {
778
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
779 779
 				$ignoreImport = false;
780
-			    }
780
+				}
781 781
 			}
782
-		    }
783
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
782
+			}
783
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
784 784
 			foreach($globalAirlineIgnore as $airlineIgnore) {
785
-			    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)) {
785
+				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)) {
786 786
 				$ignoreImport = true;
787
-			    }
787
+				}
788 788
 			}
789
-		    }
790
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
789
+			}
790
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
791 791
 			$ignoreImport = true;
792 792
 			foreach($globalAirlineAccept as $airlineAccept) {
793
-			    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)) {
793
+				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)) {
794 794
 				$ignoreImport = false;
795
-			    }
795
+				}
796 796
 			}
797
-		    }
798
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
797
+			}
798
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
799 799
 			$ignoreImport = true;
800 800
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
801
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
802
-			        $ignoreImport = false;
803
-			    }
801
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
802
+					$ignoreImport = false;
803
+				}
804
+			}
804 805
 			}
805
-		    }
806 806
 
807
-		    if (!$ignoreImport) {
807
+			if (!$ignoreImport) {
808 808
 			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'])) {
809 809
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
810 810
 				$timeelapsed = microtime(true);
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 					if ($stats_heading == 16) $stats_heading = 0;
844 844
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
845 845
 						for ($i=0;$i<=15;$i++) {
846
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
846
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
847 847
 						}
848 848
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
849 849
 					} else {
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
 					//var_dump($this->stats);
857 857
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
858 858
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
859
-						    end($this->stats[$current_date][$source]['hist']);
860
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
859
+							end($this->stats[$current_date][$source]['hist']);
860
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
861 861
 						} else $mini = 0;
862 862
 						for ($i=$mini;$i<=$distance;$i+=10) {
863
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
863
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
864 864
 						}
865 865
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
866 866
 					} else {
@@ -877,22 +877,22 @@  discard block
 block discarded – undo
877 877
 			
878 878
 			
879 879
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
880
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
881
-			    $SpotterLive = new SpotterLive($this->db);
882
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
883
-			    $SpotterLive->db = null;
884
-			    //SpotterLive->deleteLiveSpotterData();
885
-			    if ($globalDebug) echo " Done\n";
886
-			    $this->last_delete_hourly = time();
880
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
881
+				$SpotterLive = new SpotterLive($this->db);
882
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
883
+				$SpotterLive->db = null;
884
+				//SpotterLive->deleteLiveSpotterData();
885
+				if ($globalDebug) echo " Done\n";
886
+				$this->last_delete_hourly = time();
887 887
 			}
888 888
 			
889
-		    }
890
-		    //$ignoreImport = false;
889
+			}
890
+			//$ignoreImport = false;
891 891
 		}
892 892
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
893 893
 		if ($send) return $this->all_flights[$id];
894
-	    }
894
+		}
895
+	}
895 896
 	}
896
-    }
897 897
 }
898 898
 ?>
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+    public function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67 67
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
69
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
70 70
 		    // Should also check if route schedule = route from DB
71 71
 		    if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			    }
87 87
 			}
88 88
 		    }
89
-		    $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']);
89
+		    $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']);
90 90
 		}
91 91
 	    } else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
        if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96 96
     		$sch = $Schedule->getSchedule($operator);
97
-		$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']));
97
+		$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']));
98 98
        }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121 121
     		$Spotter = new Spotter($this->db);
122 122
         	$real_arrival = $this->arrival($key);
123
-        	$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']);
123
+        	$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']);
124 124
             }
125 125
 	}
126 126
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $airport_time = '';
134 134
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
136
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
137 137
     	    if (isset($closestAirports[0])) {
138 138
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 139
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         		    break;
149 149
         		}
150 150
         	    }
151
-        	} 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))) {
151
+        	} 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))) {
152 152
         		$airport_icao = $closestAirports[0]['icao'];
153 153
         		$airport_time = $this->all_flights[$key]['datetime'];
154 154
         	} else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         } else {
162 162
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163 163
         }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
164
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
165 165
     }
166 166
 
167 167
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174 174
     	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
175
+        	if ($flight['lastupdate'] < (time() - 3000)) {
176 176
             	    if (isset($this->all_flights[$key]['id'])) {
177 177
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             		$real_arrival = $this->arrival($key);
184 184
             		$Spotter = new Spotter($this->db);
185 185
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186
-				$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']);
186
+				$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']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	$send = false;
220 220
 	
221 221
 	// SBS format is CSV format
222
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
222
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
223 223
 	    //print_r($line);
224 224
   	    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)) {
225 225
 
@@ -252,25 +252,25 @@  discard block
 block discarded – undo
252 252
 		
253 253
 		if (!isset($this->all_flights[$id])) {
254 254
 		    $this->all_flights[$id] = array();
255
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
257
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
255
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
256
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', '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' => ''));
257
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
258 258
 		    if (!isset($line['id'])) {
259 259
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
260 260
 //			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')));
261 261
 //			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')));
262
-			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')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
262
+			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')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
263 263
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
264
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
264
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
265 265
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
266 266
 		}
267 267
 		if (isset($line['source_type']) && $line['source_type'] != '') {
268
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
268
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
269 269
 		}
270 270
 		
271 271
 		//print_r($this->all_flights);
272 272
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
273
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
273
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
274 274
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
275 275
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
276 276
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -278,41 +278,41 @@  discard block
 block discarded – undo
278 278
 			$timeelapsed = microtime(true);
279 279
 			$Spotter = new Spotter($this->db);
280 280
 			if (isset($this->all_flights[$id]['source_type'])) {
281
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
281
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
282 282
 			} else {
283 283
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
284 284
 			}
285 285
 			$Spotter->db = null;
286
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
286
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
288 288
 		    }
289 289
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
290 290
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
291 291
 		}
292 292
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
293
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
294 294
 		}
295 295
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
296 296
 			// Get aircraft ICAO from aircraft name
297 297
 			$Spotter = new Spotter($this->db);
298 298
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
299 299
 			$Spotter->db = null;
300
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
300
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
301 301
 		}
302 302
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
303 303
 			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
304 304
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
305 305
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
306 306
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
307
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
307
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
308 308
 		}
309 309
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
310
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
310
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
311 311
 		}
312 312
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
313
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
313
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) {
314 314
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
315
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
315
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
316 316
 		    } else {
317 317
 				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";
318 318
 				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";
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
 		    }
326 326
 		} else {
327 327
 			date_default_timezone_set('UTC');
328
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
328
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
329 329
 		}
330 330
 
331 331
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
332
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
332
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
333 333
 		}
334 334
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
335
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
335
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
336 336
 		}
337 337
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
338
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
338
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
339 339
 		}
340 340
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
341
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
341
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
342 342
 		}
343 343
  
344 344
 		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'])) {
345
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
345
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
346 346
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
347 347
 			$timeelapsed = microtime(true);
348 348
             		$Spotter = new Spotter($this->db);
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
353 353
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
354 354
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
355
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
355
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
356 356
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
357 357
 			$Spotter->db = null;
358
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
359 359
 		    }
360 360
 
361 361
 /*
@@ -366,24 +366,24 @@  discard block
 block discarded – undo
366 366
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
367 367
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
368 368
   */
369
-		    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']));
369
+		    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']));
370 370
 
371 371
 		    //$putinarchive = true;
372 372
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
373
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
373
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
374 374
 		    }
375 375
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
376
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
376
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
377 377
 		    }
378 378
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
379
-		    		$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' => ''));
379
+		    		$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' => ''));
380 380
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
381 381
 				$timeelapsed = microtime(true);
382 382
 				$Spotter = new Spotter($this->db);
383 383
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
384 384
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
385
-		    		$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' => ''));
386
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385
+		    		$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' => ''));
386
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
387 387
 
388 388
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
389 389
 			$timeelapsed = microtime(true);
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
 				$Translation->db = null;
397 397
 			}
398 398
 			$Spotter->db = null;
399
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
400 400
 
401 401
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
402 402
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
403 403
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
404 404
 				//    $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']));
405
-		    		$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']));
405
+		    		$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']));
406 406
 		    	    }
407 407
 			}
408 408
 			if (!isset($globalFork)) $globalFork = TRUE;
409 409
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
410
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
410
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
411 411
 			}
412 412
 		    }
413 413
 		}
414 414
 
415 415
 		if (isset($line['speed']) && $line['speed'] != '') {
416 416
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
417
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
418
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
417
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
418
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
419 419
 		    //$dataFound = true;
420 420
 		} 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'])) {
421
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
421
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
422 422
 		    if ($distance > 1000 && $distance < 10000) {
423 423
 		    // use datetime
424 424
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
425 425
 			$speed = $speed*3.6;
426
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
426
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
427 427
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
428 428
 		    }
429 429
 		}
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 
432 432
 
433 433
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
434
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
434
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
435 435
 	    	    else unset($timediff);
436
-	    	    if ($this->tmd > 5 || (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')))) {
436
+	    	    if ($this->tmd > 5 || (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')))) {
437 437
 			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'])) {
438
-			    if (!$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'])) {
438
+			    if (!$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'])) {
439 439
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
440 440
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
441 441
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
444 444
 				$timeelapsed = microtime(true);
445 445
 				$Spotter = new Spotter($this->db);
446
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
446
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
447 447
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
448 448
 				$Spotter->db = null;
449
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
450 450
 				$this->tmd = 0;
451 451
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
452 452
 			    }
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
456 456
 			    //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) {
457 457
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
458
-				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') {
458
+				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') {
459 459
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
460 460
 				    $dataFound = true;
461 461
 				    $this->all_flights[$id]['time_last_coord'] = time();
462 462
 				}
463 463
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
464
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
464
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
465 465
 				/*
466 466
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
467 467
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -479,13 +479,13 @@  discard block
 block discarded – undo
479 479
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
480 480
 			    //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) {
481 481
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
482
-				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') {
482
+				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') {
483 483
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
484 484
 				    $dataFound = true;
485 485
 				    $this->all_flights[$id]['time_last_coord'] = time();
486 486
 				}
487 487
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
488
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
488
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
489 489
 				/*
490 490
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
491 491
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -503,46 +503,46 @@  discard block
 block discarded – undo
503 503
 		    } else if ($globalDebug && $timediff > 20) {
504 504
 			$this->tmd = $this->tmd + 1;
505 505
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
506
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
507
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
506
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
507
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
508 508
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
509 509
 		    }
510 510
 		}
511 511
 		if (isset($line['last_update']) && $line['last_update'] != '') {
512 512
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
513
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
513
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
514 514
 		}
515 515
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
516
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
516
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
517 517
 		    //$dataFound = true;
518 518
 		}
519 519
 		if (isset($line['format_source']) && $line['format_source'] != '') {
520
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
520
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
521 521
 		}
522 522
 		if (isset($line['source_name']) && $line['source_name'] != '') {
523
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
523
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
524 524
 		}
525 525
 		if (isset($line['emergency']) && $line['emergency'] != '') {
526
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
526
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
527 527
 		    //$dataFound = true;
528 528
 		}
529 529
 		if (isset($line['ground']) && $line['ground'] != '') {
530 530
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
531 531
 			// Here we force archive of flight because after ground it's a new one (or should be)
532
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
533
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
534
-			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'].'-'.date('YmdGi')));
535
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
536
-			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']));
532
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
533
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
534
+			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'].'-'.date('YmdGi')));
535
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
536
+			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']));
537 537
 		    }
538 538
 		    if ($line['ground'] != 1) $line['ground'] = 0;
539
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
539
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
540 540
 		    //$dataFound = true;
541 541
 		}
542 542
 		if (isset($line['squawk']) && $line['squawk'] != '') {
543 543
 		    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'])) {
544 544
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
545
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
545
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
546 546
 			    $highlight = '';
547 547
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
548 548
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -550,47 +550,47 @@  discard block
 block discarded – undo
550 550
 			    if ($highlight != '') {
551 551
 				$timeelapsed = microtime(true);
552 552
 				$Spotter = new Spotter($this->db);
553
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
553
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
554 554
 				$Spotter->db = null;
555
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
555
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
556 556
 
557 557
 				//$putinarchive = true;
558 558
 				//$highlight = '';
559 559
 			    }
560 560
 			    
561
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
561
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
562 562
 		    //$dataFound = true;
563 563
 		}
564 564
 
565 565
 		if (isset($line['altitude']) && $line['altitude'] != '') {
566 566
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
567
-			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;
568
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
569
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
567
+			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;
568
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
569
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
570 570
 			//$dataFound = true;
571 571
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
572 572
   		}
573 573
 
574 574
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
575
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
575
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
576 576
 		}
577 577
 		
578 578
 		if (isset($line['heading']) && $line['heading'] != '') {
579
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
580
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
581
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
579
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
580
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
581
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
582 582
 		    //$dataFound = true;
583 583
   		} 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']) {
584
-  		    $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']);
585
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
586
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
584
+  		    $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']);
585
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
586
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
587 587
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
588 588
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
589 589
   		    // If not enough messages and ACARS set heading to 0
590
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
590
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
591 591
   		}
592
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
593
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
592
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
593
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
594 594
 
595 595
 //		print_r($this->all_flights[$id]);
596 596
 		//gets the callsign from the last hour
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
601 601
 		    $this->all_flights[$id]['lastupdate'] = time();
602 602
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
603
-		        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'])) {
603
+		        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'])) {
604 604
 			    //print_r($this->all_flights);
605 605
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
606 606
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -610,61 +610,61 @@  discard block
 block discarded – undo
610 610
 				$SpotterLive = new SpotterLive($this->db);
611 611
 				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')) {
612 612
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
613
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
613
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
614 614
 				} elseif (isset($line['id'])) {
615 615
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
616
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
616
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
617 617
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
618 618
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
619
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
619
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
620 620
 				} else $recent_ident = '';
621
-				$SpotterLive->db=null;
621
+				$SpotterLive->db = null;
622 622
 
623 623
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
624 624
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
625 625
 			    } else {
626 626
 				$recent_ident = '';
627
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
627
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
628 628
 			    }
629 629
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
630
-			    if($recent_ident == "")
630
+			    if ($recent_ident == "")
631 631
 			    {
632 632
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
633 633
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
634 634
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
635 635
 				//adds the spotter data for the archive
636 636
 				$ignoreImport = false;
637
-				foreach($globalAirportIgnore as $airportIgnore) {
637
+				foreach ($globalAirportIgnore as $airportIgnore) {
638 638
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
639 639
 					$ignoreImport = true;
640 640
 				    }
641 641
 				}
642 642
 				if (count($globalAirportAccept) > 0) {
643 643
 				    $ignoreImport = true;
644
-				    foreach($globalAirportIgnore as $airportIgnore) {
644
+				    foreach ($globalAirportIgnore as $airportIgnore) {
645 645
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
646 646
 					    $ignoreImport = false;
647 647
 					}
648 648
 				    }
649 649
 				}
650 650
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
651
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
652
-					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)) {
651
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
652
+					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)) {
653 653
 					    $ignoreImport = true;
654 654
 					}
655 655
 				    }
656 656
 				}
657 657
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
658 658
 				    $ignoreImport = true;
659
-				    foreach($globalAirlineAccept as $airlineAccept) {
660
-					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)) {
659
+				    foreach ($globalAirlineAccept as $airlineAccept) {
660
+					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)) {
661 661
 					    $ignoreImport = false;
662 662
 					}
663 663
 				    }
664 664
 				}
665 665
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
666 666
 				    $ignoreImport = true;
667
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
667
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
668 668
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
669 669
 					    $ignoreImport = false;
670 670
 					}
@@ -676,27 +676,27 @@  discard block
 block discarded – undo
676 676
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
677 677
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
678 678
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
679
-				    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')));
679
+				    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')));
680 680
 				    $timeelapsed = microtime(true);
681 681
 				    $Spotter = new Spotter($this->db);
682
-				    $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]['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']);
682
+				    $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]['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']);
683 683
 				    $Spotter->db = null;
684 684
 				    if ($globalDebug && isset($result)) echo $result."\n";
685
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
685
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
686 686
 				    
687 687
 				    // Add source stat in DB
688 688
 				    $Stats = new Stats($this->db);
689 689
 				    if (!empty($this->stats)) {
690 690
 					if ($globalDebug) echo 'Add source stats : ';
691
-				        foreach($this->stats as $date => $data) {
692
-					    foreach($data as $source => $sourced) {
691
+				        foreach ($this->stats as $date => $data) {
692
+					    foreach ($data as $source => $sourced) {
693 693
 					        //print_r($sourced);
694
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
695
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
694
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
695
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
696 696
 				    		if (isset($sourced['msg'])) {
697 697
 				    		    if (time() - $sourced['msg']['date'] > 10) {
698 698
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
699
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
699
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
700 700
 			    			        unset($this->stats[$date][$source]['msg']);
701 701
 			    			    }
702 702
 			    			}
@@ -732,18 +732,18 @@  discard block
 block discarded – undo
732 732
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
733 733
 				    $SpotterLive = new SpotterLive($this->db);
734 734
 				    $SpotterLive->deleteLiveSpotterData();
735
-				    $SpotterLive->db=null;
735
+				    $SpotterLive->db = null;
736 736
 				    if ($globalDebug) echo " Done\n";
737 737
 				    $this->last_delete = time();
738 738
 				}
739 739
 			    } else {
740
-				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')) {
740
+				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')) {
741 741
 				    $this->all_flights[$id]['id'] = $recent_ident;
742 742
 				    $this->all_flights[$id]['addedSpotter'] = 1;
743 743
 				}
744 744
 				if (isset($globalDaemon) && !$globalDaemon) {
745 745
 					$Spotter = new Spotter($this->db);
746
-					$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]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
746
+					$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]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
747 747
 					$Spotter->db = null;
748 748
 				}
749 749
 				
@@ -767,37 +767,37 @@  discard block
 block discarded – undo
767 767
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
768 768
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
769 769
 
770
-		    foreach($globalAirportIgnore as $airportIgnore) {
770
+		    foreach ($globalAirportIgnore as $airportIgnore) {
771 771
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
772 772
 			    $ignoreImport = true;
773 773
 			}
774 774
 		    }
775 775
 		    if (count($globalAirportAccept) > 0) {
776 776
 		        $ignoreImport = true;
777
-		        foreach($globalAirportIgnore as $airportIgnore) {
777
+		        foreach ($globalAirportIgnore as $airportIgnore) {
778 778
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
779 779
 				$ignoreImport = false;
780 780
 			    }
781 781
 			}
782 782
 		    }
783 783
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
784
-			foreach($globalAirlineIgnore as $airlineIgnore) {
785
-			    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)) {
784
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
785
+			    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)) {
786 786
 				$ignoreImport = true;
787 787
 			    }
788 788
 			}
789 789
 		    }
790 790
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
791 791
 			$ignoreImport = true;
792
-			foreach($globalAirlineAccept as $airlineAccept) {
793
-			    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)) {
792
+			foreach ($globalAirlineAccept as $airlineAccept) {
793
+			    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)) {
794 794
 				$ignoreImport = false;
795 795
 			    }
796 796
 			}
797 797
 		    }
798 798
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
799 799
 			$ignoreImport = true;
800
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
800
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
801 801
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
802 802
 			        $ignoreImport = false;
803 803
 			    }
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
 		    }
806 806
 
807 807
 		    if (!$ignoreImport) {
808
-			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'])) {
808
+			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'])) {
809 809
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
810 810
 				$timeelapsed = microtime(true);
811 811
 				$SpotterLive = new SpotterLive($this->db);
812
-				$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]['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']);
812
+				$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]['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']);
813 813
 				$SpotterLive->db = null;
814 814
 				$this->all_flights[$id]['putinarchive'] = false;
815
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
815
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
816 816
 
817 817
 				// Put statistics in $this->stats variable
818 818
 				//if ($line['format_source'] != 'aprs') {
@@ -830,19 +830,19 @@  discard block
 block discarded – undo
830 830
 							$latitude = $globalCenterLatitude;
831 831
 							$longitude = $globalCenterLongitude;
832 832
 						}
833
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
833
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
834 834
 					} else {
835 835
 						$latitude = $this->source_location[$source]['latitude'];
836 836
 						$longitude = $this->source_location[$source]['longitude'];
837 837
 					}
838
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
838
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
839 839
 					//$stats_heading = $stats_heading%22.5;
840 840
 					$stats_heading = round($stats_heading/22.5);
841
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
841
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
842 842
 					$current_date = date('Y-m-d');
843 843
 					if ($stats_heading == 16) $stats_heading = 0;
844 844
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
845
-						for ($i=0;$i<=15;$i++) {
845
+						for ($i = 0; $i <= 15; $i++) {
846 846
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
847 847
 						}
848 848
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -857,9 +857,9 @@  discard block
 block discarded – undo
857 857
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
858 858
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
859 859
 						    end($this->stats[$current_date][$source]['hist']);
860
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
860
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
861 861
 						} else $mini = 0;
862
-						for ($i=$mini;$i<=$distance;$i+=10) {
862
+						for ($i = $mini; $i <= $distance; $i += 10) {
863 863
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
864 864
 						}
865 865
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
873 873
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
874 874
 				if ($globalDebug) echo $result."\n";
875
-			} 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";
875
+			} 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";
876 876
 			//$this->del();
877 877
 			
878 878
 			
Please login to merge, or discard this patch.
Braces   +331 added lines, -117 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
 	    if ($Schedule->checkSchedule($operator) == 0) {
65 67
 		$schedule = $Schedule->fetchSchedule($operator);
66 68
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
69
+		    if ($globalDebug) {
70
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
71
+		    }
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69 73
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70 74
 		    // Should also check if route schedule = route from DB
@@ -73,7 +77,9 @@  discard block
 block discarded – undo
73 77
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74 78
 			    if (trim($airport_icao) != '') {
75 79
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
80
+				if ($globalDebug) {
81
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
82
+				}
77 83
 			    }
78 84
 			}
79 85
 		    }
@@ -82,17 +88,25 @@  discard block
 block discarded – undo
82 88
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83 89
 			    if (trim($airport_icao) != '') {
84 90
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
91
+				if ($globalDebug) {
92
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
93
+				}
86 94
 			    }
87 95
 			}
88 96
 		    }
89 97
 		    $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']);
90 98
 		}
91
-	    } else $scheduleexist = true;
92
-	} else $scheduleexist = true;
99
+	    } else {
100
+	    	$scheduleexist = true;
101
+	    }
102
+	} else {
103
+		$scheduleexist = true;
104
+	}
93 105
 	// close connection, at least one way will work ?
94 106
        if ($scheduleexist) {
95
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
107
+		if ($globalDebug) {
108
+			echo "-> get arrival/departure airport info for ".$ident."\n";
109
+		}
96 110
     		$sch = $Schedule->getSchedule($operator);
97 111
 		$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']));
98 112
        }
@@ -114,7 +128,9 @@  discard block
 block discarded – undo
114 128
 
115 129
     public function checkAll() {
116 130
 	global $globalDebug;
117
-	if ($globalDebug) echo "Update last seen flights data...\n";
131
+	if ($globalDebug) {
132
+		echo "Update last seen flights data...\n";
133
+	}
118 134
 	foreach ($this->all_flights as $key => $flight) {
119 135
 	    if (isset($this->all_flights[$key]['id'])) {
120 136
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -127,24 +143,32 @@  discard block
 block discarded – undo
127 143
 
128 144
     public function arrival($key) {
129 145
 	global $globalClosestMinDist, $globalDebug;
130
-	if ($globalDebug) echo 'Update arrival...'."\n";
146
+	if ($globalDebug) {
147
+		echo 'Update arrival...'."\n";
148
+	}
131 149
 	$Spotter = new Spotter($this->db);
132 150
         $airport_icao = '';
133 151
         $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
153
+        	$globalClosestMinDist = 50;
154
+        }
135 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136 156
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137 157
     	    if (isset($closestAirports[0])) {
138 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 159
         	    $airport_icao = $closestAirports[0]['icao'];
140 160
         	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
161
+        	    if ($globalDebug) {
162
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+        	    }
142 164
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143 165
         	    foreach ($closestAirports as $airport) {
144 166
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145 167
         		    $airport_icao = $airport['icao'];
146 168
         		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        		    if ($globalDebug) {
170
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        		    }
148 172
         		    break;
149 173
         		}
150 174
         	    }
@@ -152,14 +176,20 @@  discard block
 block discarded – undo
152 176
         		$airport_icao = $closestAirports[0]['icao'];
153 177
         		$airport_time = $this->all_flights[$key]['datetime'];
154 178
         	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
179
+        		if ($globalDebug) {
180
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
181
+        		}
156 182
         	}
157 183
     	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
184
+    		    if ($globalDebug) {
185
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
186
+    		    }
159 187
     	    }
160 188
 
161 189
         } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
190
+        	if ($globalDebug) {
191
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
192
+        	}
163 193
         }
164 194
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165 195
     }
@@ -169,12 +199,16 @@  discard block
 block discarded – undo
169 199
     public function del() {
170 200
 	global $globalDebug;
171 201
 	// Delete old infos
172
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
202
+	if ($globalDebug) {
203
+		echo 'Delete old values and update latest data...'."\n";
204
+	}
173 205
 	foreach ($this->all_flights as $key => $flight) {
174 206
     	    if (isset($flight['lastupdate'])) {
175 207
         	if ($flight['lastupdate'] < (time()-3000)) {
176 208
             	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
209
+            		if ($globalDebug) {
210
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
211
+            		}
178 212
 			/*
179 213
 			$SpotterLive = new SpotterLive();
180 214
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -184,7 +218,9 @@  discard block
 block discarded – undo
184 218
             		$Spotter = new Spotter($this->db);
185 219
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 220
 				$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']);
187
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
221
+				if ($globalDebug && $result != 'success') {
222
+					echo '!!! ERROR : '.$result."\n";
223
+				}
188 224
 			}
189 225
 			// Put in archive
190 226
 //			$Spotter->db = null;
@@ -198,8 +234,10 @@  discard block
 block discarded – undo
198 234
     public function add($line) {
199 235
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 236
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
202
-/*
237
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
238
+		$globalCoordMinChange = '0.02';
239
+	}
240
+	/*
203 241
 	$Spotter = new Spotter();
204 242
 	$dbc = $Spotter->db;
205 243
 	$SpotterLive = new SpotterLive($dbc);
@@ -227,11 +265,15 @@  discard block
 block discarded – undo
227 265
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228 266
 		    $current_date = date('Y-m-d');
229 267
 		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
268
+		    if ($source == '' || $line['format_source'] == 'aprs') {
269
+		    	$source = $line['format_source'];
270
+		    }
231 271
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232 272
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233 273
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
274
+		    } else {
275
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
276
+		    }
235 277
 		}
236 278
 		
237 279
 		/*
@@ -247,8 +289,11 @@  discard block
 block discarded – undo
247 289
 		//$this->db = $dbc;
248 290
 
249 291
 		//$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
292
+	        if (!isset($line['id'])) {
293
+	        	$id = trim($line['hex']);
294
+	        } else {
295
+	        	$id = trim($line['id']);
296
+	        }
252 297
 		
253 298
 		if (!isset($this->all_flights[$id])) {
254 299
 		    $this->all_flights[$id] = array();
@@ -256,13 +301,21 @@  discard block
 block discarded – undo
256 301
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
257 302
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
258 303
 		    if (!isset($line['id'])) {
259
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
260
-//			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')));
304
+			if (!isset($globalDaemon)) {
305
+				$globalDaemon = TRUE;
306
+			}
307
+			//			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')));
261 308
 //			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')));
262
-			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')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
309
+			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')) {
310
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
311
+			}
263 312
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
264
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
265
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
313
+		     } else {
314
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
315
+		     }
316
+		    if ($globalAllFlights !== FALSE) {
317
+		    	$dataFound = true;
318
+		    }
266 319
 		}
267 320
 		if (isset($line['source_type']) && $line['source_type'] != '') {
268 321
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -283,11 +336,19 @@  discard block
 block discarded – undo
283 336
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
284 337
 			}
285 338
 			$Spotter->db = null;
286
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
339
+			if ($globalDebugTimeElapsed) {
340
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
341
+			}
342
+			if ($aircraft_icao != '') {
343
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
344
+			}
345
+		    }
346
+		    if ($globalAllFlights !== FALSE) {
347
+		    	$dataFound = true;
348
+		    }
349
+		    if ($globalDebug) {
350
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
288 351
 		    }
289
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
290
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
291 352
 		}
292 353
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
293 354
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -297,14 +358,23 @@  discard block
 block discarded – undo
297 358
 			$Spotter = new Spotter($this->db);
298 359
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
299 360
 			$Spotter->db = null;
300
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
361
+			if ($aircraft_icao != '') {
362
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			}
301 364
 		}
302 365
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
303
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
304
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
305
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
306
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
307
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
366
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
367
+				$aircraft_icao = 'GLID';
368
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
369
+				$aircraft_icao = 'UHEL';
370
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
371
+				$aircraft_icao = 'TOWPLANE';
372
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
373
+				$aircraft_icao = 'POWAIRC';
374
+			}
375
+			if (isset($aircraft_icao)) {
376
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
377
+			}
308 378
 		}
309 379
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
310 380
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -314,8 +384,11 @@  discard block
 block discarded – undo
314 384
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
315 385
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
316 386
 		    } else {
317
-				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";
318
-				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";
387
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
388
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
389
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
390
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
391
+				}
319 392
 				/*
320 393
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
321 394
 				print_r($this->all_flights[$id]);
@@ -347,15 +420,25 @@  discard block
 block discarded – undo
347 420
 			$timeelapsed = microtime(true);
348 421
             		$Spotter = new Spotter($this->db);
349 422
             		$fromsource = NULL;
350
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
351
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
352
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
353
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
354
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
423
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
424
+            			$fromsource = $globalAirlinesSource;
425
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
426
+            			$fromsource = 'vatsim';
427
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
428
+				$fromsource = 'ivao';
429
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
430
+				$fromsource = 'vatsim';
431
+			} elseif (isset($globalIVAO) && $globalIVAO) {
432
+				$fromsource = 'ivao';
433
+			}
355 434
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
356
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
435
+			if ($globalDebug && $result != 'success') {
436
+				echo '!!! ERROR : '.$result."\n";
437
+			}
357 438
 			$Spotter->db = null;
358
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
439
+			if ($globalDebugTimeElapsed) {
440
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
441
+			}
359 442
 		    }
360 443
 
361 444
 /*
@@ -366,7 +449,9 @@  discard block
 block discarded – undo
366 449
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
367 450
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
368 451
   */
369
-		    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']));
452
+		    if (!isset($this->all_flights[$id]['id'])) {
453
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
454
+		    }
370 455
 
371 456
 		    //$putinarchive = true;
372 457
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -383,7 +468,9 @@  discard block
 block discarded – undo
383 468
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
384 469
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
385 470
 		    		$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' => ''));
386
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
471
+				if ($globalDebugTimeElapsed) {
472
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+				}
387 474
 
388 475
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
389 476
 			$timeelapsed = microtime(true);
@@ -396,7 +483,9 @@  discard block
 block discarded – undo
396 483
 				$Translation->db = null;
397 484
 			}
398 485
 			$Spotter->db = null;
399
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
486
+			if ($globalDebugTimeElapsed) {
487
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
488
+			}
400 489
 
401 490
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
402 491
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -405,9 +494,13 @@  discard block
 block discarded – undo
405 494
 		    		$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']));
406 495
 		    	    }
407 496
 			}
408
-			if (!isset($globalFork)) $globalFork = TRUE;
497
+			if (!isset($globalFork)) {
498
+				$globalFork = TRUE;
499
+			}
409 500
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
410
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
501
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
502
+					$this->get_Schedule($id,trim($line['ident']));
503
+				}
411 504
 			}
412 505
 		    }
413 506
 		}
@@ -423,16 +516,23 @@  discard block
 block discarded – undo
423 516
 		    // use datetime
424 517
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
425 518
 			$speed = $speed*3.6;
426
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
427
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
519
+			if ($speed < 1000) {
520
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
521
+			}
522
+  			if ($globalDebug) {
523
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
524
+  			}
428 525
 		    }
429 526
 		}
430 527
 
431 528
 
432 529
 
433 530
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
434
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
435
-	    	    else unset($timediff);
531
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
532
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
533
+	    	    } else {
534
+	    	    	unset($timediff);
535
+	    	    }
436 536
 	    	    if ($this->tmd > 5 || (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')))) {
437 537
 			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'])) {
438 538
 			    if (!$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'])) {
@@ -440,21 +540,31 @@  discard block
 block discarded – undo
440 540
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
441 541
 				$this->all_flights[$id]['putinarchive'] = true;
442 542
 				
443
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
543
+				if ($globalDebug) {
544
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
545
+				}
444 546
 				$timeelapsed = microtime(true);
445 547
 				$Spotter = new Spotter($this->db);
446 548
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
447
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
549
+				if (!empty($all_country)) {
550
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
551
+				}
448 552
 				$Spotter->db = null;
449
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
553
+				if ($globalDebugTimeElapsed) {
554
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
555
+				}
450 556
 				$this->tmd = 0;
451
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
557
+				if ($globalDebug) {
558
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
559
+				}
452 560
 			    }
453 561
 			}
454 562
 
455 563
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
456 564
 			    //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) {
457
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
565
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
566
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
567
+				}
458 568
 				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') {
459 569
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
460 570
 				    $dataFound = true;
@@ -476,9 +586,13 @@  discard block
 block discarded – undo
476 586
 			    */
477 587
 			}
478 588
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
479
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
589
+			    if ($line['longitude'] > 180) {
590
+			    	$line['longitude'] = $line['longitude'] - 360;
591
+			    }
480 592
 			    //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) {
481
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
593
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
594
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
595
+				}
482 596
 				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') {
483 597
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
484 598
 				    $dataFound = true;
@@ -509,7 +623,9 @@  discard block
 block discarded – undo
509 623
 		    }
510 624
 		}
511 625
 		if (isset($line['last_update']) && $line['last_update'] != '') {
512
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
626
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
627
+		    	$dataFound = true;
628
+		    }
513 629
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
514 630
 		}
515 631
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -531,40 +647,60 @@  discard block
 block discarded – undo
531 647
 			// Here we force archive of flight because after ground it's a new one (or should be)
532 648
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
533 649
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
534
-			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'].'-'.date('YmdGi')));
535
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
536
-			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']));
650
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
651
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
652
+			} elseif (isset($line['id'])) {
653
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
654
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
655
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
656
+			}
657
+		    }
658
+		    if ($line['ground'] != 1) {
659
+		    	$line['ground'] = 0;
537 660
 		    }
538
-		    if ($line['ground'] != 1) $line['ground'] = 0;
539 661
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
540 662
 		    //$dataFound = true;
541 663
 		}
542 664
 		if (isset($line['squawk']) && $line['squawk'] != '') {
543 665
 		    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'])) {
544
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
666
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
667
+			    	$this->all_flights[$id]['putinarchive'] = true;
668
+			    }
545 669
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
546 670
 			    $highlight = '';
547
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
548
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
549
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
671
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
672
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
673
+			    }
674
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
675
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
676
+			    }
677
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
678
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
679
+			    }
550 680
 			    if ($highlight != '') {
551 681
 				$timeelapsed = microtime(true);
552 682
 				$Spotter = new Spotter($this->db);
553 683
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
554 684
 				$Spotter->db = null;
555
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
685
+				if ($globalDebugTimeElapsed) {
686
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
687
+				}
556 688
 
557 689
 				//$putinarchive = true;
558 690
 				//$highlight = '';
559 691
 			    }
560 692
 			    
561
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
693
+		    } else {
694
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
695
+		    }
562 696
 		    //$dataFound = true;
563 697
 		}
564 698
 
565 699
 		if (isset($line['altitude']) && $line['altitude'] != '') {
566 700
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
567
-			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;
701
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
702
+				$this->all_flights[$id]['putinarchive'] = true;
703
+			}
568 704
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
569 705
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
570 706
 			//$dataFound = true;
@@ -576,21 +712,30 @@  discard block
 block discarded – undo
576 712
 		}
577 713
 		
578 714
 		if (isset($line['heading']) && $line['heading'] != '') {
579
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
715
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
716
+		    	$this->all_flights[$id]['putinarchive'] = true;
717
+		    }
580 718
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
581 719
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
582 720
 		    //$dataFound = true;
583 721
   		} 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']) {
584 722
   		    $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']);
585 723
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
586
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
587
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
724
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
725
+		    	$this->all_flights[$id]['putinarchive'] = true;
726
+		    }
727
+  		    if ($globalDebug) {
728
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
729
+  		    }
588 730
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
589 731
   		    // If not enough messages and ACARS set heading to 0
590 732
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
591 733
   		}
592
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
593
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
734
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
735
+			$dataFound = false;
736
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
737
+			$dataFound = false;
738
+		}
594 739
 
595 740
 //		print_r($this->all_flights[$id]);
596 741
 		//gets the callsign from the last hour
@@ -605,23 +750,36 @@  discard block
 block discarded – undo
605 750
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
606 751
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
607 752
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
608
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
753
+				if ($globalDebug) {
754
+					echo "Check if aircraft is already in DB...";
755
+				}
609 756
 				$timeelapsed = microtime(true);
610 757
 				$SpotterLive = new SpotterLive($this->db);
611 758
 				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')) {
612 759
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
613
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
760
+				    if ($globalDebugTimeElapsed) {
761
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
762
+				    }
614 763
 				} elseif (isset($line['id'])) {
615 764
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
616
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
765
+				    if ($globalDebugTimeElapsed) {
766
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
767
+				    }
617 768
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
618 769
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
619
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
620
-				} else $recent_ident = '';
770
+				    if ($globalDebugTimeElapsed) {
771
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
772
+				    }
773
+				} else {
774
+					$recent_ident = '';
775
+				}
621 776
 				$SpotterLive->db=null;
622 777
 
623
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
624
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
778
+				if ($globalDebug && $recent_ident == '') {
779
+					echo " Not in DB.\n";
780
+				} elseif ($globalDebug && $recent_ident != '') {
781
+					echo " Already in DB.\n";
782
+				}
625 783
 			    } else {
626 784
 				$recent_ident = '';
627 785
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -629,7 +787,9 @@  discard block
 block discarded – undo
629 787
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
630 788
 			    if($recent_ident == "")
631 789
 			    {
632
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
790
+				if ($globalDebug) {
791
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
792
+				}
633 793
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
634 794
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
635 795
 				//adds the spotter data for the archive
@@ -673,26 +833,44 @@  discard block
 block discarded – undo
673 833
 				
674 834
 				if (!$ignoreImport) {
675 835
 				    $highlight = '';
676
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
677
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
678
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
679
-				    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')));
836
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
837
+				    	$highlight = 'Squawk 7500 : Hijack';
838
+				    }
839
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
840
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
841
+				    }
842
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
843
+				    	$highlight = 'Squawk 7700 : Emergency';
844
+				    }
845
+				    if (!isset($this->all_flights[$id]['id'])) {
846
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
847
+				    }
680 848
 				    $timeelapsed = microtime(true);
681 849
 				    $Spotter = new Spotter($this->db);
682 850
 				    $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]['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']);
683 851
 				    $Spotter->db = null;
684
-				    if ($globalDebug && isset($result)) echo $result."\n";
685
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
852
+				    if ($globalDebug && isset($result)) {
853
+				    	echo $result."\n";
854
+				    }
855
+				    if ($globalDebugTimeElapsed) {
856
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
857
+				    }
686 858
 				    
687 859
 				    // Add source stat in DB
688 860
 				    $Stats = new Stats($this->db);
689 861
 				    if (!empty($this->stats)) {
690
-					if ($globalDebug) echo 'Add source stats : ';
862
+					if ($globalDebug) {
863
+						echo 'Add source stats : ';
864
+					}
691 865
 				        foreach($this->stats as $date => $data) {
692 866
 					    foreach($data as $source => $sourced) {
693 867
 					        //print_r($sourced);
694
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
695
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
868
+				    	        if (isset($sourced['polar'])) {
869
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
870
+				    	        }
871
+				    	        if (isset($sourced['hist'])) {
872
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
873
+				    	        }
696 874
 				    		if (isset($sourced['msg'])) {
697 875
 				    		    if (time() - $sourced['msg']['date'] > 10) {
698 876
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -705,13 +883,17 @@  discard block
 block discarded – undo
705 883
 			    			unset($this->stats[$date]);
706 884
 			    		    }
707 885
 				    	}
708
-				    	if ($globalDebug) echo 'Done'."\n";
886
+				    	if ($globalDebug) {
887
+				    		echo 'Done'."\n";
888
+				    	}
709 889
 
710 890
 				    }
711 891
 				    $Stats->db = null;
712 892
 				    
713 893
 				    $this->del();
714
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
894
+				} elseif ($globalDebug) {
895
+					echo 'Ignore data'."\n";
896
+				}
715 897
 				//$ignoreImport = false;
716 898
 				$this->all_flights[$id]['addedSpotter'] = 1;
717 899
 				//print_r($this->all_flights[$id]);
@@ -728,12 +910,16 @@  discard block
 block discarded – undo
728 910
 			*/
729 911
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
730 912
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
731
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
913
+				    if ($globalDebug) {
914
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
915
+				    }
732 916
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
733 917
 				    $SpotterLive = new SpotterLive($this->db);
734 918
 				    $SpotterLive->deleteLiveSpotterData();
735 919
 				    $SpotterLive->db=null;
736
-				    if ($globalDebug) echo " Done\n";
920
+				    if ($globalDebug) {
921
+				    	echo " Done\n";
922
+				    }
737 923
 				    $this->last_delete = time();
738 924
 				}
739 925
 			    } else {
@@ -756,11 +942,17 @@  discard block
 block discarded – undo
756 942
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
757 943
 		    if ($globalDebug) {
758 944
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
759
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
760
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
945
+				if (isset($this->all_flights[$id]['source_name'])) {
946
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
947
+				} else {
948
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
949
+				}
761 950
 			} else {
762
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
763
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
951
+				if (isset($this->all_flights[$id]['source_name'])) {
952
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
953
+				} else {
954
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
955
+				}
764 956
 			}
765 957
 		    }
766 958
 		    $ignoreImport = false;
@@ -806,20 +998,26 @@  discard block
 block discarded – undo
806 998
 
807 999
 		    if (!$ignoreImport) {
808 1000
 			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'])) {
809
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1001
+				if ($globalDebug) {
1002
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1003
+				}
810 1004
 				$timeelapsed = microtime(true);
811 1005
 				$SpotterLive = new SpotterLive($this->db);
812 1006
 				$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]['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']);
813 1007
 				$SpotterLive->db = null;
814 1008
 				$this->all_flights[$id]['putinarchive'] = false;
815
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1009
+				if ($globalDebugTimeElapsed) {
1010
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1011
+				}
816 1012
 
817 1013
 				// Put statistics in $this->stats variable
818 1014
 				//if ($line['format_source'] != 'aprs') {
819 1015
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
820 1016
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
821 1017
 					$source = $this->all_flights[$id]['source_name'];
822
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1018
+					if ($source == '') {
1019
+						$source = $this->all_flights[$id]['format_source'];
1020
+					}
823 1021
 					if (!isset($this->source_location[$source])) {
824 1022
 						$Location = new Source();
825 1023
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -840,7 +1038,9 @@  discard block
 block discarded – undo
840 1038
 					$stats_heading = round($stats_heading/22.5);
841 1039
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
842 1040
 					$current_date = date('Y-m-d');
843
-					if ($stats_heading == 16) $stats_heading = 0;
1041
+					if ($stats_heading == 16) {
1042
+						$stats_heading = 0;
1043
+					}
844 1044
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
845 1045
 						for ($i=0;$i<=15;$i++) {
846 1046
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -858,7 +1058,9 @@  discard block
 block discarded – undo
858 1058
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
859 1059
 						    end($this->stats[$current_date][$source]['hist']);
860 1060
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
861
-						} else $mini = 0;
1061
+						} else {
1062
+							$mini = 0;
1063
+						}
862 1064
 						for ($i=$mini;$i<=$distance;$i+=10) {
863 1065
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
864 1066
 						}
@@ -869,20 +1071,30 @@  discard block
 block discarded – undo
869 1071
 				}
870 1072
 
871 1073
 				$this->all_flights[$id]['lastupdate'] = time();
872
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1074
+				if ($this->all_flights[$id]['putinarchive']) {
1075
+					$send = true;
1076
+				}
873 1077
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
874
-				if ($globalDebug) echo $result."\n";
875
-			} 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";
1078
+				if ($globalDebug) {
1079
+					echo $result."\n";
1080
+				}
1081
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1082
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1083
+			}
876 1084
 			//$this->del();
877 1085
 			
878 1086
 			
879 1087
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
880
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1088
+			    if ($globalDebug) {
1089
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1090
+			    }
881 1091
 			    $SpotterLive = new SpotterLive($this->db);
882 1092
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
883 1093
 			    $SpotterLive->db = null;
884 1094
 			    //SpotterLive->deleteLiveSpotterData();
885
-			    if ($globalDebug) echo " Done\n";
1095
+			    if ($globalDebug) {
1096
+			    	echo " Done\n";
1097
+			    }
886 1098
 			    $this->last_delete_hourly = time();
887 1099
 			}
888 1100
 			
@@ -890,7 +1102,9 @@  discard block
 block discarded – undo
890 1102
 		    //$ignoreImport = false;
891 1103
 		}
892 1104
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
893
-		if ($send) return $this->all_flights[$id];
1105
+		if ($send) {
1106
+			return $this->all_flights[$id];
1107
+		}
894 1108
 	    }
895 1109
 	}
896 1110
     }
Please login to merge, or discard this patch.