Completed
Push — master ( 4407ee...8e145a )
by Yannick
06:51
created
accident-latest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 $page_url = $globalURL.'/accident-latest';
10 10
 
11
-if(!isset($_GET['limit']))
11
+if (!isset($_GET['limit']))
12 12
 {
13 13
 	$limit_start = 0;
14 14
 	$limit_end = 25;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 print '<div class="table column">';
35 35
 print '<p>'._("The table below shows the latest Accidents.").'</p>';
36
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident');
36
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'accident');
37 37
 //print_r($spotter_array);
38 38
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
Please login to merge, or discard this patch.
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) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
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);
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
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) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source)';
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);
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);
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.
scripts/daemon-spotter.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	else $aprs_ssid = 'FAM';
294 294
 	//else $aprs_ssid = 'PerlEx';
295 295
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
296
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
296
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
297 297
 	if ($aprs_full) $aprs_filter = '';
298 298
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
299 299
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
 sleep(1);
305 305
 if ($globalDebug) echo "SCAN MODE \n\n";
306 306
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
307
-$endtime = time()+$globalCronEnd;
307
+$endtime = time() + $globalCronEnd;
308 308
 $i = 1;
309 309
 $tt = array();
310 310
 // Delete all ATC
311 311
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
312
-	$ATC=new ATC($Connection->db);
312
+	$ATC = new ATC($Connection->db);
313 313
 }
314 314
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315 315
 	$ATC->deleteAll();
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
320
+    if (!$globalDaemon) $i = $endtime - time();
321 321
     // Delete old ATC
322 322
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333 333
 	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
334
+	    sleep($globalMinFetch - $max + 2);
335 335
 	}
336 336
     }
337 337
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	    //$buffer = $Common->getData($hosts[$id]);
344 344
 	    $buffer = $Common->getData($value['host']);
345 345
 	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
346
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
347
+	    $buffer = explode('\n', $buffer);
348 348
 	    foreach ($buffer as $line) {
349 349
     		if ($line != '' && count($line) > 7) {
350 350
     		    $line = explode(',', $line);
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374 374
 	    //$buffer = $Common->getData($hosts[$id]);
375 375
 	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    $reset = 0;
379 379
 	    foreach ($buffer as $line) {
380 380
     		if ($line != '') {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 			$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
385 385
 			$data['pilot_id'] = $line[1];
386 386
 			$data['pilot_name'] = $line[2];
387
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
387
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
388 388
 			$data['ident'] = $line[0]; // ident
389 389
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
390 390
 			$data['speed'] = $line[8]; // speed
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
401 401
 			if (isset($line[37])) $data['last_update'] = $line[37];
402 402
 		        $data['departure_airport_icao'] = $line[11];
403
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
403
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
404 404
 		        $data['arrival_airport_icao'] = $line[13];
405 405
 			$data['frequency'] = $line[4];
406 406
 			$data['type'] = $line[18];
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     			$data['id_source'] = $id_source;
410 410
 	    		//$data['arrival_airport_time'] = ;
411 411
 	    		if ($line[9] != '') {
412
-	    		    $aircraft_data = explode('/',$line[9]);
412
+	    		    $aircraft_data = explode('/', $line[9]);
413 413
 	    		    if (isset($aircraft_data[1])) {
414 414
 	    			$data['aircraft_icao'] = $aircraft_data[1];
415 415
 	    		    }
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
     			if ($line[3] == 'PILOT') $SI->add($data);
424 424
 			elseif ($line[3] == 'ATC') {
425 425
 				//print_r($data);
426
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
427
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
428
-				$typec = substr($data['ident'],-3);
426
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
427
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
428
+				$typec = substr($data['ident'], -3);
429 429
 				if ($typec == 'APP') $data['type'] = 'Approach';
430 430
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
431 431
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
437 437
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
438 438
 				if (!isset($data['source_name'])) $data['source_name'] = '';
439
-				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
439
+				echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
440 440
 			}
441 441
     			unset($data);
442 442
     		    }
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
     	    $last_exec[$id]['last'] = time();
448 448
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449 449
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
450
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
451 451
 	    if ($buffer != '') {
452
-	    $all_data = json_decode($buffer,true);
452
+	    $all_data = json_decode($buffer, true);
453 453
 	    if (isset($all_data['acList'])) {
454 454
 		$reset = 0;
455 455
 		foreach ($all_data['acList'] as $line) {
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506 506
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507 507
 	    $buffer = $Common->getData($value['host']);
508
-	    $all_data = json_decode($buffer,true);
508
+	    $all_data = json_decode($buffer, true);
509 509
 	    if (isset($all_data['planes'])) {
510 510
 		$reset = 0;
511 511
 		foreach ($all_data['planes'] as $key => $line) {
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
 		    $data['emergency'] = ''; // emergency
523 523
 		    $data['registration'] = $line[2];
524 524
 		    $data['aircraft_icao'] = $line[0];
525
-		    $deparr = explode('-',$line[1]);
525
+		    $deparr = explode('-', $line[1]);
526 526
 		    if (count($deparr) == 2) {
527 527
 			$data['departure_airport_icao'] = $deparr[0];
528 528
 			$data['arrival_airport_icao'] = $deparr[1];
529 529
 		    }
530
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
530
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
531 531
 	    	    $data['format_source'] = 'planeupdatefaa';
532 532
     		    $data['id_source'] = $id_source;
533 533
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
     	    $last_exec[$id]['last'] = time();
540 540
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541 541
 	    $buffer = $Common->getData($value['host']);
542
-	    $all_data = json_decode($buffer,true);
542
+	    $all_data = json_decode($buffer, true);
543 543
 	    if (isset($all_data['states'])) {
544 544
 		$reset = 0;
545 545
 		foreach ($all_data['states'] as $key => $line) {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    //$data['emergency'] = ''; // emergency
557 557
 		    //$data['registration'] = $line[2];
558 558
 		    //$data['aircraft_icao'] = $line[0];
559
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
559
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
560 560
 	    	    $data['format_source'] = 'opensky';
561 561
     		    $data['id_source'] = $id_source;
562 562
 		    $SI->add($data);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570 570
 	    //$buffer = $Common->getData($hosts[$id]);
571 571
 	    $buffer = $Common->getData($value['host']);
572
-	    $all_data = json_decode($buffer,true);
572
+	    $all_data = json_decode($buffer, true);
573 573
 	    if (!empty($all_data)) $reset = 0;
574 574
 	    foreach ($all_data as $key => $line) {
575 575
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602 602
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603 603
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
604
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
605 605
 	    //echo $buffer;
606
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
607
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
-	    $all_data = json_decode($buffer,true);
606
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
607
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
608
+	    $all_data = json_decode($buffer, true);
609 609
 	    if (json_last_error() != JSON_ERROR_NONE) {
610 610
 		die(json_last_error_msg());
611 611
 	    }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 			//$data['departure_airport_iata'] = $line[11];
629 629
 			//$data['arrival_airport_iata'] = $line[12];
630 630
 	    		//$data['emergency'] = ''; // emergency
631
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
631
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
632 632
 	    		$data['format_source'] = 'radarvirtueljson';
633 633
     			$data['id_source'] = $id_source;
634 634
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -643,14 +643,14 @@  discard block
 block discarded – undo
643 643
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644 644
 	    //$buffer = $Common->getData($hosts[$id]);
645 645
 	    $buffer = $Common->getData($value['host'].'?'.time());
646
-	    $all_data = json_decode(utf8_encode($buffer),true);
646
+	    $all_data = json_decode(utf8_encode($buffer), true);
647 647
 	    
648 648
 	    if (isset($all_data['pireps'])) {
649 649
 		$reset = 0;
650 650
 	        foreach ($all_data['pireps'] as $line) {
651 651
 		    $data = array();
652 652
 		    $data['id'] = $line['id'];
653
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
653
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
654 654
 		    $data['ident'] = $line['callsign']; // ident
655 655
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656 656
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 			$SI->add($data);
680 680
 		    //    print_r($data);
681 681
     		    } elseif ($line['icon'] == 'ct') {
682
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
683
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
684
-			$typec = substr($data['ident'],-3);
682
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
683
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
684
+			$typec = substr($data['ident'], -3);
685 685
 			$data['type'] = '';
686 686
 			if ($typec == 'APP') $data['type'] = 'Approach';
687 687
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
693 693
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
694 694
 			else $data['type'] = 'Observer';
695
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
695
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
696 696
 		    }
697 697
 		    unset($data);
698 698
 		}
@@ -704,14 +704,14 @@  discard block
 block discarded – undo
704 704
 	    //$buffer = $Common->getData($hosts[$id]);
705 705
 	    if ($globalDebug) echo 'Get Data...'."\n";
706 706
 	    $buffer = $Common->getData($value['host']);
707
-	    $all_data = json_decode($buffer,true);
707
+	    $all_data = json_decode($buffer, true);
708 708
 	    if ($buffer != '' && is_array($all_data)) {
709 709
 		$reset = 0;
710 710
 		foreach ($all_data as $line) {
711 711
 	    	    $data = array();
712 712
 	    	    //$data['id'] = $line['id']; // id not usable
713 713
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
714
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
715 715
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716 716
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717 717
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735 735
 		    if (isset($line['aircraftname'])) {
736 736
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
737
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
738
-	    		$aircraft_data = explode('-',$line['aircraftname']);
737
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
738
+	    		$aircraft_data = explode('-', $line['aircraftname']);
739 739
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740 740
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741 741
 	    		else {
742
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
742
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
743 743
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744 744
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
745 745
 	    		}
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 	    //$buffer = $Common->getData($hosts[$id]);
762 762
 	    if ($globalDebug) echo 'Get Data...'."\n";
763 763
 	    $buffer = $Common->getData($value['host']);
764
-	    $all_data = json_decode($buffer,true);
764
+	    $all_data = json_decode($buffer, true);
765 765
 	    if ($buffer != '' && is_array($all_data)) {
766 766
 		$reset = 0;
767 767
 		foreach ($all_data as $line) {
768 768
 	    	    $data = array();
769 769
 	    	    //$data['id'] = $line['id']; // id not usable
770 770
 	    	    $data['id'] = trim($line['flight_id']);
771
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
771
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
772 772
 	    	    $data['pilot_name'] = $line['pilot_name'];
773 773
 	    	    $data['pilot_id'] = $line['pilot_id'];
774 774
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -819,9 +819,9 @@  discard block
 block discarded – undo
819 819
 		    //$value = $formats[$nb];
820 820
 		    $format = $globalSources[$nb]['format'];
821 821
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
822
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
823 823
         	    } else {
824
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
824
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
825 825
 	    	    }
826 826
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827 827
         	    //echo $buffer."\n";
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830 830
 		    $error = false;
831 831
 		    //$SI::del();
832
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
832
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
833 833
 		    // SBS format is CSV format
834 834
 		    if ($buffer != '') {
835 835
 			$tt[$format] = 0;
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
                         } elseif ($format == 'flightgearsp') {
851 851
                     	    //echo $buffer."\n";
852 852
                     	    if (strlen($buffer) > 5) {
853
-				$line = explode(',',$buffer);
853
+				$line = explode(',', $buffer);
854 854
 				$data = array();
855 855
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
856
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
856
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
857 857
 				$data['ident'] = $line[6];
858 858
 				$data['aircraft_name'] = $line[7];
859 859
 				$data['longitude'] = $line[1];
@@ -864,21 +864,21 @@  discard block
 block discarded – undo
864 864
 				$data['datetime'] = date('Y-m-d H:i:s');
865 865
 				$data['format_source'] = 'flightgearsp';
866 866
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
867
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
867
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
868 868
 			    }
869 869
                         } elseif ($format == 'acars') {
870 870
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871 871
 			    $ACARS->add(trim($buffer));
872
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
872
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
873 873
 			    $ACARS->deleteLiveAcarsData();
874 874
 			} elseif ($format == 'flightgearmp') {
875
-			    if (substr($buffer,0,1) != '#') {
875
+			    if (substr($buffer, 0, 1) != '#') {
876 876
 				$data = array();
877 877
 				//echo $buffer."\n";
878
-				$line = explode(' ',$buffer);
878
+				$line = explode(' ', $buffer);
879 879
 				if (count($line) == 11) {
880
-				    $userserver = explode('@',$line[0]);
881
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
880
+				    $userserver = explode('@', $line[0]);
881
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
882 882
 				    $data['ident'] = $userserver[0];
883 883
 				    $data['registration'] = $userserver[0];
884 884
 				    $data['latitude'] = $line[4];
@@ -886,24 +886,24 @@  discard block
 block discarded – undo
886 886
 				    $data['altitude'] = $line[6];
887 887
 				    $data['datetime'] = date('Y-m-d H:i:s');
888 888
 				    $aircraft_type = $line[10];
889
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
890
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
889
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
890
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
891 891
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
892 892
 				}
893 893
 			    }
894 894
 			} elseif ($format == 'beast') {
895 895
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896 896
 			    die;
897
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
897
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
898 898
 			    $line = explode("\t", $buffer);
899
-			    for($k = 0; $k < count($line); $k=$k+2) {
899
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
900 900
 				$key = $line[$k];
901
-			        $lined[$key] = $line[$k+1];
901
+			        $lined[$key] = $line[$k + 1];
902 902
 			    }
903 903
     			    if (count($lined) > 3) {
904 904
     				$data['hex'] = $lined['hexid'];
905 905
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
-    				$data['datetime'] = date('Y-m-d H:i:s');;
906
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
907 907
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908 908
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909 909
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -921,24 +921,24 @@  discard block
 block discarded – undo
921 921
     			    } else $error = true;
922 922
 			} elseif ($format == 'aprs' && $use_aprs) {
923 923
 			    if ($aprs_connect == 0) {
924
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
924
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
925 925
 				$aprs_connect = 1;
926 926
 			    }
927
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
927
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
928 928
 				$aprs_last_tx = time();
929 929
 				$data_aprs = "# Keep alive";
930
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
930
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
931 931
 			    }
932 932
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
-			    $buffer = str_replace('APRS <- ','',$buffer);
934
-			    $buffer = str_replace('APRS -> ','',$buffer);
935
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
933
+			    $buffer = str_replace('APRS <- ', '', $buffer);
934
+			    $buffer = str_replace('APRS -> ', '', $buffer);
935
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
936 936
 				$line = $APRS->parse($buffer);
937 937
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
938 938
 				    $data = array();
939 939
 				    //print_r($line);
940 940
 				    $data['hex'] = $line['address'];
941
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
941
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
942 942
 				    //$data['datetime'] = date('Y-m-d H:i:s');
943 943
 				    $data['ident'] = $line['ident'];
944 944
 				    $data['latitude'] = $line['latitude'];
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 				    $currentdate = date('Y-m-d H:i:s');
959 959
 				    $aprsdate = strtotime($data['datetime']);
960 960
 				    // Accept data if time <= system time + 20s
961
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
961
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
962 962
 				    else {
963 963
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
964 964
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 				connect_all($sourceee);
1045 1045
 				$sourceee = array();
1046 1046
 				//connect_all($globalSources);
1047
-				$tt[$format]=0;
1047
+				$tt[$format] = 0;
1048 1048
 				break;
1049 1049
 			    }
1050 1050
 			}
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 		}
1053 1053
 	    } else {
1054 1054
 		$error = socket_strerror(socket_last_error());
1055
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1055
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1056 1056
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1057 1057
 			if (isset($globalDebug)) echo "Restarting...\n";
1058 1058
 			// Restart the script if possible
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 			    if ($globalDebug) echo "Shutdown all sockets...";
1061 1061
 			    
1062 1062
 			    foreach ($sockets as $sock) {
1063
-				@socket_shutdown($sock,2);
1063
+				@socket_shutdown($sock, 2);
1064 1064
 				@socket_close($sock);
1065 1065
 			    }
1066 1066
 			    
Please login to merge, or discard this patch.
statistics-airline-country.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Airline by Country");
7 7
 if (!isset($filter_name)) $filter_name = '';
8 8
 require_once('header.php');
9
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
10
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
9
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
10
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
11 11
 include('statistics-sub-menu.php'); 
12 12
 
13 13
 print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	  </div>
17 17
       <p>'._("Below are the <strong>Top 10</strong> countries that an airline belongs to.").'</p>';
18 18
 
19
-$airline_array = $Stats->countAllAirlineCountries(true,$filter_name,$year,$month);
19
+$airline_array = $Stats->countAllAirlineCountries(true, $filter_name, $year, $month);
20 20
 if (count($airline_array) > 0) {
21 21
 print '<div id="chartCountry" class="chart" width="100%"></div>
22 22
       	<script> 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             var data = google.visualization.arrayToDataTable([
27 27
             	["'._("Country").'", "'._("# of times").'"], ';
28 28
 $country_data = '';
29
-foreach($airline_array as $airline_item)
29
+foreach ($airline_array as $airline_item)
30 30
 {
31 31
 	$country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],';
32 32
 }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	print '</thead>';
61 61
 	print '<tbody>';
62 62
 	$i = 1;
63
-	foreach($airline_array as $airline_item)
63
+	foreach ($airline_array as $airline_item)
64 64
 	{
65 65
 		print '<tr>';
66 66
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-owner.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common owners");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
20
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
21
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
19
+setcookie('stats_airline_icao', $airline_icao);
20
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
21
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
22 22
 require_once('header.php');
23 23
 include('statistics-sub-menu.php');
24 24
 print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	</div>
28 28
 	<p>'._("Below are the <strong>Top 10</strong> most common owner.").'</p>';
29 29
  
30
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
30
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
31 31
 	print '<div id="chart" class="chart" width="100%"></div>
32 32
       	<script> 
33 33
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Owner").'", "'._("# of times").'"], ';
38 38
             	$owner_data = '';
39
-		foreach($owner_array as $owner_item)
39
+		foreach ($owner_array as $owner_item)
40 40
 		{
41 41
 			$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
42 42
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	print '</thead>';
70 70
 	print '<tbody>';
71 71
 	$i = 1;
72
-	foreach($owner_array as $owner_item)
72
+	foreach ($owner_array as $owner_item)
73 73
 	{
74 74
 		print '<tr>';
75 75
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-pilot.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
20
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
21
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
19
+setcookie('stats_airline_icao', $airline_icao);
20
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
21
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
22 22
 require_once('header.php');
23 23
 include('statistics-sub-menu.php');
24 24
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	</div>
29 29
 	<p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>';
30 30
 	  
31
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
31
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
32 32
 	print '<div id="chart" class="chart" width="100%"></div>
33 33
       	<script> 
34 34
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             var data = google.visualization.arrayToDataTable([
38 38
             	["'._("Pilot").'", "'._("# of times").'"], ';
39 39
             	$pilot_data = '';
40
-		foreach($pilot_array as $pilot_item)
40
+		foreach ($pilot_array as $pilot_item)
41 41
 		{
42 42
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
43 43
 		}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	print '</thead>';
71 71
 	print '<tbody>';
72 72
 	$i = 1;
73
-	foreach($pilot_array as $pilot_item)
73
+	foreach ($pilot_array as $pilot_item)
74 74
 	{
75 75
 		print '<tr>';
76 76
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,43 +82,43 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         }
127 127
 
128 128
 
129
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
129
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
130 130
 		global $globalStatsFilters;
131 131
 		if ($filter_name == '') $filter_name = $this->filter_name;
132 132
 		if ($year == '' && $month == '') {
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
135 135
 			try {
136 136
 				$sth = $this->db->prepare($query);
137
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-			} catch(PDOException $e) {
137
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+			} catch (PDOException $e) {
139 139
 				echo "error : ".$e->getMessage();
140 140
 			}
141 141
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
                 if (empty($all)) {
144 144
             	    $filters = array('airlines' => array($stats_airline));
145 145
             	    if ($filter_name != '') {
146
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
146
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
147 147
             	    }
148 148
             	    $Spotter = new Spotter($this->db);
149
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
149
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
150 150
                 }
151 151
                 return $all;
152 152
 	}
153
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
153
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
154 154
 		global $globalStatsFilters;
155 155
 		if ($filter_name == '') $filter_name = $this->filter_name;
156 156
 		if ($year == '' && $month == '') {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			try {
160 160
 				$sth = $this->db->prepare($query);
161 161
 				$sth->execute(array(':filter_name' => $filter_name));
162
-			} catch(PDOException $e) {
162
+			} catch (PDOException $e) {
163 163
 				echo "error : ".$e->getMessage();
164 164
 			}
165 165
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
             		$Spotter = new Spotter($this->db);
169 169
             		$filters = array();
170 170
             		if ($filter_name != '') {
171
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
171
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
172 172
 			}
173
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
173
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
174 174
                 }
175 175
                 return $all;
176 176
 	}
177
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
177
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
178 178
 		global $globalStatsFilters;
179 179
 		if ($filter_name == '') $filter_name = $this->filter_name;
180 180
 		if ($year == '' && $month == '') {
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
183 183
 			try {
184 184
 				$sth = $this->db->prepare($query);
185
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
186
-			} catch(PDOException $e) {
185
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
186
+			} catch (PDOException $e) {
187 187
 				echo "error : ".$e->getMessage();
188 188
 			}
189 189
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 		if (empty($all)) {
192 192
 			$filters = array('airlines' => array($stats_airline));
193 193
 			if ($filter_name != '') {
194
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
194
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
195 195
 			}
196 196
 			$Spotter = new Spotter($this->db);
197
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
197
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
198 198
 		}
199 199
 		return $all;
200 200
 	}
201 201
 
202
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
202
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
203 203
 		global $globalStatsFilters;
204 204
 		if ($filter_name == '') $filter_name = $this->filter_name;
205 205
 		if ($year == '' && $month == '') {
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
208 208
 			try {
209 209
 				$sth = $this->db->prepare($query);
210
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
211
-			} catch(PDOException $e) {
210
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
211
+			} catch (PDOException $e) {
212 212
 				echo "error : ".$e->getMessage();
213 213
 			}
214 214
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
                 if (empty($all)) {
217 217
 			$filters = array('airlines' => array($stats_airline));
218 218
 			if ($filter_name != '') {
219
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
219
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
220 220
 			}
221 221
 			$Spotter = new Spotter($this->db);
222
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
222
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
223 223
                 }
224 224
                 return $all;
225 225
 	}
@@ -230,23 +230,23 @@  discard block
 block discarded – undo
230 230
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
231 231
                  try {
232 232
                         $sth = $this->db->prepare($query);
233
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
234
-                } catch(PDOException $e) {
233
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
234
+                } catch (PDOException $e) {
235 235
                         echo "error : ".$e->getMessage();
236 236
                 }
237 237
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
238 238
                 if (empty($all)) {
239 239
 			$filters = array('airlines' => array($stats_airline));
240 240
 			if ($filter_name != '') {
241
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
241
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
242 242
 			}
243 243
 			$Spotter = new Spotter($this->db);
244
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
244
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
245 245
                 }
246 246
                 return $all;
247 247
 	}
248 248
 
249
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
249
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
250 250
 		global $globalStatsFilters;
251 251
 		if ($filter_name == '') $filter_name = $this->filter_name;
252 252
 		if ($year == '' && $month == '') {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			try {
256 256
 				$sth = $this->db->prepare($query);
257 257
 				$sth->execute(array(':filter_name' => $filter_name));
258
-			} catch(PDOException $e) {
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage();
260 260
 			}
261 261
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 	                $Spotter = new Spotter($this->db);
265 265
             		$filters = array();
266 266
             		if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 
270
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
270
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
274
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
275 275
 		global $globalStatsFilters;
276 276
 		if ($filter_name == '') $filter_name = $this->filter_name;
277 277
 		if ($year == '' && $month == '') {
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
280 280
 			try {
281 281
 				$sth = $this->db->prepare($query);
282
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
283
-			} catch(PDOException $e) {
282
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
283
+			} catch (PDOException $e) {
284 284
 				echo "error : ".$e->getMessage();
285 285
 			}
286 286
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
                 if (empty($all)) {
289 289
 			$filters = array('airlines' => array($stats_airline));
290 290
 			if ($filter_name != '') {
291
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
291
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
292 292
 			}
293 293
 	                $Spotter = new Spotter($this->db);
294
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
294
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
295 295
                 }
296 296
                 return $all;
297 297
 	}
298
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
298
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
299 299
 		global $globalStatsFilters;
300 300
 		if ($filter_name == '') $filter_name = $this->filter_name;
301 301
 		if ($year == '' && $month == '') {
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
304 304
 			 try {
305 305
 				$sth = $this->db->prepare($query);
306
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
307
-			} catch(PDOException $e) {
306
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
307
+			} catch (PDOException $e) {
308 308
 				echo "error : ".$e->getMessage();
309 309
 			}
310 310
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
 		if (empty($all)) {
313 313
 			$filters = array('airlines' => array($stats_airline));
314 314
 			if ($filter_name != '') {
315
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
315
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
316 316
 			}
317 317
 			$Spotter = new Spotter($this->db);
318
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
318
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
319 319
 		}
320 320
 		return $all;
321 321
 	}
322
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
322
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
323 323
 		$Connection = new Connection();
324 324
 		if ($filter_name == '') $filter_name = $this->filter_name;
325 325
 		if ($Connection->tableExists('countries')) {
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
329 329
 				 try {
330 330
 					$sth = $this->db->prepare($query);
331
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
332
-				} catch(PDOException $e) {
331
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
332
+				} catch (PDOException $e) {
333 333
 					echo "error : ".$e->getMessage();
334 334
 				}
335 335
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			return array();
346 346
 		}
347 347
 	}
348
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
348
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		global $globalStatsFilters;
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($year == '' && $month == '') {
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
354 354
 			try {
355 355
 				$sth = $this->db->prepare($query);
356
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
357
-			} catch(PDOException $e) {
356
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
357
+			} catch (PDOException $e) {
358 358
 				echo "error : ".$e->getMessage();
359 359
 			}
360 360
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
 		if (empty($all)) {
363 363
 			$filters = array('airlines' => array($stats_airline));
364 364
 			if ($filter_name != '') {
365
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
365
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
366 366
 			}
367 367
 			$Spotter = new Spotter($this->db);
368
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
368
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
369 369
 		}
370 370
 		return $all;
371 371
 	}
372 372
 
373
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
373
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
374 374
 		global $globalStatsFilters;
375 375
 		if ($filter_name == '') $filter_name = $this->filter_name;
376 376
 		if ($year == '' && $month == '') {
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
379 379
 			try {
380 380
 				$sth = $this->db->prepare($query);
381
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
382
-			} catch(PDOException $e) {
381
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
382
+			} catch (PDOException $e) {
383 383
 				echo "error : ".$e->getMessage();
384 384
 			}
385 385
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
                 if (empty($all)) {
388 388
 			$filters = array('airlines' => array($stats_airline));
389 389
 			if ($filter_name != '') {
390
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
390
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
391 391
 			}
392 392
             		$Spotter = new Spotter($this->db);
393
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
393
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
394 394
                 }
395 395
                 return $all;
396 396
 	}
397
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
397
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
398 398
 		global $globalStatsFilters;
399 399
 		if ($filter_name == '') $filter_name = $this->filter_name;
400 400
 		if ($year == '' && $month == '') {
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
403 403
 			try {
404 404
 				$sth = $this->db->prepare($query);
405
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
406
-			} catch(PDOException $e) {
405
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
406
+			} catch (PDOException $e) {
407 407
 				echo "error : ".$e->getMessage();
408 408
 			}
409 409
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
                 if (empty($all)) {
412 412
 			$filters = array('airlines' => array($stats_airline));
413 413
             		if ($filter_name != '') {
414
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
414
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
415 415
 			}
416 416
             		$Spotter = new Spotter($this->db);
417
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
418
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
417
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
418
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
419 419
         		$all = array();
420 420
         		foreach ($pall as $value) {
421 421
         			$icao = $value['airport_departure_icao'];
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
         		foreach ($all as $key => $row) {
433 433
         			$count[$key] = $row['airport_departure_icao_count'];
434 434
         		}
435
-        		array_multisort($count,SORT_DESC,$all);
435
+        		array_multisort($count, SORT_DESC, $all);
436 436
                 }
437 437
                 return $all;
438 438
 	}
439
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
439
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
440 440
 		global $globalStatsFilters;
441 441
 		if ($filter_name == '') $filter_name = $this->filter_name;
442 442
 		if ($year == '' && $month == '') {
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
445 445
 			try {
446 446
 				$sth = $this->db->prepare($query);
447
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
448
-			} catch(PDOException $e) {
447
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
448
+			} catch (PDOException $e) {
449 449
 				echo "error : ".$e->getMessage();
450 450
 			}
451 451
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 		if (empty($all)) {
454 454
 			$filters = array('airlines' => array($stats_airline));
455 455
 			if ($filter_name != '') {
456
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
456
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
457 457
 			}
458 458
 			$Spotter = new Spotter($this->db);
459
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
460
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
459
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
460
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
461 461
         		$all = array();
462 462
         		foreach ($pall as $value) {
463 463
         			$icao = $value['airport_arrival_icao'];
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
         		foreach ($all as $key => $row) {
475 475
         			$count[$key] = $row['airport_arrival_icao_count'];
476 476
         		}
477
-        		array_multisort($count,SORT_DESC,$all);
477
+        		array_multisort($count, SORT_DESC, $all);
478 478
                 }
479 479
  
480 480
                 return $all;
481 481
 	}
482
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
482
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
483 483
 		global $globalDBdriver, $globalStatsFilters;
484 484
 		if ($filter_name == '') $filter_name = $this->filter_name;
485 485
 		if ($globalDBdriver == 'mysql') {
@@ -489,18 +489,18 @@  discard block
 block discarded – undo
489 489
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
490 490
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 491
 		}
492
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
493 493
                  try {
494 494
                         $sth = $this->db->prepare($query);
495 495
                         $sth->execute($query_data);
496
-                } catch(PDOException $e) {
496
+                } catch (PDOException $e) {
497 497
                         echo "error : ".$e->getMessage();
498 498
                 }
499 499
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
500 500
                 if (empty($all)) {
501 501
 			$filters = array('airlines' => array($stats_airline));
502 502
 			if ($filter_name != '') {
503
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
503
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
504 504
 			}
505 505
             		$Spotter = new Spotter($this->db);
506 506
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -509,29 +509,29 @@  discard block
 block discarded – undo
509 509
                 return $all;
510 510
 	}
511 511
 	
512
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
512
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
513 513
 		global $globalStatsFilters;
514 514
 		if ($filter_name == '') $filter_name = $this->filter_name;
515 515
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
516
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
517 517
                  try {
518 518
                         $sth = $this->db->prepare($query);
519 519
                         $sth->execute($query_data);
520
-                } catch(PDOException $e) {
520
+                } catch (PDOException $e) {
521 521
                         echo "error : ".$e->getMessage();
522 522
                 }
523 523
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
524 524
                 if (empty($all)) {
525 525
 			$filters = array('airlines' => array($stats_airline));
526 526
 			if ($filter_name != '') {
527
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
527
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
528 528
 			}
529 529
             		$Spotter = new Spotter($this->db);
530 530
             		$all = $Spotter->countAllDatesLastMonth($filters);
531 531
                 }
532 532
                 return $all;
533 533
 	}
534
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
534
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
535 535
 		global $globalDBdriver, $globalStatsFilters;
536 536
 		if ($filter_name == '') $filter_name = $this->filter_name;
537 537
 		if ($globalDBdriver == 'mysql') {
@@ -539,40 +539,40 @@  discard block
 block discarded – undo
539 539
 		} else {
540 540
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
541 541
 		}
542
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLast7Days($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDates($stats_airline = '',$filter_name = '') {
560
+	public function countAllDates($stats_airline = '', $filter_name = '') {
561 561
 		global $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
564
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
564
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
565 565
                  try {
566 566
                         $sth = $this->db->prepare($query);
567 567
                         $sth->execute($query_data);
568
-                } catch(PDOException $e) {
568
+                } catch (PDOException $e) {
569 569
                         echo "error : ".$e->getMessage();
570 570
                 }
571 571
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
572 572
                 if (empty($all)) {
573 573
 			$filters = array('airlines' => array($stats_airline));
574 574
 			if ($filter_name != '') {
575
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
575
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
576 576
 			}
577 577
             		$Spotter = new Spotter($this->db);
578 578
             		$all = $Spotter->countAllDates($filters);
@@ -587,35 +587,35 @@  discard block
 block discarded – undo
587 587
                  try {
588 588
                         $sth = $this->db->prepare($query);
589 589
                         $sth->execute($query_data);
590
-                } catch(PDOException $e) {
590
+                } catch (PDOException $e) {
591 591
                         echo "error : ".$e->getMessage();
592 592
                 }
593 593
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
594 594
                 if (empty($all)) {
595 595
             		$filters = array();
596 596
             		if ($filter_name != '') {
597
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
597
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
598 598
 			}
599 599
             		$Spotter = new Spotter($this->db);
600 600
             		$all = $Spotter->countAllDatesByAirlines($filters);
601 601
                 }
602 602
                 return $all;
603 603
 	}
604
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
604
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
605 605
 		global $globalStatsFilters;
606 606
 		if ($filter_name == '') $filter_name = $this->filter_name;
607 607
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
608 608
                  try {
609 609
                         $sth = $this->db->prepare($query);
610 610
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
611
-                } catch(PDOException $e) {
611
+                } catch (PDOException $e) {
612 612
                         echo "error : ".$e->getMessage();
613 613
                 }
614 614
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
615 615
                 if (empty($all)) {
616 616
 			$filters = array('airlines' => array($stats_airline));
617 617
 			if ($filter_name != '') {
618
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
618
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
619 619
 			}
620 620
             		$Spotter = new Spotter($this->db);
621 621
             		$all = $Spotter->countAllMonths($filters);
@@ -629,21 +629,21 @@  discard block
 block discarded – undo
629 629
                  try {
630 630
                         $sth = $this->db->prepare($query);
631 631
                         $sth->execute(array(':filter_name' => $filter_name));
632
-                } catch(PDOException $e) {
632
+                } catch (PDOException $e) {
633 633
                         echo "error : ".$e->getMessage();
634 634
                 }
635 635
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
636 636
                 if (empty($all)) {
637 637
             		$filters = array();
638 638
             		if ($filter_name != '') {
639
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
639
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
640 640
 			}
641 641
             		$Spotter = new Spotter($this->db);
642 642
             		$all = $Spotter->countAllMilitaryMonths($filters);
643 643
                 }
644 644
                 return $all;
645 645
 	}
646
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
646
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
647 647
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
648 648
 		if ($filter_name == '') $filter_name = $this->filter_name;
649 649
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -660,82 +660,82 @@  discard block
 block discarded – undo
660 660
                  try {
661 661
                         $sth = $this->db->prepare($query);
662 662
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
663
-                } catch(PDOException $e) {
663
+                } catch (PDOException $e) {
664 664
                         echo "error : ".$e->getMessage();
665 665
                 }
666 666
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
667 667
                 if (empty($all)) {
668 668
 			$filters = array('airlines' => array($stats_airline));
669 669
 			if ($filter_name != '') {
670
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
670
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
671 671
 			}
672 672
             		$Spotter = new Spotter($this->db);
673
-            		$all = $Spotter->countAllHours($orderby,$filters);
673
+            		$all = $Spotter->countAllHours($orderby, $filters);
674 674
                 }
675 675
                 return $all;
676 676
 	}
677 677
 	
678
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
678
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
679 679
 		global $globalStatsFilters;
680 680
 		if ($filter_name == '') $filter_name = $this->filter_name;
681 681
 		if ($year == '') $year = date('Y');
682
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
682
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
683 683
 		if (empty($all)) {
684 684
 			$filters = array('airlines' => array($stats_airline));
685 685
 			if ($filter_name != '') {
686
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
686
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
687 687
 			}
688 688
 			$Spotter = new Spotter($this->db);
689
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
689
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
690 690
 		}
691 691
 		return $all;
692 692
 	}
693
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
693
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
694 694
 		global $globalStatsFilters;
695 695
 		if ($filter_name == '') $filter_name = $this->filter_name;
696 696
 		if ($year == '') $year = date('Y');
697
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
697
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
698 698
 		if (empty($all)) {
699 699
 		        $filters = array();
700 700
             		if ($filter_name != '') {
701
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
701
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
702 702
 			}
703 703
 			$Spotter = new Spotter($this->db);
704
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
704
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
705 705
 		}
706 706
 		return $all;
707 707
 	}
708
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
708
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
709 709
 		global $globalStatsFilters;
710 710
 		if ($filter_name == '') $filter_name = $this->filter_name;
711 711
 		if ($year == '') $year = date('Y');
712
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
712
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
713 713
 		if (empty($all)) {
714 714
 			$filters = array('airlines' => array($stats_airline));
715 715
 			if ($filter_name != '') {
716
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
716
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
717 717
 			}
718 718
 			$Spotter = new Spotter($this->db);
719
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
719
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
720 720
 		}
721 721
 		return $all;
722 722
 	}
723
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
723
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
724 724
 		global $globalStatsFilters;
725 725
 		if ($filter_name == '') $filter_name = $this->filter_name;
726 726
 		if ($year == '') $year = date('Y');
727
-		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
727
+		$all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
728 728
 		if (empty($all)) {
729 729
 			$filters = array('airlines' => array($stats_airline));
730 730
 			if ($filter_name != '') {
731
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
731
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
732 732
 			}
733 733
 			$Spotter = new Spotter($this->db);
734
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
734
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
735 735
 		}
736 736
 		return $all;
737 737
 	}
738
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
738
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
739 739
 		global $globalStatsFilters;
740 740
 		if ($filter_name == '') $filter_name = $this->filter_name;
741 741
 		if ($year == '' && $month == '') {
@@ -743,23 +743,23 @@  discard block
 block discarded – undo
743 743
 			try {
744 744
 				$sth = $this->db->prepare($query);
745 745
 				$sth->execute(array(':filter_name' => $filter_name));
746
-			} catch(PDOException $e) {
746
+			} catch (PDOException $e) {
747 747
 				echo "error : ".$e->getMessage();
748 748
 			}
749 749
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
750 750
 			$all = $result[0]['nb_airline'];
751
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
751
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
752 752
 		if (empty($all)) {
753 753
             		$filters = array();
754 754
             		if ($filter_name != '') {
755
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
755
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
756 756
 			}
757 757
 			$Spotter = new Spotter($this->db);
758
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
758
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
759 759
 		}
760 760
 		return $all;
761 761
 	}
762
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
762
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
763 763
 		global $globalStatsFilters;
764 764
 		if ($filter_name == '') $filter_name = $this->filter_name;
765 765
 		if ($year == '') $year = date('Y');
@@ -774,83 +774,83 @@  discard block
 block discarded – undo
774 774
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
775 775
                 $all = $result[0]['nb_owner'];
776 776
                 */
777
-		$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
777
+		$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
778 778
 		if (empty($all)) {
779 779
 			$filters = array('airlines' => array($stats_airline));
780 780
 			if ($filter_name != '') {
781
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
781
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
782 782
 			}
783 783
 			$Spotter = new Spotter($this->db);
784
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
784
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
785 785
 		}
786 786
 		return $all;
787 787
 	}
788
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
788
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
789 789
 		global $globalStatsFilters;
790 790
 		if ($filter_name == '') $filter_name = $this->filter_name;
791 791
 		if ($year == '') $year = date('Y');
792
-		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
792
+		$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
793 793
 		if (empty($all)) {
794 794
 			$filters = array('airlines' => array($stats_airline));
795 795
 			if ($filter_name != '') {
796
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
796
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
797 797
 			}
798 798
 			$Spotter = new Spotter($this->db);
799
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
799
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
800 800
 		}
801 801
 		return $all;
802 802
 	}
803 803
 
804
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
804
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
805 805
 		if ($filter_name == '') $filter_name = $this->filter_name;
806 806
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
807
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
807
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
808 808
                  try {
809 809
                         $sth = $this->db->prepare($query);
810 810
                         $sth->execute($query_values);
811
-                } catch(PDOException $e) {
811
+                } catch (PDOException $e) {
812 812
                         echo "error : ".$e->getMessage();
813 813
                 }
814 814
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
815 815
                 return $all;
816 816
 	}
817
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
817
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
818 818
 		if ($filter_name == '') $filter_name = $this->filter_name;
819 819
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
820
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
820
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
821 821
                  try {
822 822
                         $sth = $this->db->prepare($query);
823 823
                         $sth->execute($query_values);
824
-                } catch(PDOException $e) {
824
+                } catch (PDOException $e) {
825 825
                         echo "error : ".$e->getMessage();
826 826
                 }
827 827
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
828 828
                 return $all;
829 829
         }
830
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
830
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
831 831
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 832
     		global $globalArchiveMonths, $globalDBdriver;
833 833
     		if ($globalDBdriver == 'mysql') {
834 834
     			if ($month == '') {
835 835
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
836
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
836
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
837 837
 			} else {
838 838
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
839
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
839
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
840 840
 			}
841 841
 		} else {
842 842
 			if ($month == '') {
843 843
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
844
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
844
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
845 845
 			} else {
846 846
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
847
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
847
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
848 848
 			}
849 849
                 }
850 850
                  try {
851 851
                         $sth = $this->db->prepare($query);
852 852
                         $sth->execute($query_values);
853
-                } catch(PDOException $e) {
853
+                } catch (PDOException $e) {
854 854
                         echo "error : ".$e->getMessage();
855 855
                 }
856 856
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                  try {
869 869
                         $sth = $this->db->prepare($query);
870 870
                         $sth->execute($query_values);
871
-                } catch(PDOException $e) {
871
+                } catch (PDOException $e) {
872 872
                         echo "error : ".$e->getMessage();
873 873
                 }
874 874
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
                  try {
886 886
                         $sth = $this->db->prepare($query);
887 887
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
888
-                } catch(PDOException $e) {
888
+                } catch (PDOException $e) {
889 889
                         echo "error : ".$e->getMessage();
890 890
                 }
891 891
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
                  try {
903 903
                         $sth = $this->db->prepare($query);
904 904
                         $sth->execute(array(':filter_name' => $filter_name));
905
-                } catch(PDOException $e) {
905
+                } catch (PDOException $e) {
906 906
                         echo "error : ".$e->getMessage();
907 907
                 }
908 908
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                  try {
920 920
                         $sth = $this->db->prepare($query);
921 921
                         $sth->execute(array(':filter_name' => $filter_name));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         echo "error : ".$e->getMessage();
924 924
                 }
925 925
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -936,14 +936,14 @@  discard block
 block discarded – undo
936 936
                  try {
937 937
                         $sth = $this->db->prepare($query);
938 938
                         $sth->execute(array(':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
939
+                } catch (PDOException $e) {
940 940
                         echo "error : ".$e->getMessage();
941 941
                 }
942 942
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
943 943
                 return $all[0]['total'];
944 944
         }
945 945
 
946
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
946
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
947 947
 		global $globalDBdriver;
948 948
 		if ($filter_name == '') $filter_name = $this->filter_name;
949 949
 		if ($globalDBdriver == 'mysql') {
@@ -951,15 +951,15 @@  discard block
 block discarded – undo
951 951
                 } else {
952 952
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
953 953
 		}
954
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
954
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955 955
                  try {
956 956
                         $sth = $this->db->prepare($query);
957 957
                         $sth->execute($query_values);
958
-                } catch(PDOException $e) {
958
+                } catch (PDOException $e) {
959 959
                         return "error : ".$e->getMessage();
960 960
                 }
961 961
         }
962
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
962
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
963 963
 		global $globalDBdriver;
964 964
 		if ($filter_name == '') $filter_name = $this->filter_name;
965 965
 		if ($globalDBdriver == 'mysql') {
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
969 969
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
970 970
                 }
971
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
971
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
972 972
                  try {
973 973
                         $sth = $this->db->prepare($query);
974 974
                         $sth->execute($query_values);
975
-                } catch(PDOException $e) {
975
+                } catch (PDOException $e) {
976 976
                         return "error : ".$e->getMessage();
977 977
                 }
978 978
         }
@@ -996,75 +996,75 @@  discard block
 block discarded – undo
996 996
         }
997 997
         */
998 998
 
999
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
999
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1000 1000
 		global $globalDBdriver;
1001 1001
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1002 1002
 		$query_values = array();
1003 1003
 		if ($globalDBdriver == 'mysql') {
1004 1004
 			if ($year != '') {
1005 1005
 				$query .= ' AND YEAR(stats_date) = :year';
1006
-				$query_values = array_merge($query_values,array(':year' => $year));
1006
+				$query_values = array_merge($query_values, array(':year' => $year));
1007 1007
 			}
1008 1008
 			if ($month != '') {
1009 1009
 				$query .= ' AND MONTH(stats_date) = :month';
1010
-				$query_values = array_merge($query_values,array(':month' => $month));
1010
+				$query_values = array_merge($query_values, array(':month' => $month));
1011 1011
 			}
1012 1012
 			if ($day != '') {
1013 1013
 				$query .= ' AND DAY(stats_date) = :day';
1014
-				$query_values = array_merge($query_values,array(':day' => $day));
1014
+				$query_values = array_merge($query_values, array(':day' => $day));
1015 1015
 			}
1016 1016
 		} else {
1017 1017
 			if ($year != '') {
1018 1018
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1019
-				$query_values = array_merge($query_values,array(':year' => $year));
1019
+				$query_values = array_merge($query_values, array(':year' => $year));
1020 1020
 			}
1021 1021
 			if ($month != '') {
1022 1022
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1023
-				$query_values = array_merge($query_values,array(':month' => $month));
1023
+				$query_values = array_merge($query_values, array(':month' => $month));
1024 1024
 			}
1025 1025
 			if ($day != '') {
1026 1026
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1027
-				$query_values = array_merge($query_values,array(':day' => $day));
1027
+				$query_values = array_merge($query_values, array(':day' => $day));
1028 1028
 			}
1029 1029
 		}
1030 1030
 		$query .= " ORDER BY source_name";
1031
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1031
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1032 1032
 		try {
1033 1033
 			$sth = $this->db->prepare($query);
1034 1034
 			$sth->execute($query_values);
1035
-		} catch(PDOException $e) {
1035
+		} catch (PDOException $e) {
1036 1036
 			echo "error : ".$e->getMessage();
1037 1037
 		}
1038 1038
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1039 1039
 		return $all;
1040 1040
 	}
1041 1041
 
1042
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1042
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1043 1043
 		global $globalDBdriver;
1044 1044
 		if ($globalDBdriver == 'mysql') {
1045 1045
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1046 1046
 		} else {
1047 1047
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1048 1048
                 }
1049
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1049
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1050 1050
                  try {
1051 1051
                         $sth = $this->db->prepare($query);
1052 1052
                         $sth->execute($query_values);
1053
-                } catch(PDOException $e) {
1053
+                } catch (PDOException $e) {
1054 1054
                         return "error : ".$e->getMessage();
1055 1055
                 }
1056 1056
         }
1057
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1057
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1058 1058
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1059
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1059
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1060 1060
                  try {
1061 1061
                         $sth = $this->db->prepare($query);
1062 1062
                         $sth->execute($query_values);
1063
-                } catch(PDOException $e) {
1063
+                } catch (PDOException $e) {
1064 1064
                         return "error : ".$e->getMessage();
1065 1065
                 }
1066 1066
         }
1067
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1067
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1068 1068
 		global $globalDBdriver;
1069 1069
 		if ($globalDBdriver == 'mysql') {
1070 1070
 			if ($reset) {
@@ -1079,15 +1079,15 @@  discard block
 block discarded – undo
1079 1079
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1080 1080
 			}
1081 1081
 		}
1082
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1082
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1083 1083
                  try {
1084 1084
                         $sth = $this->db->prepare($query);
1085 1085
                         $sth->execute($query_values);
1086
-                } catch(PDOException $e) {
1086
+                } catch (PDOException $e) {
1087 1087
                         return "error : ".$e->getMessage();
1088 1088
                 }
1089 1089
         }
1090
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1090
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1091 1091
 		global $globalDBdriver;
1092 1092
 		if ($globalDBdriver == 'mysql') {
1093 1093
 			if ($reset) {
@@ -1102,15 +1102,15 @@  discard block
 block discarded – undo
1102 1102
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1103 1103
 			}
1104 1104
 		}
1105
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1105
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1106 1106
                  try {
1107 1107
                         $sth = $this->db->prepare($query);
1108 1108
                         $sth->execute($query_values);
1109
-                } catch(PDOException $e) {
1109
+                } catch (PDOException $e) {
1110 1110
                         return "error : ".$e->getMessage();
1111 1111
                 }
1112 1112
         }
1113
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1113
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1114 1114
 		global $globalDBdriver;
1115 1115
 		if ($globalDBdriver == 'mysql') {
1116 1116
 			if ($reset) {
@@ -1125,15 +1125,15 @@  discard block
 block discarded – undo
1125 1125
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1126 1126
 			}
1127 1127
 		}
1128
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1128
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1129 1129
                  try {
1130 1130
                         $sth = $this->db->prepare($query);
1131 1131
                         $sth->execute($query_values);
1132
-                } catch(PDOException $e) {
1132
+                } catch (PDOException $e) {
1133 1133
                         return "error : ".$e->getMessage();
1134 1134
                 }
1135 1135
         }
1136
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1136
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1137 1137
 		global $globalDBdriver;
1138 1138
 		if ($globalDBdriver == 'mysql') {
1139 1139
 			if ($reset) {
@@ -1148,15 +1148,15 @@  discard block
 block discarded – undo
1148 1148
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1149 1149
 			}
1150 1150
 		}
1151
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1151
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1152 1152
                  try {
1153 1153
                         $sth = $this->db->prepare($query);
1154 1154
                         $sth->execute($query_values);
1155
-                } catch(PDOException $e) {
1155
+                } catch (PDOException $e) {
1156 1156
                         return "error : ".$e->getMessage();
1157 1157
                 }
1158 1158
         }
1159
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1159
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1160 1160
 		global $globalDBdriver;
1161 1161
 		if ($globalDBdriver == 'mysql') {
1162 1162
 			if ($reset) {
@@ -1171,15 +1171,15 @@  discard block
 block discarded – undo
1171 1171
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1172 1172
 			}
1173 1173
 		}
1174
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1174
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1175 1175
                  try {
1176 1176
                         $sth = $this->db->prepare($query);
1177 1177
                         $sth->execute($query_values);
1178
-                } catch(PDOException $e) {
1178
+                } catch (PDOException $e) {
1179 1179
                         return "error : ".$e->getMessage();
1180 1180
                 }
1181 1181
         }
1182
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1182
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1183 1183
 		global $globalDBdriver;
1184 1184
 		if ($globalDBdriver == 'mysql') {
1185 1185
 			if ($reset) {
@@ -1194,15 +1194,15 @@  discard block
 block discarded – undo
1194 1194
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1195 1195
 			}
1196 1196
 		}
1197
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1197
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1198 1198
                  try {
1199 1199
                         $sth = $this->db->prepare($query);
1200 1200
                         $sth->execute($query_values);
1201
-                } catch(PDOException $e) {
1201
+                } catch (PDOException $e) {
1202 1202
                         return "error : ".$e->getMessage();
1203 1203
                 }
1204 1204
         }
1205
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1205
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1206 1206
 		global $globalDBdriver;
1207 1207
 		if ($globalDBdriver == 'mysql') {
1208 1208
 			if ($reset) {
@@ -1217,15 +1217,15 @@  discard block
 block discarded – undo
1217 1217
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1218 1218
 			}
1219 1219
 		}
1220
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1220
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1221 1221
                  try {
1222 1222
                         $sth = $this->db->prepare($query);
1223 1223
                         $sth->execute($query_values);
1224
-                } catch(PDOException $e) {
1224
+                } catch (PDOException $e) {
1225 1225
                         return "error : ".$e->getMessage();
1226 1226
                 }
1227 1227
         }
1228
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1228
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1229 1229
 		global $globalDBdriver;
1230 1230
 		if ($airport_icao != '') {
1231 1231
 			if ($globalDBdriver == 'mysql') {
@@ -1241,16 +1241,16 @@  discard block
 block discarded – undo
1241 1241
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1242 1242
 				}
1243 1243
 			}
1244
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1244
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1245 1245
 			try {
1246 1246
 				$sth = $this->db->prepare($query);
1247 1247
 				$sth->execute($query_values);
1248
-			} catch(PDOException $e) {
1248
+			} catch (PDOException $e) {
1249 1249
 				return "error : ".$e->getMessage();
1250 1250
 			}
1251 1251
                 }
1252 1252
         }
1253
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1253
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1254 1254
 		global $globalDBdriver;
1255 1255
 		if ($airport_icao != '') {
1256 1256
 			if ($globalDBdriver == 'mysql') {
@@ -1258,16 +1258,16 @@  discard block
 block discarded – undo
1258 1258
 			} else {
1259 1259
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1260 1260
 			}
1261
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1261
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1262 1262
 			 try {
1263 1263
 				$sth = $this->db->prepare($query);
1264 1264
 				$sth->execute($query_values);
1265
-			} catch(PDOException $e) {
1265
+			} catch (PDOException $e) {
1266 1266
 				return "error : ".$e->getMessage();
1267 1267
 			}
1268 1268
                 }
1269 1269
         }
1270
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1270
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1271 1271
 		global $globalDBdriver;
1272 1272
 		if ($airport_icao != '') {
1273 1273
 			if ($globalDBdriver == 'mysql') {
@@ -1283,16 +1283,16 @@  discard block
 block discarded – undo
1283 1283
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1284 1284
 				}
1285 1285
 			}
1286
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1286
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1287 1287
 			 try {
1288 1288
                     		$sth = $this->db->prepare($query);
1289 1289
 	                        $sth->execute($query_values);
1290
-    		        } catch(PDOException $e) {
1290
+    		        } catch (PDOException $e) {
1291 1291
             		        return "error : ".$e->getMessage();
1292 1292
 	                }
1293 1293
 	        }
1294 1294
         }
1295
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1295
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1296 1296
 		global $globalDBdriver;
1297 1297
 		if ($airport_icao != '') {
1298 1298
 			if ($globalDBdriver == 'mysql') {
@@ -1300,11 +1300,11 @@  discard block
 block discarded – undo
1300 1300
 			} else {
1301 1301
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1302 1302
 			}
1303
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1303
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1304 1304
 			try {
1305 1305
 				$sth = $this->db->prepare($query);
1306 1306
 				$sth->execute($query_values);
1307
-			} catch(PDOException $e) {
1307
+			} catch (PDOException $e) {
1308 1308
 				return "error : ".$e->getMessage();
1309 1309
 			}
1310 1310
                 }
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
                  try {
1317 1317
                         $sth = $this->db->prepare($query);
1318 1318
                         $sth->execute($query_values);
1319
-                } catch(PDOException $e) {
1319
+                } catch (PDOException $e) {
1320 1320
                         return "error : ".$e->getMessage();
1321 1321
                 }
1322 1322
         }
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
                  try {
1327 1327
                         $sth = $this->db->prepare($query);
1328 1328
                         $sth->execute($query_values);
1329
-                } catch(PDOException $e) {
1329
+                } catch (PDOException $e) {
1330 1330
                         return "error : ".$e->getMessage();
1331 1331
                 }
1332 1332
         }
@@ -1336,13 +1336,13 @@  discard block
 block discarded – undo
1336 1336
                  try {
1337 1337
                         $sth = $this->db->prepare($query);
1338 1338
                         $sth->execute($query_values);
1339
-                } catch(PDOException $e) {
1339
+                } catch (PDOException $e) {
1340 1340
                         return "error : ".$e->getMessage();
1341 1341
                 }
1342 1342
         }
1343 1343
         
1344 1344
         public function addOldStats() {
1345
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1345
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1346 1346
     		$Common = new Common();
1347 1347
     		$Connection = new Connection();
1348 1348
     		date_default_timezone_set('UTC');
@@ -1359,40 +1359,40 @@  discard block
 block discarded – undo
1359 1359
 			$Spotter = new Spotter($this->db);
1360 1360
 
1361 1361
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1362
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1362
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1363 1363
 			foreach ($alldata as $number) {
1364
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1364
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1365 1365
 			}
1366 1366
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1367
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1367
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1368 1368
 			foreach ($alldata as $number) {
1369
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1369
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1370 1370
 			}
1371 1371
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1372
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1372
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1373 1373
 			foreach ($alldata as $number) {
1374
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1374
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1375 1375
 			}
1376 1376
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1377
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1377
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1378 1378
 			foreach ($alldata as $number) {
1379
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1379
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1380 1380
 			}
1381 1381
 			if ($globalDebug) echo 'Count all owners...'."\n";
1382
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1382
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1383 1383
 			foreach ($alldata as $number) {
1384
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1384
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1385 1385
 			}
1386 1386
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1387
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1387
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1388 1388
 			foreach ($alldata as $number) {
1389
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1389
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1390 1390
 			}
1391 1391
 			
1392 1392
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1393
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1393
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1394 1394
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1395
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1395
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1396 1396
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1397 1397
 	        	$alldata = array();
1398 1398
 	        	
@@ -1410,14 +1410,14 @@  discard block
 block discarded – undo
1410 1410
     			foreach ($alldata as $key => $row) {
1411 1411
     				$count[$key] = $row['airport_departure_icao_count'];
1412 1412
         		}
1413
-			array_multisort($count,SORT_DESC,$alldata);
1413
+			array_multisort($count, SORT_DESC, $alldata);
1414 1414
 			foreach ($alldata as $number) {
1415
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1415
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1416 1416
 			}
1417 1417
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1418
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1418
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1419 1419
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1420
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1420
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1421 1421
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1422 1422
 	        	$alldata = array();
1423 1423
     			foreach ($pall as $value) {
@@ -1434,16 +1434,16 @@  discard block
 block discarded – undo
1434 1434
         		foreach ($alldata as $key => $row) {
1435 1435
         			$count[$key] = $row['airport_arrival_icao_count'];
1436 1436
 	        	}
1437
-    			array_multisort($count,SORT_DESC,$alldata);
1437
+    			array_multisort($count, SORT_DESC, $alldata);
1438 1438
                         foreach ($alldata as $number) {
1439
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1439
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1440 1440
 			}
1441 1441
 			if ($Connection->tableExists('countries')) {
1442 1442
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1443 1443
 				$SpotterArchive = new SpotterArchive();
1444
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1444
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1445 1445
 				foreach ($alldata as $number) {
1446
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'',$reset);
1446
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', $reset);
1447 1447
 				}
1448 1448
 			}
1449 1449
 			
@@ -1457,37 +1457,37 @@  discard block
 block discarded – undo
1457 1457
 			$lastyear = false;
1458 1458
 			foreach ($alldata as $number) {
1459 1459
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1460
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1460
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1461 1461
 			}
1462 1462
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1463 1463
 			$alldata = $Spotter->countAllMilitaryMonths();
1464 1464
 			foreach ($alldata as $number) {
1465
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1465
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1466 1466
 			}
1467 1467
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1468 1468
 			$alldata = $Spotter->countAllMonthsOwners();
1469 1469
 			foreach ($alldata as $number) {
1470
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1470
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1471 1471
 			}
1472 1472
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1473 1473
 			$alldata = $Spotter->countAllMonthsPilots();
1474 1474
 			foreach ($alldata as $number) {
1475
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1475
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1476 1476
 			}
1477 1477
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1478 1478
 			$alldata = $Spotter->countAllMonthsAirlines();
1479 1479
 			foreach ($alldata as $number) {
1480
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1480
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1481 1481
 			}
1482 1482
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1483 1483
 			$alldata = $Spotter->countAllMonthsAircrafts();
1484 1484
 			foreach ($alldata as $number) {
1485
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1485
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1486 1486
 			}
1487 1487
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1488 1488
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1489 1489
 			foreach ($alldata as $number) {
1490
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1490
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1491 1491
 			}
1492 1492
 			if ($globalDebug) echo 'Airports data...'."\n";
1493 1493
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
     			}
1533 1533
     			$alldata = $pall;
1534 1534
 			foreach ($alldata as $number) {
1535
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1535
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1536 1536
 			}
1537 1537
 			echo '...Arrival'."\n";
1538 1538
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
     			}
1575 1575
     			$alldata = $pall;
1576 1576
 			foreach ($alldata as $number) {
1577
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1577
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1578 1578
 			}
1579 1579
 
1580 1580
 			echo 'Flights data...'."\n";
@@ -1582,28 +1582,28 @@  discard block
 block discarded – undo
1582 1582
 			echo '-> countAllDatesLastMonth...'."\n";
1583 1583
 			$alldata = $Spotter->countAllDatesLastMonth();
1584 1584
 			foreach ($alldata as $number) {
1585
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1585
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1586 1586
 			}
1587 1587
 			echo '-> countAllDates...'."\n";
1588 1588
 			$previousdata = $this->countAllDates();
1589 1589
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1590 1590
 			$this->deleteStatFlight('date');
1591
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1591
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1592 1592
 			$values = array();
1593 1593
 			foreach ($alldata as $cnt) {
1594 1594
 				$values[] = $cnt['date_count'];
1595 1595
 			}
1596
-			array_multisort($values,SORT_DESC,$alldata);
1597
-			array_splice($alldata,11);
1596
+			array_multisort($values, SORT_DESC, $alldata);
1597
+			array_splice($alldata, 11);
1598 1598
 			foreach ($alldata as $number) {
1599
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1599
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1600 1600
 			}
1601 1601
 			
1602 1602
 			$this->deleteStatFlight('hour');
1603 1603
 			echo '-> countAllHours...'."\n";
1604 1604
 			$alldata = $Spotter->countAllHours('hour');
1605 1605
 			foreach ($alldata as $number) {
1606
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1606
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1607 1607
 			}
1608 1608
 
1609 1609
 
@@ -1612,34 +1612,34 @@  discard block
 block discarded – undo
1612 1612
 			echo '--- Stats by airlines ---'."\n";
1613 1613
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1614 1614
 			$Spotter = new Spotter($this->db);
1615
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1615
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1616 1616
 			foreach ($alldata as $number) {
1617
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1617
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1618 1618
 			}
1619 1619
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1620
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1620
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1621 1621
 			foreach ($alldata as $number) {
1622
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1622
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1623 1623
 			}
1624 1624
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1625
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1625
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1626 1626
 			foreach ($alldata as $number) {
1627
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1627
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1628 1628
 			}
1629 1629
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1630
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1630
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1631 1631
 			foreach ($alldata as $number) {
1632
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1632
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1633 1633
 			}
1634 1634
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1635
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1635
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1636 1636
 			foreach ($alldata as $number) {
1637
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1637
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1638 1638
 			}
1639 1639
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1640
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1640
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1641 1641
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1642
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1642
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1643 1643
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1644 1644
 	        	//$alldata = array();
1645 1645
     			foreach ($dall as $value) {
@@ -1659,12 +1659,12 @@  discard block
 block discarded – undo
1659 1659
     			}
1660 1660
     			$alldata = $pall;
1661 1661
 			foreach ($alldata as $number) {
1662
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1662
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
1663 1663
 			}
1664 1664
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1665
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1665
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1666 1666
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1667
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1667
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1668 1668
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1669 1669
 	        	//$alldata = array();
1670 1670
     			foreach ($dall as $value) {
@@ -1684,7 +1684,7 @@  discard block
 block discarded – undo
1684 1684
     			}
1685 1685
     			$alldata = $pall;
1686 1686
                         foreach ($alldata as $number) {
1687
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1687
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
1688 1688
 			}
1689 1689
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1690 1690
 			$Spotter = new Spotter($this->db);
@@ -1692,27 +1692,27 @@  discard block
 block discarded – undo
1692 1692
 			$lastyear = false;
1693 1693
 			foreach ($alldata as $number) {
1694 1694
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1695
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1695
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1696 1696
 			}
1697 1697
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1698 1698
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1699 1699
 			foreach ($alldata as $number) {
1700
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1700
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1701 1701
 			}
1702 1702
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1703 1703
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1704 1704
 			foreach ($alldata as $number) {
1705
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1705
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1706 1706
 			}
1707 1707
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1708 1708
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1709 1709
 			foreach ($alldata as $number) {
1710
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1710
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1711 1711
 			}
1712 1712
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1713 1713
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1714 1714
 			foreach ($alldata as $number) {
1715
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1715
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1716 1716
 			}
1717 1717
 			if ($globalDebug) echo '...Departure'."\n";
1718 1718
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
     			}
1736 1736
     			$alldata = $pall;
1737 1737
 			foreach ($alldata as $number) {
1738
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1738
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
1739 1739
 			}
1740 1740
 			if ($globalDebug) echo '...Arrival'."\n";
1741 1741
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1758,32 +1758,32 @@  discard block
 block discarded – undo
1758 1758
     			}
1759 1759
     			$alldata = $pall;
1760 1760
 			foreach ($alldata as $number) {
1761
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1761
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
1762 1762
 			}
1763 1763
 
1764 1764
 			if ($globalDebug) echo 'Flights data...'."\n";
1765 1765
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1766 1766
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1767 1767
 			foreach ($alldata as $number) {
1768
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1768
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1769 1769
 			}
1770 1770
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1771 1771
 			//$previousdata = $this->countAllDatesByAirlines();
1772
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1772
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1773 1773
 			$values = array();
1774 1774
 			foreach ($alldata as $cnt) {
1775 1775
 				$values[] = $cnt['date_count'];
1776 1776
 			}
1777
-			array_multisort($values,SORT_DESC,$alldata);
1778
-			array_splice($alldata,11);
1777
+			array_multisort($values, SORT_DESC, $alldata);
1778
+			array_splice($alldata, 11);
1779 1779
 			foreach ($alldata as $number) {
1780
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1780
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1781 1781
 			}
1782 1782
 			
1783 1783
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1784 1784
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1785 1785
 			foreach ($alldata as $number) {
1786
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1786
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1787 1787
 			}
1788 1788
 			
1789 1789
 
@@ -1802,32 +1802,32 @@  discard block
 block discarded – undo
1802 1802
 				// Count by filter
1803 1803
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1804 1804
 				$Spotter = new Spotter($this->db);
1805
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1805
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1806 1806
 				foreach ($alldata as $number) {
1807
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1807
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1808 1808
 				}
1809
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1809
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1810 1810
 				foreach ($alldata as $number) {
1811
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1811
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1812 1812
 				}
1813
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1813
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1814 1814
 				foreach ($alldata as $number) {
1815
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1815
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1816 1816
 				}
1817
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1817
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1818 1818
 				foreach ($alldata as $number) {
1819
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1819
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1820 1820
 				}
1821
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1821
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1822 1822
 				foreach ($alldata as $number) {
1823
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1823
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1824 1824
 				}
1825
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1825
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1826 1826
 				foreach ($alldata as $number) {
1827
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1827
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1828 1828
 				}
1829
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1830
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1829
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1830
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1831 1831
 		        	$alldata = array();
1832 1832
 	    			foreach ($pall as $value) {
1833 1833
 		        		$icao = $value['airport_departure_icao'];
@@ -1843,12 +1843,12 @@  discard block
 block discarded – undo
1843 1843
     				foreach ($alldata as $key => $row) {
1844 1844
     					$count[$key] = $row['airport_departure_icao_count'];
1845 1845
     				}
1846
-				array_multisort($count,SORT_DESC,$alldata);
1846
+				array_multisort($count, SORT_DESC, $alldata);
1847 1847
 				foreach ($alldata as $number) {
1848
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1848
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
1849 1849
 				}
1850
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1851
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1850
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1851
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1852 1852
 				$alldata = array();
1853 1853
     				foreach ($pall as $value) {
1854 1854
 		        		$icao = $value['airport_arrival_icao'];
@@ -1864,40 +1864,40 @@  discard block
 block discarded – undo
1864 1864
         			foreach ($alldata as $key => $row) {
1865 1865
     					$count[$key] = $row['airport_arrival_icao_count'];
1866 1866
 		        	}
1867
-        			array_multisort($count,SORT_DESC,$alldata);
1867
+        			array_multisort($count, SORT_DESC, $alldata);
1868 1868
 				foreach ($alldata as $number) {
1869
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1869
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
1870 1870
 				}
1871 1871
 				$Spotter = new Spotter($this->db);
1872 1872
 				$alldata = $Spotter->countAllMonths($filter);
1873 1873
 				$lastyear = false;
1874 1874
 				foreach ($alldata as $number) {
1875 1875
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1876
-					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1876
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1877 1877
 				}
1878 1878
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1879 1879
 				foreach ($alldata as $number) {
1880
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1880
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1881 1881
 				}
1882 1882
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1883 1883
 				foreach ($alldata as $number) {
1884
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1884
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1885 1885
 				}
1886 1886
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1887 1887
 				foreach ($alldata as $number) {
1888
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1888
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1889 1889
 				}
1890 1890
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1891 1891
 				foreach ($alldata as $number) {
1892
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1892
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1893 1893
 				}
1894 1894
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1895 1895
 				foreach ($alldata as $number) {
1896
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1896
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1897 1897
 				}
1898 1898
 				echo '...Departure'."\n";
1899
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1900
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1899
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1900
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1901 1901
 				foreach ($dall as $value) {
1902 1902
     					$icao = $value['departure_airport_icao'];
1903 1903
     					$ddate = $value['date'];
@@ -1915,11 +1915,11 @@  discard block
 block discarded – undo
1915 1915
     				}
1916 1916
 	    			$alldata = $pall;
1917 1917
 				foreach ($alldata as $number) {
1918
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1918
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
1919 1919
 				}
1920 1920
 				echo '...Arrival'."\n";
1921
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1922
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1921
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1922
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1923 1923
 				foreach ($dall as $value) {
1924 1924
 					$icao = $value['arrival_airport_icao'];
1925 1925
 					$ddate = $value['date'];
@@ -1937,40 +1937,40 @@  discard block
 block discarded – undo
1937 1937
     				}
1938 1938
     				$alldata = $pall;
1939 1939
 				foreach ($alldata as $number) {
1940
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1940
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
1941 1941
 				}
1942 1942
     
1943 1943
 				echo 'Flights data...'."\n";
1944 1944
 				echo '-> countAllDatesLastMonth...'."\n";
1945 1945
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1946 1946
 				foreach ($alldata as $number) {
1947
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1947
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1948 1948
 				}
1949 1949
 				echo '-> countAllDates...'."\n";
1950
-				$previousdata = $this->countAllDates('',$filter_name);
1951
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1950
+				$previousdata = $this->countAllDates('', $filter_name);
1951
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1952 1952
 				$values = array();
1953 1953
 				foreach ($alldata as $cnt) {
1954 1954
 					$values[] = $cnt['date_count'];
1955 1955
 				}
1956
-				array_multisort($values,SORT_DESC,$alldata);
1957
-				array_splice($alldata,11);
1956
+				array_multisort($values, SORT_DESC, $alldata);
1957
+				array_splice($alldata, 11);
1958 1958
 				foreach ($alldata as $number) {
1959
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1959
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1960 1960
 				}
1961 1961
 				
1962 1962
 				echo '-> countAllHours...'."\n";
1963
-				$alldata = $Spotter->countAllHours('hour',$filter);
1963
+				$alldata = $Spotter->countAllHours('hour', $filter);
1964 1964
 				foreach ($alldata as $number) {
1965
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1965
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1966 1966
 				}
1967 1967
 				echo 'Insert last stats update date...'."\n";
1968 1968
 				date_default_timezone_set('UTC');
1969
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
1969
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
1970 1970
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
1971
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
1971
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
1972 1972
 						$this->deleteOldStats($filter_name);
1973
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
1973
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
1974 1974
 					}
1975 1975
 				}
1976 1976
 
@@ -1983,16 +1983,16 @@  discard block
 block discarded – undo
1983 1983
 				// SUM all previous month to put as year
1984 1984
 				$previous_year = date('Y');
1985 1985
 				$previous_year--;
1986
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1987
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1988
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1989
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1986
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1987
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1988
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1989
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1990 1990
 				$allairlines = $this->getAllAirlineNames();
1991 1991
 				foreach ($allairlines as $data) {
1992
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1993
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1994
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1995
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1992
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1993
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1994
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1995
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1996 1996
 				}
1997 1997
 				
1998 1998
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 						try {
2002 2002
 							$sth = $this->db->prepare($query);
2003 2003
 							$sth->execute();
2004
-						} catch(PDOException $e) {
2004
+						} catch (PDOException $e) {
2005 2005
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2006 2006
 						}
2007 2007
 					}
@@ -2010,15 +2010,15 @@  discard block
 block discarded – undo
2010 2010
 					try {
2011 2011
 						$sth = $this->db->prepare($query);
2012 2012
 						$sth->execute();
2013
-					} catch(PDOException $e) {
2013
+					} catch (PDOException $e) {
2014 2014
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2015 2015
 					}
2016 2016
 				}
2017 2017
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2018 2018
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2019
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2019
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2020 2020
 						$this->deleteOldStats();
2021
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2021
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2022 2022
 						$lastyearupdate = true;
2023 2023
 					}
2024 2024
 				}
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 					try {
2041 2041
 						$sth = $this->db->prepare($query);
2042 2042
 						$sth->execute();
2043
-					} catch(PDOException $e) {
2043
+					} catch (PDOException $e) {
2044 2044
 						return "error : ".$e->getMessage();
2045 2045
 					}
2046 2046
 				}
@@ -2054,14 +2054,14 @@  discard block
 block discarded – undo
2054 2054
 				try {
2055 2055
 					$sth = $this->db->prepare($query);
2056 2056
 					$sth->execute();
2057
-				} catch(PDOException $e) {
2057
+				} catch (PDOException $e) {
2058 2058
 					return "error : ".$e->getMessage();
2059 2059
 				}
2060 2060
 			}
2061 2061
 			if (!isset($lastyearupdate)) {
2062 2062
 				echo 'Insert last stats update date...'."\n";
2063 2063
 				date_default_timezone_set('UTC');
2064
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2064
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2065 2065
 			}
2066 2066
 			if ($globalStatsResetYear) {
2067 2067
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
statistics-airport-departure-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Departure Airport by Country");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
20
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
21
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
19
+setcookie('stats_airline_icao', $airline_icao);
20
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
21
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
22 22
 
23 23
 require_once('header.php');
24 24
 include('statistics-sub-menu.php'); 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	  </div>
30 30
 	<p>'._("Below are the <strong>Top 10</strong> most common countries of all the departure airports.").'</p>';
31 31
 
32
-$airport_country_array = $Stats->countAllDepartureCountries(true,$airline_icao,$filter_name,$year,$month);
32
+$airport_country_array = $Stats->countAllDepartureCountries(true, $airline_icao, $filter_name, $year, $month);
33 33
 print '<script>
34 34
     	google.load("visualization", "1", {packages:["geochart"]});
35 35
     	google.setOnLoadCallback(drawCharts);
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         	["'._("Country").'", "'._("# of times").'"],';
43 43
 
44 44
 $country_data = '';
45
-foreach($airport_country_array as $airport_item)
45
+foreach ($airport_country_array as $airport_item)
46 46
 {
47 47
 	$country_data .= '[ "'.$airport_item['airport_departure_country'].'",'.$airport_item['airport_departure_country_count'].'],';
48 48
 }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 print '</thead>';
78 78
 print '<tbody>';
79 79
 $i = 1;
80
-foreach($airport_country_array as $airport_item)
80
+foreach ($airport_country_array as $airport_item)
81 81
 {
82 82
 	print '<tr>';
83 83
 	print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-callsign.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Callsign");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
20
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
21
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
19
+setcookie('stats_airline_icao', $airline_icao);
20
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
21
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
22 22
 require_once('header.php');
23 23
 include('statistics-sub-menu.php'); 
24 24
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	  </div>
29 29
     	<p>'._("Below are the <strong>Top 10</strong> most common ident/callsigns of all airlines.").'</p>';
30 30
 
31
-$callsign_array = $Stats->countAllCallsigns(true,$airline_icao,$filter_name,$year,$month);
31
+$callsign_array = $Stats->countAllCallsigns(true, $airline_icao, $filter_name, $year, $month);
32 32
 print '<div id="chart" class="chart" width="100%"></div>
33 33
       	<script> 
34 34
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             var data = google.visualization.arrayToDataTable([
38 38
             	["'._("Aircraft").'", "'._("# of times").'"], ';
39 39
 $callsign_data = '';
40
-foreach($callsign_array as $callsign_item)
40
+foreach ($callsign_array as $callsign_item)
41 41
 {
42 42
 	$callsign_data .= '[ "'.$callsign_item['callsign_icao'].' ('.$callsign_item['airline_name'].')",'.$callsign_item['callsign_icao_count'].'],';
43 43
 }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	print '</thead>';
72 72
 	print '<tbody>';
73 73
 	$i = 1;
74
-	foreach($callsign_array as $callsign_item)
74
+	foreach ($callsign_array as $callsign_item)
75 75
 	{
76 76
 		print '<tr>';
77 77
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.