Completed
Push — master ( 84a1ce...088ca9 )
by Yannick
05:27
created
date-statistics-manufacturer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Aircraft Manufacturer on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Aircraft Manufacturer on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 
14 14
 	require_once('header.php');
15 15
 	print '<div class="select-item">';
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 	print '</div>';
22 22
 
23 23
 	print '<div class="info column">';
24
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
24
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
25 25
 	print '</div>';
26 26
 
27 27
 	include('date-sub-menu.php');
28 28
 	print '<div class="column">';
29 29
 	print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>';
30
-	print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
30
+	print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
31 31
 
32 32
 	$manufacturers_array = $Spotter->countAllAircraftManufacturerByDate($date);
33 33
 	if (!empty($manufacturers_array))
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		print '</thead>';
43 43
 		print '<tbody>';
44 44
 		$i = 1;
45
-		foreach($manufacturers_array as $manufacturer_item)
45
+		foreach ($manufacturers_array as $manufacturer_item)
46 46
 		{
47 47
 			print '<tr>';
48 48
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +273 added lines, -273 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 (ModeS,Registration,ICAOTypeCode,Source) VALUES (: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(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
376
+						$query_dest_values = array(':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;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -403,11 +403,11 @@  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
 		
410
-		if ($fh = fopen($database_file,"r")) {
410
+		if ($fh = fopen($database_file, "r")) {
411 411
 			//$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)';
412 412
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
413 413
 		
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 			$sth_dest = $Connection->db->prepare($query_dest);
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418
-				$tmp = fgetcsv($fh,9999,',','"');
418
+				$tmp = fgetcsv($fh, 9999, ',', '"');
419 419
             			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
420
+            				$line = fgetcsv($fh, 9999, ',', '"');
421 421
             				$values = array();
422 422
             				//print_r($line);
423 423
             				if ($country == 'F') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
             				    $values['base'] = $line[4];
426 426
             				    $values['owner'] = $line[5];
427 427
             				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
429 429
 					    $values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431 431
 					    // TODO : add modeS & reg to aircraft_modes
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             				    $values['base'] = $line[3];
434 434
             				    $values['owner'] = $line[2];
435 435
             				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
437 437
 					    $values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439 439
 					    // TODO : add modeS & reg to aircraft_modes
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             				    $values['base'] = null;
449 449
             				    $values['owner'] = $line[5];
450 450
             				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
452 452
 					    $values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454 454
 					    // TODO : add modeS & reg to aircraft_modes
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[12];
458 458
             				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
460 460
 
461 461
 					    $values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -476,28 +476,28 @@  discard block
 block discarded – undo
476 476
             				    $values['base'] = null;
477 477
             				    $values['owner'] = $line[8];
478 478
             				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
480 480
 					    $values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482 482
             				    $values['registration'] = $line[0];
483 483
             				    $values['base'] = null;
484 484
             				    $values['owner'] = $line[4];
485 485
             				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
487 487
 					    $values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489 489
             				    $values['registration'] = $line[0];
490 490
             				    $values['base'] = null;
491 491
             				    $values['owner'] = $line[4];
492 492
             				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
494 494
 					    $values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496 496
             				    $values['registration'] = $line[0];
497 497
             				    $values['base'] = null;
498 498
             				    $values['owner'] = $line[3];
499 499
             				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
501 501
 					    $values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 503
             				    $values['registration'] = $line[0];
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 					    $values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
510
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
511 511
 						$sth_dest->execute($query_dest_values);
512 512
 					}
513 513
 				}
514 514
 				if ($globalTransaction) $Connection->db->commit();
515
-			} catch(PDOException $e) {
515
+			} catch (PDOException $e) {
516 516
 				return "error : ".$e->getMessage();
517 517
 			}
518 518
 		}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629 629
                         $sth->execute();
630
-                } catch(PDOException $e) {
630
+                } catch (PDOException $e) {
631 631
                         return "error : ".$e->getMessage();
632 632
                 }
633 633
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639 639
                         $sth->execute();
640
-                } catch(PDOException $e) {
640
+                } catch (PDOException $e) {
641 641
                         return "error : ".$e->getMessage();
642 642
                 }
643 643
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 		if ($globalTransaction) $Connection->db->beginTransaction();
649 649
   
650 650
 		$i = 0;
651
-		while($row = sparql_fetch_array($result))
651
+		while ($row = sparql_fetch_array($result))
652 652
 		{
653 653
 			if ($i >= 1) {
654 654
 			//print_r($row);
@@ -668,31 +668,31 @@  discard block
 block discarded – undo
668 668
 				$row['image'] = '';
669 669
 				$row['image_thumb'] = '';
670 670
 			} else {
671
-				$image = str_replace(' ','_',$row['image']);
671
+				$image = str_replace(' ', '_', $row['image']);
672 672
 				$digest = md5($image);
673
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
674
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
675
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
676
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
673
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
674
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
675
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
676
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
677 677
 			}
678 678
 			
679
-			$country = explode('-',$row['country']);
679
+			$country = explode('-', $row['country']);
680 680
 			$row['country'] = $country[0];
681 681
 			
682 682
 			$row['type'] = trim($row['type']);
683
-			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'])) {
683
+			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'])) {
684 684
 				$row['type'] = 'Military';
685 685
 			} 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') {
686 686
 				$row['type'] = 'small_airport';
687 687
 			}
688 688
 			
689
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
690
-			$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']);
689
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
690
+			$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']);
691 691
 			//print_r($query_dest_values);
692 692
 			
693 693
 			try {
694 694
 				$sth_dest->execute($query_dest_values);
695
-			} catch(PDOException $e) {
695
+			} catch (PDOException $e) {
696 696
 				return "error : ".$e->getMessage();
697 697
 			}
698 698
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708 708
                         $sth->execute();
709
-                } catch(PDOException $e) {
709
+                } catch (PDOException $e) {
710 710
                         return "error : ".$e->getMessage();
711 711
                 }
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
715 715
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 716
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717
-		$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' => '');
717
+		$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' => '');
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721 721
                         $sth->execute($query_values);
722
-                } catch(PDOException $e) {
722
+                } catch (PDOException $e) {
723 723
                         return "error : ".$e->getMessage();
724 724
                 }
725 725
 		$i++;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		echo "Download data from ourairports.com...\n";
738 738
 		$delimiter = ',';
739 739
 		$out_file = $tmp_dir.'airports.csv';
740
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
741 741
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
742 742
 		echo "Add data from ourairports.com...\n";
743 743
 
@@ -748,32 +748,32 @@  discard block
 block discarded – undo
748 748
 			//$Connection->db->beginTransaction();
749 749
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 750
 			{
751
-				if(!$header) $header = $row;
751
+				if (!$header) $header = $row;
752 752
 				else {
753 753
 					$data = array();
754 754
 					$data = array_combine($header, $row);
755 755
 					try {
756 756
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
757 757
 						$sth->execute(array(':icao' => $data['gps_code']));
758
-					} catch(PDOException $e) {
758
+					} catch (PDOException $e) {
759 759
 						return "error : ".$e->getMessage();
760 760
 					}
761 761
 					if ($sth->fetchColumn() > 0) {
762 762
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
763 763
 						try {
764 764
 							$sth = $Connection->db->prepare($query);
765
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
766
-						} catch(PDOException $e) {
765
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
766
+						} catch (PDOException $e) {
767 767
 							return "error : ".$e->getMessage();
768 768
 						}
769 769
 					} else {
770 770
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
771 771
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
772
-						$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']);
772
+						$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']);
773 773
 						try {
774 774
 							$sth = $Connection->db->prepare($query);
775 775
 							$sth->execute($query_values);
776
-						} catch(PDOException $e) {
776
+						} catch (PDOException $e) {
777 777
 							return "error : ".$e->getMessage();
778 778
 						}
779 779
 						$i++;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 		echo "Download data from another free database...\n";
788 788
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
790 790
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
791 791
 		update_db::unzip($out_file);
792 792
 		$header = NULL;
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 			//$Connection->db->beginTransaction();
799 799
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 800
 			{
801
-				if(!$header) $header = $row;
801
+				if (!$header) $header = $row;
802 802
 				else {
803 803
 					$data = $row;
804 804
 
805 805
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
806 806
 					try {
807 807
 						$sth = $Connection->db->prepare($query);
808
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
809
-					} catch(PDOException $e) {
808
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
809
+					} catch (PDOException $e) {
810 810
 						return "error : ".$e->getMessage();
811 811
 					}
812 812
 				}
@@ -820,15 +820,15 @@  discard block
 block discarded – undo
820 820
 		try {
821 821
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
822 822
 			$sth->execute();
823
-		} catch(PDOException $e) {
823
+		} catch (PDOException $e) {
824 824
 			return "error : ".$e->getMessage();
825 825
 		}
826 826
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
827 827
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
828 828
 			try {
829 829
 				$sth2 = $Connection->db->prepare($query2);
830
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
831
-			} catch(PDOException $e) {
830
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
831
+			} catch (PDOException $e) {
832 832
 				return "error : ".$e->getMessage();
833 833
 			}
834 834
 		}
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854 854
                         $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
855
+                } catch (PDOException $e) {
856 856
                         return "error : ".$e->getMessage();
857 857
                 }
858 858
 
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871 871
 				$i++;
872
-				if($i > 12) {
872
+				if ($i > 12) {
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                                                 //echo substr($operator, 0, 2)."\n";;
878 878
                                                 if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880
-							$operator = $airline_array[0]['icao'].substr($operator,2);
880
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
881 881
                                                 }
882 882
                                         }
883 883
 					
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886 886
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887 887
                                                 if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
889 889
                                             	}
890 890
                                         }
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
894
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
-					} catch(PDOException $e) {
894
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
+					} catch (PDOException $e) {
896 896
 						return "error : ".$e->getMessage();
897 897
 					}
898 898
 				}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914 914
                         $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
915
+                } catch (PDOException $e) {
916 916
                         return "error : ".$e->getMessage();
917 917
                 }
918 918
 
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
935
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
-					} catch(PDOException $e) {
935
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
+					} catch (PDOException $e) {
937 937
 						return "error : ".$e->getMessage();
938 938
 					}
939 939
 				}
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 			$Connection = new Connection();
957 957
 			$sth = $Connection->db->prepare($query);
958 958
                         $sth->execute(array(':source' => 'website_faa'));
959
-                } catch(PDOException $e) {
959
+                } catch (PDOException $e) {
960 960
                         return "error : ".$e->getMessage();
961 961
                 }
962 962
 
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 			$Connection = new Connection();
966 966
 			$sth = $Connection->db->prepare($query);
967 967
                         $sth->execute(array(':source' => 'website_faa'));
968
-                } catch(PDOException $e) {
968
+                } catch (PDOException $e) {
969 969
                         return "error : ".$e->getMessage();
970 970
                 }
971 971
 
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
982 982
 					try {
983 983
 						$sths = $Connection->db->prepare($query_search);
984
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
985
-					} catch(PDOException $e) {
984
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
985
+					} catch (PDOException $e) {
986 986
 						return "error s : ".$e->getMessage();
987 987
 					}
988 988
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 						$queryi = 'UPDATE aircraft SET mfr = :mfr WHERE icao = :icao';
992 992
 						try {
993 993
 							$sthi = $Connection->db->prepare($queryi);
994
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
995
-						} catch(PDOException $e) {
994
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
995
+						} catch (PDOException $e) {
996 996
 							return "error u : ".$e->getMessage();
997 997
 						}
998 998
 					} else {
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 						try {
1001 1001
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1002 1002
 							$sthsm->execute(array(':mfr' => $data[2]));
1003
-						} catch(PDOException $e) {
1003
+						} catch (PDOException $e) {
1004 1004
 							return "error mfr : ".$e->getMessage();
1005 1005
 						}
1006 1006
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1011 1011
 							try {
1012 1012
 								$sthf = $Connection->db->prepare($queryf);
1013
-								$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'));
1014
-							} catch(PDOException $e) {
1013
+								$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'));
1014
+							} catch (PDOException $e) {
1015 1015
 								return "error f : ".$e->getMessage();
1016 1016
 							}
1017 1017
 						}
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1022 1022
 						try {
1023 1023
 							$sth = $Connection->db->prepare($query);
1024
-							$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'));
1025
-						} catch(PDOException $e) {
1024
+							$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'));
1025
+						} catch (PDOException $e) {
1026 1026
 							return "error i : ".$e->getMessage();
1027 1027
 						}
1028 1028
 					}
1029 1029
 				}
1030
-				if ($i % 90 == 0) {
1030
+				if ($i%90 == 0) {
1031 1031
 					if ($globalTransaction) $Connection->db->commit();
1032 1032
 					if ($globalTransaction) $Connection->db->beginTransaction();
1033 1033
 				}
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 			$Connection = new Connection();
1046 1046
 			$sth = $Connection->db->prepare($query);
1047 1047
                         $sth->execute(array(':source' => 'website_fam'));
1048
-                } catch(PDOException $e) {
1048
+                } catch (PDOException $e) {
1049 1049
                         return "error : ".$e->getMessage();
1050 1050
                 }
1051 1051
 
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1066 1066
 					try {
1067 1067
 						$sth = $Connection->db->prepare($query);
1068
-						$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'));
1069
-					} catch(PDOException $e) {
1068
+						$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'));
1069
+					} catch (PDOException $e) {
1070 1070
 						return "error : ".$e->getMessage();
1071 1071
 					}
1072 1072
 				}
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 			$Connection = new Connection();
1086 1086
 			$sth = $Connection->db->prepare($query);
1087 1087
                         $sth->execute(array(':source' => 'website_fam'));
1088
-                } catch(PDOException $e) {
1088
+                } catch (PDOException $e) {
1089 1089
                         return "error : ".$e->getMessage();
1090 1090
                 }
1091 1091
 
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1102 1102
 					try {
1103 1103
 						$sth = $Connection->db->prepare($query);
1104
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1105
-					} catch(PDOException $e) {
1104
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1105
+					} catch (PDOException $e) {
1106 1106
 						print_r($data);
1107 1107
 						return "error : ".$e->getMessage();
1108 1108
 					}
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			$Connection = new Connection();
1123 1123
 			$sth = $Connection->db->prepare($query);
1124 1124
                         $sth->execute(array(':source' => 'website_fam'));
1125
-                } catch(PDOException $e) {
1125
+                } catch (PDOException $e) {
1126 1126
                         return "error : ".$e->getMessage();
1127 1127
                 }
1128 1128
 
@@ -1142,8 +1142,8 @@  discard block
 block discarded – undo
1142 1142
 					$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)';
1143 1143
 					try {
1144 1144
 						$sth = $Connection->db->prepare($query);
1145
-						$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'));
1146
-					} catch(PDOException $e) {
1145
+						$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'));
1146
+					} catch (PDOException $e) {
1147 1147
 						return "error : ".$e->getMessage();
1148 1148
 					}
1149 1149
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 		return '';
1156 1156
         }
1157 1157
 
1158
-	public static function tle($filename,$tletype) {
1158
+	public static function tle($filename, $tletype) {
1159 1159
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1160 1160
 		global $tmp_dir, $globalTransaction;
1161 1161
 		//$Spotter = new Spotter();
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 			$Connection = new Connection();
1166 1166
 			$sth = $Connection->db->prepare($query);
1167 1167
                         $sth->execute(array(':source' => $filename));
1168
-                } catch(PDOException $e) {
1168
+                } catch (PDOException $e) {
1169 1169
                         return "error : ".$e->getMessage();
1170 1170
                 }
1171 1171
 		
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1191 1191
 					try {
1192 1192
 						$sth = $Connection->db->prepare($query);
1193
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1194
-					} catch(PDOException $e) {
1193
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1194
+					} catch (PDOException $e) {
1195 1195
 						return "error : ".$e->getMessage();
1196 1196
 					}
1197 1197
 
@@ -1211,28 +1211,28 @@  discard block
 block discarded – undo
1211 1211
         */
1212 1212
         private static function table2array($data) {
1213 1213
                 $html = str_get_html($data);
1214
-                $tabledata=array();
1215
-                foreach($html->find('tr') as $element)
1214
+                $tabledata = array();
1215
+                foreach ($html->find('tr') as $element)
1216 1216
                 {
1217 1217
                         $td = array();
1218
-                        foreach( $element->find('th') as $row)
1218
+                        foreach ($element->find('th') as $row)
1219 1219
                         {
1220 1220
                                 $td [] = trim($row->plaintext);
1221 1221
                         }
1222
-                        $td=array_filter($td);
1222
+                        $td = array_filter($td);
1223 1223
                         $tabledata[] = $td;
1224 1224
 
1225 1225
                         $td = array();
1226 1226
                         $tdi = array();
1227
-                        foreach( $element->find('td') as $row)
1227
+                        foreach ($element->find('td') as $row)
1228 1228
                         {
1229 1229
                                 $td [] = trim($row->plaintext);
1230 1230
                                 $tdi [] = trim($row->innertext);
1231 1231
                         }
1232
-                        $td=array_filter($td);
1233
-                        $tdi=array_filter($tdi);
1232
+                        $td = array_filter($td);
1233
+                        $tdi = array_filter($tdi);
1234 1234
                     //    $tabledata[]=array_merge($td,$tdi);
1235
-                        $tabledata[]=$td;
1235
+                        $tabledata[] = $td;
1236 1236
                 }
1237 1237
                 return(array_filter($tabledata));
1238 1238
         }
@@ -1305,13 +1305,13 @@  discard block
 block discarded – undo
1305 1305
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1306 1306
 			{
1307 1307
 				$i++;
1308
-				if($i > 3 && count($row) > 2) {
1308
+				if ($i > 3 && count($row) > 2) {
1309 1309
 					$data = array_values(array_filter($row));
1310 1310
 					$cntdata = count($data);
1311 1311
 					if ($cntdata > 10) {
1312 1312
 						$value = $data[9];
1313 1313
 						
1314
-						for ($i =10;$i < $cntdata;$i++) {
1314
+						for ($i = 10; $i < $cntdata; $i++) {
1315 1315
 							$value .= ' '.$data[$i];
1316 1316
 						}
1317 1317
 						$data[9] = $value;
@@ -1321,8 +1321,8 @@  discard block
 block discarded – undo
1321 1321
 						$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)';
1322 1322
 						try {
1323 1323
 							$sth = $Connection->db->prepare($query);
1324
-							$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]));
1325
-						} catch(PDOException $e) {
1324
+							$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]));
1325
+						} catch (PDOException $e) {
1326 1326
 							return "error : ".$e->getMessage();
1327 1327
 						}
1328 1328
 					}
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 			$Connection = new Connection();
1344 1344
 			$sth = $Connection->db->prepare($query);
1345 1345
                         $sth->execute();
1346
-                } catch(PDOException $e) {
1346
+                } catch (PDOException $e) {
1347 1347
                         return "error : ".$e->getMessage();
1348 1348
                 }
1349 1349
 
@@ -1355,12 +1355,12 @@  discard block
 block discarded – undo
1355 1355
 			if ($globalTransaction) $Connection->db->beginTransaction();
1356 1356
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1357 1357
 			{
1358
-				if(count($row) > 1) {
1358
+				if (count($row) > 1) {
1359 1359
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1360 1360
 					try {
1361 1361
 						$sth = $Connection->db->prepare($query);
1362
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1363
-					} catch(PDOException $e) {
1362
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1363
+					} catch (PDOException $e) {
1364 1364
 						return "error : ".$e->getMessage();
1365 1365
 					}
1366 1366
 				}
@@ -1380,21 +1380,21 @@  discard block
 block discarded – undo
1380 1380
 			try {
1381 1381
 				$sth = $Connection->db->prepare($query);
1382 1382
                     		$sth->execute();
1383
-	                } catch(PDOException $e) {
1383
+	                } catch (PDOException $e) {
1384 1384
 				return "error : ".$e->getMessage();
1385 1385
 	                }
1386 1386
 	        }
1387 1387
 
1388 1388
 
1389
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1389
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1390 1390
 		else {
1391
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1391
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1392 1392
 			$query = "CREATE EXTENSION postgis";
1393
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1393
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1394 1394
 			try {
1395 1395
 				$sth = $Connection->db->prepare($query);
1396 1396
 				$sth->execute();
1397
-			} catch(PDOException $e) {
1397
+			} catch (PDOException $e) {
1398 1398
 				return "error : ".$e->getMessage();
1399 1399
 			}
1400 1400
 		}
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 		include_once('class.create_db.php');
1408 1408
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1409 1409
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1410
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1410
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1411 1411
 		$error = '';
1412 1412
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1413 1413
 			if ($globalDebug) echo "Gunzip...";
@@ -1439,14 +1439,14 @@  discard block
 block discarded – undo
1439 1439
 			try {
1440 1440
 				$sth = $Connection->db->prepare($query);
1441 1441
             	        	$sth->execute();
1442
-	                } catch(PDOException $e) {
1442
+	                } catch (PDOException $e) {
1443 1443
     	                	echo "error : ".$e->getMessage();
1444 1444
 	                }
1445 1445
 		}
1446 1446
 		if ($globalDBdriver == 'mysql') {
1447
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1447
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1448 1448
 		} else {
1449
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1449
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1450 1450
 		}
1451 1451
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1452 1452
 		return $error;
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1460 1460
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1461 1461
 //		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');
1462
-		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');
1462
+		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');
1463 1463
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1464 1464
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1465 1465
 		return $error;
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1480 1480
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1481 1481
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1482
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1482
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1483 1483
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1484 1484
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1485 1485
 		if ($error != '') {
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 		global $tmp_dir, $globalDebug;
1493 1493
 		$error = '';
1494 1494
 		if ($globalDebug) echo "Routes : Download...";
1495
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1495
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1496 1496
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1497 1497
 			if ($globalDebug) echo "Gunzip...";
1498 1498
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 		global $tmp_dir, $globalDebug;
1509 1509
 		$error = '';
1510 1510
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1511
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1511
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1512 1512
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1513 1513
 			if ($globalDebug) echo "Gunzip...";
1514 1514
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
 		global $tmp_dir, $globalDebug;
1525 1525
 		$error = '';
1526 1526
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1527
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1527
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1528 1528
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1529 1529
 			if ($globalDebug) echo "Gunzip...";
1530 1530
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
 */
1553 1553
 		if ($globalDebug) echo "Modes : Download...";
1554 1554
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1555
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1555
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1556 1556
 
1557 1557
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1558 1558
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 	public static function update_ModeS_faa() {
1573 1573
 		global $tmp_dir, $globalDebug;
1574 1574
 		if ($globalDebug) echo "Modes FAA: Download...";
1575
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1575
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1576 1576
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1577 1577
 			if ($globalDebug) echo "Unzip...";
1578 1578
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 	public static function update_ModeS_flarm() {
1589 1589
 		global $tmp_dir, $globalDebug;
1590 1590
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1591
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1591
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1592 1592
 		if (file_exists($tmp_dir.'data.fln')) {
1593 1593
 			if ($globalDebug) echo "Add to DB...";
1594 1594
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 	public static function update_ModeS_ogn() {
1603 1603
 		global $tmp_dir, $globalDebug;
1604 1604
 		if ($globalDebug) echo "Modes OGN: Download...";
1605
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1605
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1606 1606
 		if (file_exists($tmp_dir.'ogn.csv')) {
1607 1607
 			if ($globalDebug) echo "Add to DB...";
1608 1608
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1617,173 +1617,173 @@  discard block
 block discarded – undo
1617 1617
 		global $tmp_dir, $globalDebug;
1618 1618
 		
1619 1619
 		if ($globalDebug) echo "Owner France: Download...";
1620
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1620
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1621 1621
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1622 1622
 			if ($globalDebug) echo "Add to DB...";
1623
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1623
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1624 1624
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1625 1625
 		if ($error != '') {
1626 1626
 			return $error;
1627 1627
 		} elseif ($globalDebug) echo "Done\n";
1628 1628
 		
1629 1629
 		if ($globalDebug) echo "Owner Ireland: Download...";
1630
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1630
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1631 1631
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1632 1632
 			if ($globalDebug) echo "Add to DB...";
1633
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1633
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1634 1634
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1635 1635
 		if ($error != '') {
1636 1636
 			return $error;
1637 1637
 		} elseif ($globalDebug) echo "Done\n";
1638 1638
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1639
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1639
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1640 1640
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1641 1641
 			if ($globalDebug) echo "Add to DB...";
1642
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1642
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1643 1643
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1644 1644
 		if ($error != '') {
1645 1645
 			return $error;
1646 1646
 		} elseif ($globalDebug) echo "Done\n";
1647 1647
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1648
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1648
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1649 1649
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1650 1650
 			if ($globalDebug) echo "Add to DB...";
1651
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1651
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1652 1652
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1653 1653
 		if ($error != '') {
1654 1654
 			return $error;
1655 1655
 		} elseif ($globalDebug) echo "Done\n";
1656 1656
 		if ($globalDebug) echo "Owner Australia: Download...";
1657
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1657
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1658 1658
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1659 1659
 			if ($globalDebug) echo "Add to DB...";
1660
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1660
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1661 1661
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1662 1662
 		if ($error != '') {
1663 1663
 			return $error;
1664 1664
 		} elseif ($globalDebug) echo "Done\n";
1665 1665
 		if ($globalDebug) echo "Owner Austria: Download...";
1666
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1666
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1667 1667
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1668 1668
 			if ($globalDebug) echo "Add to DB...";
1669
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1669
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1670 1670
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1671 1671
 		if ($error != '') {
1672 1672
 			return $error;
1673 1673
 		} elseif ($globalDebug) echo "Done\n";
1674 1674
 		if ($globalDebug) echo "Owner Chile: Download...";
1675
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1675
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1676 1676
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1677 1677
 			if ($globalDebug) echo "Add to DB...";
1678
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1678
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1679 1679
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1680 1680
 		if ($error != '') {
1681 1681
 			return $error;
1682 1682
 		} elseif ($globalDebug) echo "Done\n";
1683 1683
 		if ($globalDebug) echo "Owner Colombia: Download...";
1684
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1684
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1685 1685
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1686 1686
 			if ($globalDebug) echo "Add to DB...";
1687
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1687
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1688 1688
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1689 1689
 		if ($error != '') {
1690 1690
 			return $error;
1691 1691
 		} elseif ($globalDebug) echo "Done\n";
1692 1692
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1693
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1693
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1694 1694
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1695 1695
 			if ($globalDebug) echo "Add to DB...";
1696
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1696
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1697 1697
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1698 1698
 		if ($error != '') {
1699 1699
 			return $error;
1700 1700
 		} elseif ($globalDebug) echo "Done\n";
1701 1701
 		if ($globalDebug) echo "Owner Brazil: Download...";
1702
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1702
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1703 1703
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1704 1704
 			if ($globalDebug) echo "Add to DB...";
1705
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1705
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1706 1706
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1707 1707
 		if ($error != '') {
1708 1708
 			return $error;
1709 1709
 		} elseif ($globalDebug) echo "Done\n";
1710 1710
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1711
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1711
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1712 1712
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1713 1713
 			if ($globalDebug) echo "Add to DB...";
1714
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1714
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1715 1715
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1716 1716
 		if ($error != '') {
1717 1717
 			return $error;
1718 1718
 		} elseif ($globalDebug) echo "Done\n";
1719 1719
 		if ($globalDebug) echo "Owner Croatia: Download...";
1720
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1720
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1721 1721
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1722 1722
 			if ($globalDebug) echo "Add to DB...";
1723
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1723
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1724 1724
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1725 1725
 		if ($error != '') {
1726 1726
 			return $error;
1727 1727
 		} elseif ($globalDebug) echo "Done\n";
1728 1728
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1729
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1729
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1730 1730
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1731 1731
 			if ($globalDebug) echo "Add to DB...";
1732
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1732
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1733 1733
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1734 1734
 		if ($error != '') {
1735 1735
 			return $error;
1736 1736
 		} elseif ($globalDebug) echo "Done\n";
1737 1737
 		if ($globalDebug) echo "Owner Maldives: Download...";
1738
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1738
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1739 1739
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1740 1740
 			if ($globalDebug) echo "Add to DB...";
1741
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1741
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1742 1742
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1743 1743
 		if ($error != '') {
1744 1744
 			return $error;
1745 1745
 		} elseif ($globalDebug) echo "Done\n";
1746 1746
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1747
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1747
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1748 1748
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1749 1749
 			if ($globalDebug) echo "Add to DB...";
1750
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1750
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1751 1751
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1752 1752
 		if ($error != '') {
1753 1753
 			return $error;
1754 1754
 		} elseif ($globalDebug) echo "Done\n";
1755 1755
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1756
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1756
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1757 1757
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1758 1758
 			if ($globalDebug) echo "Add to DB...";
1759
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1759
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1760 1760
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1761 1761
 		if ($error != '') {
1762 1762
 			return $error;
1763 1763
 		} elseif ($globalDebug) echo "Done\n";
1764 1764
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1765
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1765
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1766 1766
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1767 1767
 			if ($globalDebug) echo "Add to DB...";
1768
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1768
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1769 1769
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1770 1770
 		if ($error != '') {
1771 1771
 			return $error;
1772 1772
 		} elseif ($globalDebug) echo "Done\n";
1773 1773
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1774
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1774
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1775 1775
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1776 1776
 			if ($globalDebug) echo "Add to DB...";
1777
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1777
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1778 1778
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1779 1779
 		if ($error != '') {
1780 1780
 			return $error;
1781 1781
 		} elseif ($globalDebug) echo "Done\n";
1782 1782
 		if ($globalDebug) echo "Owner Iceland: Download...";
1783
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1783
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1784 1784
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1785 1785
 			if ($globalDebug) echo "Add to DB...";
1786
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1786
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1787 1787
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1788 1788
 		if ($error != '') {
1789 1789
 			return $error;
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
 		global $tmp_dir, $globalDebug;
1796 1796
 		$error = '';
1797 1797
 		if ($globalDebug) echo "Translation : Download...";
1798
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1798
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1799 1799
 		if (file_exists($tmp_dir.'translation.zip')) {
1800 1800
 			if ($globalDebug) echo "Unzip...";
1801 1801
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 	public static function update_translation_fam() {
1812 1812
 		global $tmp_dir, $globalDebug;
1813 1813
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1814
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1814
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1815 1815
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1816 1816
 			if ($globalDebug) echo "Gunzip...";
1817 1817
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
 	public static function update_ModeS_fam() {
1827 1827
 		global $tmp_dir, $globalDebug;
1828 1828
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1829
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1829
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1830 1830
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1831 1831
 			if ($globalDebug) echo "Gunzip...";
1832 1832
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1842,9 +1842,9 @@  discard block
 block discarded – undo
1842 1842
 		global $tmp_dir, $globalDebug, $globalOwner;
1843 1843
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1844 1844
 		if ($globalOwner === TRUE) {
1845
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1845
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1846 1846
 		} else {
1847
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1847
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1848 1848
 		}
1849 1849
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1850 1850
 			if ($globalDebug) echo "Gunzip...";
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 	public static function update_routes_fam() {
1861 1861
 		global $tmp_dir, $globalDebug;
1862 1862
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1863
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1863
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1864 1864
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1865 1865
 			if ($globalDebug) echo "Gunzip...";
1866 1866
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1879,18 +1879,18 @@  discard block
 block discarded – undo
1879 1879
 		$error = '';
1880 1880
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1881 1881
 		if ($globalDBdriver == 'mysql') {
1882
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1882
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1883 1883
 		} else {
1884
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1884
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1885 1885
 		}
1886 1886
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1887
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1887
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1888 1888
 			$airspace_md5 = $airspace_md5_file[0];
1889 1889
 			if (!update_db::check_airspace_version($airspace_md5)) {
1890 1890
 				if ($globalDBdriver == 'mysql') {
1891
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1891
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1892 1892
 				} else {
1893
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1893
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1894 1894
 				}
1895 1895
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1896 1896
 					if ($globalDebug) echo "Gunzip...";
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
 						try {
1903 1903
 							$sth = $Connection->db->prepare($query);
1904 1904
     	    	    					$sth->execute();
1905
-			            		} catch(PDOException $e) {
1905
+			            		} catch (PDOException $e) {
1906 1906
 							return "error : ".$e->getMessage();
1907 1907
 		            			}
1908 1908
 		    			}
@@ -1920,15 +1920,15 @@  discard block
 block discarded – undo
1920 1920
 	public static function update_tle() {
1921 1921
 		global $tmp_dir, $globalDebug;
1922 1922
 		if ($globalDebug) echo "Download TLE : Download...";
1923
-		$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',
1924
-		'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',
1925
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1923
+		$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',
1924
+		'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',
1925
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1926 1926
 		foreach ($alltle as $filename) {
1927 1927
 			if ($globalDebug) echo "downloading ".$filename.'...';
1928
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1928
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1929 1929
 			if (file_exists($tmp_dir.$filename)) {
1930 1930
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1931
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1931
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1932 1932
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1933 1933
 			if ($error != '') {
1934 1934
 				echo $error."\n";
@@ -1941,32 +1941,32 @@  discard block
 block discarded – undo
1941 1941
 		global $tmp_dir, $globalDebug;
1942 1942
 		$error = '';
1943 1943
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1944
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1944
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1945 1945
 		if (file_exists($tmp_dir.'models.md5sum')) {
1946 1946
 			if ($globalDebug) echo "Check files...\n";
1947 1947
 			$newmodelsdb = array();
1948
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1949
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1948
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1949
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1950 1950
 					$model = trim($row[2]);
1951 1951
 					$newmodelsdb[$model] = trim($row[0]);
1952 1952
 				}
1953 1953
 			}
1954 1954
 			$modelsdb = array();
1955 1955
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1956
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1957
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1956
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1957
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1958 1958
 						$model = trim($row[2]);
1959 1959
 						$modelsdb[$model] = trim($row[0]);
1960 1960
 					}
1961 1961
 				}
1962 1962
 			}
1963
-			$diff = array_diff($newmodelsdb,$modelsdb);
1963
+			$diff = array_diff($newmodelsdb, $modelsdb);
1964 1964
 			foreach ($diff as $key => $value) {
1965 1965
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1966
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1966
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1967 1967
 				
1968 1968
 			}
1969
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1969
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1970 1970
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1971 1971
 		if ($error != '') {
1972 1972
 			return $error;
@@ -1978,32 +1978,32 @@  discard block
 block discarded – undo
1978 1978
 		global $tmp_dir, $globalDebug;
1979 1979
 		$error = '';
1980 1980
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1981
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1981
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1982 1982
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1983 1983
 			if ($globalDebug) echo "Check files...\n";
1984 1984
 			$newmodelsdb = array();
1985
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1986
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1985
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1986
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1987 1987
 					$model = trim($row[2]);
1988 1988
 					$newmodelsdb[$model] = trim($row[0]);
1989 1989
 				}
1990 1990
 			}
1991 1991
 			$modelsdb = array();
1992 1992
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1993
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1994
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1993
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1994
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1995 1995
 						$model = trim($row[2]);
1996 1996
 						$modelsdb[$model] = trim($row[0]);
1997 1997
 					}
1998 1998
 				}
1999 1999
 			}
2000
-			$diff = array_diff($newmodelsdb,$modelsdb);
2000
+			$diff = array_diff($newmodelsdb, $modelsdb);
2001 2001
 			foreach ($diff as $key => $value) {
2002 2002
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2003
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2003
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2004 2004
 				
2005 2005
 			}
2006
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2006
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2007 2007
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2008 2008
 		if ($error != '') {
2009 2009
 			return $error;
@@ -2026,8 +2026,8 @@  discard block
 block discarded – undo
2026 2026
 		*/
2027 2027
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2028 2028
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2029
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2030
-		    $result = fread($fh,100000000);
2029
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2030
+		    $result = fread($fh, 100000000);
2031 2031
 		    //echo $result;
2032 2032
 		    //var_dump(str_get_html($result));
2033 2033
 		    //print_r(self::table2array($result));
@@ -2045,23 +2045,23 @@  discard block
 block discarded – undo
2045 2045
 			$Connection = new Connection();
2046 2046
 			$sth = $Connection->db->prepare($query);
2047 2047
                         $sth->execute();
2048
-                } catch(PDOException $e) {
2048
+                } catch (PDOException $e) {
2049 2049
                         return "error : ".$e->getMessage();
2050 2050
                 }
2051 2051
 
2052 2052
 		$error = '';
2053 2053
 		if ($globalDebug) echo "Notam : Download...";
2054
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2054
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2055 2055
 		if (file_exists($tmp_dir.'notam.rss')) {
2056
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2056
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2057 2057
 			foreach ($notams['channel']['item'] as $notam) {
2058
-				$title = explode(':',$notam['title']);
2058
+				$title = explode(':', $notam['title']);
2059 2059
 				$data['ref'] = trim($title[0]);
2060 2060
 				unset($title[0]);
2061
-				$data['title'] = trim(implode(':',$title));
2062
-				$description = strip_tags($notam['description'],'<pre>');
2063
-				preg_match(':^(.*?)<pre>:',$description,$match);
2064
-				$q = explode('/',$match[1]);
2061
+				$data['title'] = trim(implode(':', $title));
2062
+				$description = strip_tags($notam['description'], '<pre>');
2063
+				preg_match(':^(.*?)<pre>:', $description, $match);
2064
+				$q = explode('/', $match[1]);
2065 2065
 				$data['fir'] = $q[0];
2066 2066
 				$data['code'] = $q[1];
2067 2067
 				$ifrvfr = $q[2];
@@ -2077,30 +2077,30 @@  discard block
 block discarded – undo
2077 2077
 				$data['lower_limit'] = $q[5];
2078 2078
 				$data['upper_limit'] = $q[6];
2079 2079
 				$latlonrad = $q[7];
2080
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2081
-				$latitude = $Common->convertDec($las,'latitude');
2082
-				$longitude = $Common->convertDec($lns,'longitude');
2080
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2081
+				$latitude = $Common->convertDec($las, 'latitude');
2082
+				$longitude = $Common->convertDec($lns, 'longitude');
2083 2083
 				if ($lac == 'S') $latitude = '-'.$latitude;
2084 2084
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2085 2085
 				$data['center_latitude'] = $latitude;
2086 2086
 				$data['center_longitude'] = $longitude;
2087 2087
 				$data['radius'] = intval($radius);
2088 2088
 				
2089
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2089
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2090 2090
 				$data['text'] = $match[1];
2091
-				preg_match(':</pre>(.*?)$:',$description,$match);
2091
+				preg_match(':</pre>(.*?)$:', $description, $match);
2092 2092
 				$fromto = $match[1];
2093
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2093
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2094 2094
 				$fromall = trim($match[1]);
2095
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2095
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2096 2096
 				$from = trim($match[1]);
2097
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2098
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2097
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2098
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2099 2099
 				$toall = trim($match[1]);
2100
-				if (!preg_match(':Permanent:',$toall)) {
2101
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2100
+				if (!preg_match(':Permanent:', $toall)) {
2101
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2102 2102
 					$to = trim($match[1]);
2103
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2103
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2104 2104
 					$data['permanent'] = 0;
2105 2105
 				} else {
2106 2106
 				    $data['date_end'] = NULL;
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 				}
2109 2109
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2110 2110
 				$NOTAM = new NOTAM();
2111
-				$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']);
2111
+				$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']);
2112 2112
 				unset($data);
2113 2113
 			} 
2114 2114
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2131,16 +2131,16 @@  discard block
 block discarded – undo
2131 2131
 				$Connection = new Connection();
2132 2132
 				$sth = $Connection->db->prepare($query);
2133 2133
 				$sth->execute();
2134
-			} catch(PDOException $e) {
2134
+			} catch (PDOException $e) {
2135 2135
 				return "error : ".$e->getMessage();
2136 2136
 			}
2137 2137
 		}
2138 2138
 		$Common = new Common();
2139 2139
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2140
-		$airspace_json = json_decode($airspace_lst,true);
2140
+		$airspace_json = json_decode($airspace_lst, true);
2141 2141
 		foreach ($airspace_json['records'] as $airspace) {
2142 2142
 			if ($globalDebug) echo $airspace['name']."...\n";
2143
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2143
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2144 2144
 			if (file_exists($tmp_dir.$airspace['name'])) {
2145 2145
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2146 2146
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
 			$Connection = new Connection();
2165 2165
 			$sth = $Connection->db->prepare($query);
2166 2166
                         $sth->execute();
2167
-                } catch(PDOException $e) {
2167
+                } catch (PDOException $e) {
2168 2168
                         return "error : ".$e->getMessage();
2169 2169
                 }
2170 2170
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 			$Connection = new Connection();
2180 2180
 			$sth = $Connection->db->prepare($query);
2181 2181
                         $sth->execute();
2182
-                } catch(PDOException $e) {
2182
+                } catch (PDOException $e) {
2183 2183
                         return "error : ".$e->getMessage();
2184 2184
                 }
2185 2185
 	}
@@ -2190,7 +2190,7 @@  discard block
 block discarded – undo
2190 2190
 			$Connection = new Connection();
2191 2191
 			$sth = $Connection->db->prepare($query);
2192 2192
                         $sth->execute(array(':version' => $version));
2193
-                } catch(PDOException $e) {
2193
+                } catch (PDOException $e) {
2194 2194
                         return "error : ".$e->getMessage();
2195 2195
                 }
2196 2196
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 			$Connection = new Connection();
2207 2207
 			$sth = $Connection->db->prepare($query);
2208 2208
                         $sth->execute(array(':version' => $version));
2209
-                } catch(PDOException $e) {
2209
+                } catch (PDOException $e) {
2210 2210
                         return "error : ".$e->getMessage();
2211 2211
                 }
2212 2212
 	}
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 			$Connection = new Connection();
2223 2223
 			$sth = $Connection->db->prepare($query);
2224 2224
                         $sth->execute();
2225
-                } catch(PDOException $e) {
2225
+                } catch (PDOException $e) {
2226 2226
                         return "error : ".$e->getMessage();
2227 2227
                 }
2228 2228
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
 			$Connection = new Connection();
2238 2238
 			$sth = $Connection->db->prepare($query);
2239 2239
                         $sth->execute();
2240
-                } catch(PDOException $e) {
2240
+                } catch (PDOException $e) {
2241 2241
                         return "error : ".$e->getMessage();
2242 2242
                 }
2243 2243
 	}
@@ -2252,7 +2252,7 @@  discard block
 block discarded – undo
2252 2252
 			$Connection = new Connection();
2253 2253
 			$sth = $Connection->db->prepare($query);
2254 2254
                         $sth->execute();
2255
-                } catch(PDOException $e) {
2255
+                } catch (PDOException $e) {
2256 2256
                         return "error : ".$e->getMessage();
2257 2257
                 }
2258 2258
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 			$Connection = new Connection();
2268 2268
 			$sth = $Connection->db->prepare($query);
2269 2269
                         $sth->execute();
2270
-                } catch(PDOException $e) {
2270
+                } catch (PDOException $e) {
2271 2271
                         return "error : ".$e->getMessage();
2272 2272
                 }
2273 2273
 	}
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 			$Connection = new Connection();
2284 2284
 			$sth = $Connection->db->prepare($query);
2285 2285
                         $sth->execute();
2286
-                } catch(PDOException $e) {
2286
+                } catch (PDOException $e) {
2287 2287
                         return "error : ".$e->getMessage();
2288 2288
                 }
2289 2289
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2298,7 +2298,7 @@  discard block
 block discarded – undo
2298 2298
 			$Connection = new Connection();
2299 2299
 			$sth = $Connection->db->prepare($query);
2300 2300
                         $sth->execute();
2301
-                } catch(PDOException $e) {
2301
+                } catch (PDOException $e) {
2302 2302
                         return "error : ".$e->getMessage();
2303 2303
                 }
2304 2304
 	}
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 			$Connection = new Connection();
2314 2314
 			$sth = $Connection->db->prepare($query);
2315 2315
                         $sth->execute();
2316
-                } catch(PDOException $e) {
2316
+                } catch (PDOException $e) {
2317 2317
                         return "error : ".$e->getMessage();
2318 2318
                 }
2319 2319
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
 			$Connection = new Connection();
2329 2329
 			$sth = $Connection->db->prepare($query);
2330 2330
                         $sth->execute();
2331
-                } catch(PDOException $e) {
2331
+                } catch (PDOException $e) {
2332 2332
                         return "error : ".$e->getMessage();
2333 2333
                 }
2334 2334
 	}
@@ -2343,7 +2343,7 @@  discard block
 block discarded – undo
2343 2343
 			$Connection = new Connection();
2344 2344
 			$sth = $Connection->db->prepare($query);
2345 2345
                         $sth->execute();
2346
-                } catch(PDOException $e) {
2346
+                } catch (PDOException $e) {
2347 2347
                         return "error : ".$e->getMessage();
2348 2348
                 }
2349 2349
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2358,7 +2358,7 @@  discard block
 block discarded – undo
2358 2358
 			$Connection = new Connection();
2359 2359
 			$sth = $Connection->db->prepare($query);
2360 2360
                         $sth->execute();
2361
-                } catch(PDOException $e) {
2361
+                } catch (PDOException $e) {
2362 2362
                         return "error : ".$e->getMessage();
2363 2363
                 }
2364 2364
 	}
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
 			$Connection = new Connection();
2374 2374
 			$sth = $Connection->db->prepare($query);
2375 2375
                         $sth->execute();
2376
-                } catch(PDOException $e) {
2376
+                } catch (PDOException $e) {
2377 2377
                         return "error : ".$e->getMessage();
2378 2378
                 }
2379 2379
 	}
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 			$Connection = new Connection();
2389 2389
 			$sth = $Connection->db->prepare($query);
2390 2390
                         $sth->execute();
2391
-                } catch(PDOException $e) {
2391
+                } catch (PDOException $e) {
2392 2392
                         return "error : ".$e->getMessage();
2393 2393
                 }
2394 2394
 	}
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
     * @param Array $filter the filter
16 16
     * @return Array the SQL part
17 17
     */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
18
+    public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-		foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+		foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 		}
25 25
 	    } else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27 27
 	    }
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
                  try {
46 46
                         $sth = $this->db->prepare($query);
47 47
                         $sth->execute($query_values);
48
-                } catch(PDOException $e) {
48
+                } catch (PDOException $e) {
49 49
                         return "error : ".$e->getMessage();
50 50
                 }
51 51
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
52 52
                 return $all;
53 53
         }
54 54
 
55
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
56
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
57
-    		$info = str_replace('^','<br />',$info);
58
-    		$info = str_replace('&amp;sect;','',$info);
59
-    		$info = str_replace('"','',$info);
55
+       public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
56
+    		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
57
+    		$info = str_replace('^', '<br />', $info);
58
+    		$info = str_replace('&amp;sect;', '', $info);
59
+    		$info = str_replace('"', '', $info);
60 60
     		if ($type == '') $type = NULL;
61 61
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
62
+                $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute($query_values);
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         return "error : ".$e->getMessage();
68 68
                 }
69 69
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                  try {
75 75
                         $sth = $this->db->prepare($query);
76 76
                         $sth->execute($query_values);
77
-                } catch(PDOException $e) {
77
+                } catch (PDOException $e) {
78 78
                         return "error : ".$e->getMessage();
79 79
                 }
80 80
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                  try {
86 86
                         $sth = $this->db->prepare($query);
87 87
                         $sth->execute($query_values);
88
-                } catch(PDOException $e) {
88
+                } catch (PDOException $e) {
89 89
                         return "error : ".$e->getMessage();
90 90
                 }
91 91
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 try {
101 101
                         $sth = $this->db->prepare($query);
102 102
                         $sth->execute();
103
-                } catch(PDOException $e) {
103
+                } catch (PDOException $e) {
104 104
                         return "error";
105 105
                 }
106 106
                 return "success";
Please login to merge, or discard this patch.
install/index.php 1 patch
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.create_db.php');
10 10
 require_once(dirname(__FILE__).'/class.update_schema.php');
11 11
 require_once(dirname(__FILE__).'/class.settings.php');
12
-$title="Install";
12
+$title = "Install";
13 13
 require(dirname(__FILE__).'/../require/settings.php');
14 14
 require(dirname(__FILE__).'/header.php');
15 15
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 if (!extension_loaded('curl')) {
67 67
 	$error[] = "Curl is not loaded.";
68 68
 }
69
-if(function_exists('apache_get_modules') ){
70
-	if(!in_array('mod_rewrite',apache_get_modules())) {
69
+if (function_exists('apache_get_modules')) {
70
+	if (!in_array('mod_rewrite', apache_get_modules())) {
71 71
 		$error[] = "mod_rewrite is not available.";
72 72
 	}
73 73
 /*
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
84 84
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
85 85
 	if (function_exists('get_headers')) {
86
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
87
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
86
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
87
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
88 88
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
89 89
 		}
90 90
 	}
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
 ?>
425 425
 							<tr>
426 426
 								<?php
427
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
427
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
428 428
 								?>
429 429
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
430 430
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
431 431
 								<?php
432 432
 								    } else {
433
-									$hostport = explode(':',$source['host']);
433
+									$hostport = explode(':', $source['host']);
434 434
 									if (isset($hostport[1])) {
435 435
 										$host = $hostport[0];
436 436
 										$port = $hostport[1];
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 			<br />
765 765
 			<p>
766 766
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
767
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
767
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
768 768
 			</p>
769 769
 			<br />
770 770
 			<p>
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 $error = '';
811 811
 
812 812
 if (isset($_POST['dbtype'])) {
813
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
814
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
815
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
816
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
817
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
818
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
819
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
820
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
813
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
814
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
815
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
816
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
817
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
818
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
819
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
820
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
821 821
 
822 822
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
823 823
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -837,48 +837,48 @@  discard block
 block discarded – undo
837 837
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
838 838
 	*/
839 839
 	
840
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
840
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
841 841
 
842
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
843
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
844
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
845
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
846
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
842
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
843
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
844
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
845
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
846
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
847 847
 
848
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
849
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
850
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
851
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
852
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
853
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
854
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
855
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
856
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
848
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
849
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
850
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
851
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
852
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
853
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
854
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
855
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
856
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
857 857
 	
858
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
859
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
860
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
861
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
862
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
863
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
858
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
859
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
860
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
861
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
862
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
863
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
864 864
 
865
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
866
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
865
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
866
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
867 867
 
868
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
869
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
870
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
868
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
869
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
870
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
871 871
 
872
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
872
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
873 873
 	if ($acars == 'acars') {
874
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
874
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
875 875
 	} else {
876
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
876
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
877 877
 	}
878 878
 
879
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
880
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
881
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
879
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
880
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
881
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
882 882
 	
883 883
 	$source_name = $_POST['source_name'];
884 884
 	$source_latitude = $_POST['source_latitude'];
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 	
893 893
 	$sources = array();
894 894
 	foreach ($source_name as $keys => $name) {
895
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
896
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
895
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
896
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
897 897
 	}
898 898
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
899 899
 
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
 	$sbsurl = $_POST['sbsurl'];
907 907
 	*/
908 908
 
909
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
910
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
911
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
912
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
913
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
914
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
915
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
909
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
910
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
911
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
912
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
913
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
914
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
915
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
916 916
 
917 917
 /*	
918 918
 	$globalSBS1Hosts = array();
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	}
929 929
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
930 930
 */
931
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
931
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
932 932
 	$host = $_POST['host'];
933 933
 	$port = $_POST['port'];
934 934
 	$name = $_POST['name'];
@@ -939,96 +939,96 @@  discard block
 block discarded – undo
939 939
 	foreach ($host as $key => $h) {
940 940
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
941 941
 		else $cov = 'FALSE';
942
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
942
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
943 943
 	}
944
-	$settings = array_merge($settings,array('globalSources' => $gSources));
944
+	$settings = array_merge($settings, array('globalSources' => $gSources));
945 945
 
946 946
 /*
947 947
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
948 948
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
949 949
 */
950
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
951
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
952
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
950
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
951
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
952
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
953 953
 
954
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
955
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
954
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
955
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
956 956
 
957
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
958
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
959
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
960
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
957
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
958
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
959
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
960
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
961 961
 
962
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
963
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
964
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
962
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
963
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
964
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
965 965
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
966
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
967
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
966
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
967
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
968 968
 
969
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
970
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
971
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
972
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
973
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
974
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
975
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
976
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
969
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
970
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
971
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
972
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
973
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
974
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
975
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
976
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
977 977
 
978
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
979
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
978
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
979
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
980 980
 
981
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
982
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
981
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
982
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
983 983
 	
984
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
984
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
985 985
 	if ($archiveyear == "archiveyear") {
986
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
986
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
987 987
 	} else {
988
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
988
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
989 989
 	}
990
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
991
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
992
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
993
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
990
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
991
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
992
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
993
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
994 994
 
995
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
996
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
997
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
998
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
995
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
996
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
997
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
998
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
999 999
 
1000
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1001
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1002
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1000
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1001
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1002
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1003 1003
 
1004 1004
 	// Create in settings.php keys not yet configurable if not already here
1005 1005
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1006
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1006
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1007 1007
 
1008
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1008
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1009 1009
 	if ($resetyearstats == 'resetyearstats') {
1010
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1010
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1011 1011
 	} else {
1012
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1012
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1013 1013
 	}
1014 1014
 
1015
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1015
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1016 1016
 	if ($archive == 'archive') {
1017
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1017
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1018 1018
 	} else {
1019
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1019
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1020 1020
 	}
1021
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1021
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1022 1022
 	if ($daemon == 'daemon') {
1023
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1023
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1024 1024
 	} else {
1025
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1025
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1026 1026
 	}
1027
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1027
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1028 1028
 	if ($schedules == 'schedules') {
1029
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1029
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1030 1030
 	} else {
1031
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1031
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1032 1032
 	}
1033 1033
 
1034 1034
 /*
@@ -1039,177 +1039,177 @@  discard block
 block discarded – undo
1039 1039
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1040 1040
 	}
1041 1041
 */
1042
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1043
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1044
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1045
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1042
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1043
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1044
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1045
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1046
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1047 1047
 	if ($globalivao == 'ivao') {
1048 1048
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1049
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1050
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1049
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1050
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1051 1051
 	if ($globalvatsim == 'vatsim') {
1052 1052
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1053
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1054
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1053
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1054
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1055 1055
 	if ($globalphpvms == 'phpvms') {
1056
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1057
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1056
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1057
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1058 1058
 	if ($globalvam == 'vam') {
1059
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1060
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1059
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1060
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1061 1061
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1062
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1063
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1062
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1063
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1064 1064
 	
1065 1065
 
1066 1066
 
1067
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1067
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1068 1068
 	if ($notam == 'notam') {
1069
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1069
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1070 1070
 	} else {
1071
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1071
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1072 1072
 	}
1073
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1073
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1074 1074
 	if ($owner == 'owner') {
1075
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1075
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1076 1076
 	} else {
1077
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1077
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1078 1078
 	}
1079
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1079
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1080 1080
 	if ($map3d == 'map3d') {
1081
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1081
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1082 1082
 	} else {
1083
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1083
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1084 1084
 	}
1085
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1085
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1086 1086
 	if ($crash == 'crash') {
1087
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1087
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1088 1088
 	} else {
1089
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1089
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1090 1090
 	}
1091
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1091
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1092 1092
 	if ($mapsatellites == 'mapsatellites') {
1093
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1093
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1094 1094
 	} else {
1095
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1095
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1096 1096
 	}
1097
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1097
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1098 1098
 	if ($map3ddefault == 'map3ddefault') {
1099
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1099
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1100 1100
 	} else {
1101
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1101
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1102 1102
 	}
1103
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1103
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1104 1104
 	if ($translate == 'translate') {
1105
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1105
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1106 1106
 	} else {
1107
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1107
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1108 1108
 	}
1109
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1109
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1110 1110
 	if ($realairlines == 'realairlines') {
1111
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1111
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1112 1112
 	} else {
1113
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1113
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1114 1114
 	}
1115
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1115
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1116 1116
 	if ($estimation == 'estimation') {
1117
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1117
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1118 1118
 	} else {
1119
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1119
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1120 1120
 	}
1121
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1121
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1122 1122
 	if ($metar == 'metar') {
1123
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1123
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1124 1124
 	} else {
1125
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1125
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1126 1126
 	}
1127
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1127
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1128 1128
 	if ($metarcycle == 'metarcycle') {
1129
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1129
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1130 1130
 	} else {
1131
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1131
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1132 1132
 	}
1133
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1133
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1134 1134
 	if ($fork == 'fork') {
1135
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1135
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1136 1136
 	} else {
1137
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1137
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1138 1138
 	}
1139 1139
 
1140
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1140
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1141 1141
 	if ($colormap == 'colormap') {
1142
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1142
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1143 1143
 	} else {
1144
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1144
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1145 1145
 	}
1146 1146
 	
1147 1147
 	if (isset($_POST['aircrafticoncolor'])) {
1148
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1149
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1148
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1149
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1150 1150
 	}
1151 1151
 
1152
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1153
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1152
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1153
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1154 1154
 
1155
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1156
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1157
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1158
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1159
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1160
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1155
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1156
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1157
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1158
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1159
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1160
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1161 1161
 
1162
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1162
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1163 1163
 	if ($mappopup == 'mappopup') {
1164
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1164
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1165 1165
 	} else {
1166
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1166
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1167 1167
 	}
1168
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1168
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1169 1169
 	if ($airportpopup == 'airportpopup') {
1170
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1170
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1171 1171
 	} else {
1172
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1172
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1173 1173
 	}
1174
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1174
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1175 1175
 	if ($maphistory == 'maphistory') {
1176
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1176
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1177 1177
 	} else {
1178
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1178
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1179 1179
 	}
1180
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1180
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1181 1181
 	if ($flightroute == 'flightroute') {
1182
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1182
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1183 1183
 	} else {
1184
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1184
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1185 1185
 	}
1186
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1186
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1187 1187
 	if ($allflights == 'allflights') {
1188
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1188
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1189 1189
 	} else {
1190
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1190
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1191 1191
 	}
1192
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1192
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1193 1193
 	if ($waypoints == 'waypoints') {
1194
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1194
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1195 1195
 	} else {
1196
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1196
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1197 1197
 	}
1198 1198
 
1199
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1199
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1200 1200
 
1201 1201
 	// Set some defaults values...
1202 1202
 	if (!isset($globalAircraftImageSources)) {
1203
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1204
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1203
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1204
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1205 1205
 	}
1206 1206
 
1207 1207
 	if (!isset($globalSchedulesSources)) {
1208
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1209
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1208
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1209
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1210 1210
     	}
1211 1211
 
1212
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1212
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1213 1213
 
1214 1214
 	if ($error == '') settings::modify_settings($settings);
1215 1215
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,29 +331,29 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345
-	    		while(($line = fgets($handle,4096)) !== false) {
346
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
345
+	    		while (($line = fgets($handle, 4096)) !== false) {
346
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
347 347
 					$date = $line;
348 348
     				} elseif ($line != '') {
349 349
     				    //$this->parse($line);
350 350
     				    if ($date == '') $date = date('Y/m/d H:m');
351 351
         			    $pos = 0;
352
-        			    $pieces = preg_split('/\s/',$line);
352
+        			    $pieces = preg_split('/\s/', $line);
353 353
         			    if ($pieces[0] == 'METAR') $pos++;
354 354
         			    if (strlen($pieces[$pos]) != 4) $pos++;
355 355
 		        	    $location = $pieces[$pos];
356
-        	        	    echo $this->addMETAR($location,$line,$date);
356
+        	        	    echo $this->addMETAR($location, $line, $date);
357 357
     				}
358 358
     			}
359 359
     			fclose($handle);
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
     		if ($globalMETARurl == '') return array();
367 367
     		date_default_timezone_set("UTC");
368 368
     		$Common = new Common();
369
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
369
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
370 370
     		$cycle = $Common->getData($url);
371 371
     		$date = '';
372
-    		foreach(explode("\n",$cycle) as $line) {
373
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
372
+    		foreach (explode("\n", $cycle) as $line) {
373
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
374 374
     				//echo "date : ".$line."\n";
375 375
     				$date = $line;
376 376
     			} 
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
     			    //echo $line;
380 380
     			    if ($date == '') $date = date('Y/m/d H:m');
381 381
     			    $pos = 0;
382
-    			    $pieces = preg_split('/\s/',$line);
382
+    			    $pieces = preg_split('/\s/', $line);
383 383
     			    if ($pieces[0] == 'METAR') $pos++;
384 384
     			    if (strlen($pieces[$pos]) != 4) $pos++;
385 385
 	        	    $location = $pieces[$pos];
386 386
 	        	    if (strlen($location == 4)) {
387
-	        		$this->addMETAR($location,$line,$date);
387
+	        		$this->addMETAR($location, $line, $date);
388 388
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389 389
 	        	    } else return array();
390 390
     			}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+    public function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67 67
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
69
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
70 70
 		    // Should also check if route schedule = route from DB
71 71
 		    if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			    }
87 87
 			}
88 88
 		    }
89
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
90 90
 		}
91 91
 	    } else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
        if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96 96
     		$sch = $Schedule->getSchedule($operator);
97
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
97
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
98 98
        }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121 121
     		$Spotter = new Spotter($this->db);
122 122
         	$real_arrival = $this->arrival($key);
123
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
123
+        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
124 124
             }
125 125
 	}
126 126
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $airport_time = '';
134 134
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
136
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
137 137
     	    if (isset($closestAirports[0])) {
138 138
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 139
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         		    break;
149 149
         		}
150 150
         	    }
151
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
151
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
152 152
         		$airport_icao = $closestAirports[0]['icao'];
153 153
         		$airport_time = $this->all_flights[$key]['datetime'];
154 154
         	} else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         } else {
162 162
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163 163
         }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
164
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
165 165
     }
166 166
 
167 167
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174 174
     	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
175
+        	if ($flight['lastupdate'] < (time() - 3000)) {
176 176
             	    if (isset($this->all_flights[$key]['id'])) {
177 177
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             		$real_arrival = $this->arrival($key);
184 184
             		$Spotter = new Spotter($this->db);
185 185
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
186
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	$send = false;
220 220
 	
221 221
 	// SBS format is CSV format
222
-	if(is_array($line) && isset($line['hex'])) {
222
+	if (is_array($line) && isset($line['hex'])) {
223 223
 	    //print_r($line);
224 224
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
225 225
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 		//print_r($this->all_flights);
254 254
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
255 255
 		    $this->all_flights[$id] = array('hex' => $hex);
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
257 257
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
258 258
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
259 259
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			$Spotter = new Spotter($this->db);
264 264
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 265
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
266
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
267 267
 
268 268
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269 269
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -271,32 +271,32 @@  discard block
 block discarded – undo
271 271
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272 272
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
273 273
 			}
274
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
274
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
275 275
 		    } else if (isset($line['aircraft_name'])) {
276 276
 			// Get aircraft ICAO from aircraft name
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 279
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
281
+			else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
282
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
283
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true));
284
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
285 285
 		    if (!isset($line['id'])) {
286 286
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287 287
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 288
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
290 290
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
291
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
292 292
 
293 293
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294 294
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
295 295
 		}
296 296
 		
297
-		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
297
+		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
298 298
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
299
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
299
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
300 300
 		    } else {
301 301
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
302 302
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -307,23 +307,23 @@  discard block
 block discarded – undo
307 307
 				*/
308 308
 				return '';
309 309
 		    }
310
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
310
+		} else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
311 311
 
312 312
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
313
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
314 314
 		}
315 315
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
316
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
317 317
 		}
318 318
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
319
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
319
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
320 320
 		}
321 321
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
322
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
322
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
323 323
 		}
324 324
  
325 325
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
326
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
326
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
327 327
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
328 328
 			$timeelapsed = microtime(true);
329 329
             		$Spotter = new Spotter($this->db);
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
334 334
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
335 335
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
336
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
336
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
337 337
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
338 338
 			$Spotter->db = null;
339
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
339
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
340 340
 		    }
341 341
 
342 342
 /*
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
348 348
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
349 349
   */
350
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
350
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
351 351
 
352 352
 		    //$putinarchive = true;
353 353
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
354
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
354
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
355 355
 		    }
356 356
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
357
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
357
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
358 358
 		    }
359 359
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
360
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
360
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
361 361
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
362 362
 				$timeelapsed = microtime(true);
363 363
 				$Spotter = new Spotter($this->db);
364 364
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
365 365
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
366
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
367
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
366
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
367
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
368 368
 
369 369
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
370 370
 			$timeelapsed = microtime(true);
@@ -377,34 +377,34 @@  discard block
 block discarded – undo
377 377
 				$Translation->db = null;
378 378
 			}
379 379
 			$Spotter->db = null;
380
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
380
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
381 381
 
382 382
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
383 383
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
384 384
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
385 385
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
386
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
386
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
387 387
 		    	    }
388 388
 			}
389 389
 			if (!isset($globalFork)) $globalFork = TRUE;
390 390
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
391
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
391
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
392 392
 			}
393 393
 		    }
394 394
 		}
395 395
 
396 396
 		if (isset($line['speed']) && $line['speed'] != '') {
397 397
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
398
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
399
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
398
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
399
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
400 400
 		    //$dataFound = true;
401 401
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
402
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
402
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
403 403
 		    if ($distance > 1000 && $distance < 10000) {
404 404
 		    // use datetime
405 405
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
406 406
 			$speed = $speed*3.6;
407
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
407
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
408 408
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
409 409
 		    }
410 410
 		}
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 
414 414
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
415
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
415
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
416 416
 	    	    else unset($timediff);
417
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
417
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
418 418
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
419
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
419
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
420 420
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
421 421
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
422 422
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
425 425
 				$timeelapsed = microtime(true);
426 426
 				$Spotter = new Spotter($this->db);
427
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
427
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
428 428
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
429 429
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
430
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
431 431
 				$this->tmd = 0;
432 432
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
433 433
 			    }
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
437 437
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
438 438
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
439
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
439
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
440 440
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
441 441
 				    $dataFound = true;
442 442
 				    $this->all_flights[$id]['time_last_coord'] = time();
443 443
 				}
444 444
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
445
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
445
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
446 446
 				/*
447 447
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
448 448
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
461 461
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
462 462
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
463
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
464 464
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
465 465
 				    $dataFound = true;
466 466
 				    $this->all_flights[$id]['time_last_coord'] = time();
467 467
 				}
468 468
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
469
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
469
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
470 470
 				/*
471 471
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
472 472
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -484,45 +484,45 @@  discard block
 block discarded – undo
484 484
 		    } else if ($globalDebug && $timediff > 20) {
485 485
 			$this->tmd = $this->tmd + 1;
486 486
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
487
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
488
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
487
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
488
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
489 489
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
490 490
 		    }
491 491
 		}
492 492
 		if (isset($line['last_update']) && $line['last_update'] != '') {
493 493
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
494
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
495 495
 		}
496 496
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
497
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
497
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
498 498
 		    //$dataFound = true;
499 499
 		}
500 500
 		if (isset($line['format_source']) && $line['format_source'] != '') {
501
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
501
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
502 502
 		}
503 503
 		if (isset($line['source_name']) && $line['source_name'] != '') {
504
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
504
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
505 505
 		}
506 506
 		if (isset($line['emergency']) && $line['emergency'] != '') {
507
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
507
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
508 508
 		    //$dataFound = true;
509 509
 		}
510 510
 		if (isset($line['ground']) && $line['ground'] != '') {
511 511
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
512 512
 			// Here we force archive of flight because after ground it's a new one (or should be)
513
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
514
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
515
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
516
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
517
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
513
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
514
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
515
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
516
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
517
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
518 518
 		    }
519 519
 		    if ($line['ground'] != 1) $line['ground'] = 0;
520
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
520
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
521 521
 		    //$dataFound = true;
522 522
 		}
523 523
 		if (isset($line['squawk']) && $line['squawk'] != '') {
524 524
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
525
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
525
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
526 526
 			    $highlight = '';
527 527
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
528 528
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -530,48 +530,48 @@  discard block
 block discarded – undo
530 530
 			    if ($highlight != '') {
531 531
 				$timeelapsed = microtime(true);
532 532
 				$Spotter = new Spotter($this->db);
533
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
533
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
534 534
 				$Spotter->db = null;
535
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
536 536
 
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
538 538
 				//$putinarchive = true;
539 539
 				//$highlight = '';
540 540
 			    }
541 541
 			    
542
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
542
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
543 543
 		    //$dataFound = true;
544 544
 		}
545 545
 
546 546
 		if (isset($line['altitude']) && $line['altitude'] != '') {
547 547
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
548
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
549
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
550
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
548
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
550
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
551 551
 			//$dataFound = true;
552 552
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
553 553
   		}
554 554
 
555 555
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
556
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
556
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
557 557
 		}
558 558
 		
559 559
 		if (isset($line['heading']) && $line['heading'] != '') {
560
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
562
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
560
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
562
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
563 563
 		    //$dataFound = true;
564 564
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
565
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
567
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
565
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
566
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
567
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
568 568
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
569 569
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
570 570
   		    // If not enough messages and ACARS set heading to 0
571
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
571
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
572 572
   		}
573
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
574
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
573
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
574
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
575 575
 
576 576
 //		print_r($this->all_flights[$id]);
577 577
 		//gets the callsign from the last hour
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
582 582
 		    $this->all_flights[$id]['lastupdate'] = time();
583 583
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
584
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
584
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
585 585
 			    //print_r($this->all_flights);
586 586
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
587 587
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -591,61 +591,61 @@  discard block
 block discarded – undo
591 591
 				$SpotterLive = new SpotterLive($this->db);
592 592
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
593 593
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
595 595
 				} elseif (isset($line['id'])) {
596 596
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
597
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
597
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
598 598
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
599 599
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
600
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
600
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
601 601
 				} else $recent_ident = '';
602
-				$SpotterLive->db=null;
602
+				$SpotterLive->db = null;
603 603
 
604 604
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
605 605
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
606 606
 			    } else {
607 607
 				$recent_ident = '';
608
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
608
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
609 609
 			    }
610 610
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
611
-			    if($recent_ident == "")
611
+			    if ($recent_ident == "")
612 612
 			    {
613 613
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
614 614
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
615 615
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
616 616
 				//adds the spotter data for the archive
617 617
 				$ignoreImport = false;
618
-				foreach($globalAirportIgnore as $airportIgnore) {
618
+				foreach ($globalAirportIgnore as $airportIgnore) {
619 619
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
620 620
 					$ignoreImport = true;
621 621
 				    }
622 622
 				}
623 623
 				if (count($globalAirportAccept) > 0) {
624 624
 				    $ignoreImport = true;
625
-				    foreach($globalAirportIgnore as $airportIgnore) {
625
+				    foreach ($globalAirportIgnore as $airportIgnore) {
626 626
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
627 627
 					    $ignoreImport = false;
628 628
 					}
629 629
 				    }
630 630
 				}
631 631
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
632
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
633
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
632
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
633
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
634 634
 					    $ignoreImport = true;
635 635
 					}
636 636
 				    }
637 637
 				}
638 638
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
639 639
 				    $ignoreImport = true;
640
-				    foreach($globalAirlineAccept as $airlineAccept) {
641
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
640
+				    foreach ($globalAirlineAccept as $airlineAccept) {
641
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
642 642
 					    $ignoreImport = false;
643 643
 					}
644 644
 				    }
645 645
 				}
646 646
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
647 647
 				    $ignoreImport = true;
648
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
648
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
649 649
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
650 650
 					    $ignoreImport = false;
651 651
 					}
@@ -657,27 +657,27 @@  discard block
 block discarded – undo
657 657
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
658 658
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
659 659
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
660
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
660
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
661 661
 				    $timeelapsed = microtime(true);
662 662
 				    $Spotter = new Spotter($this->db);
663
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
663
+				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']);
664 664
 				    $Spotter->db = null;
665 665
 				    if ($globalDebug && isset($result)) echo $result."\n";
666
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
666
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
667 667
 				    
668 668
 				    // Add source stat in DB
669 669
 				    $Stats = new Stats($this->db);
670 670
 				    if (!empty($this->stats)) {
671 671
 					if ($globalDebug) echo 'Add source stats : ';
672
-				        foreach($this->stats as $date => $data) {
673
-					    foreach($data as $source => $sourced) {
672
+				        foreach ($this->stats as $date => $data) {
673
+					    foreach ($data as $source => $sourced) {
674 674
 					        //print_r($sourced);
675
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
676
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
675
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
676
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
677 677
 				    		if (isset($sourced['msg'])) {
678 678
 				    		    if (time() - $sourced['msg']['date'] > 10) {
679 679
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
680
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
680
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
681 681
 			    			        unset($this->stats[$date][$source]['msg']);
682 682
 			    			    }
683 683
 			    			}
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
714 714
 				    $SpotterLive = new SpotterLive($this->db);
715 715
 				    $SpotterLive->deleteLiveSpotterData();
716
-				    $SpotterLive->db=null;
716
+				    $SpotterLive->db = null;
717 717
 				    if ($globalDebug) echo " Done\n";
718 718
 				    $this->last_delete = time();
719 719
 				}
720 720
 			    } else {
721
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
721
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
722 722
 				    $this->all_flights[$id]['id'] = $recent_ident;
723 723
 				    $this->all_flights[$id]['addedSpotter'] = 1;
724 724
 				}
725 725
 				if (isset($globalDaemon) && !$globalDaemon) {
726 726
 					$Spotter = new Spotter($this->db);
727
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
727
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
728 728
 					$Spotter->db = null;
729 729
 				}
730 730
 				
@@ -748,37 +748,37 @@  discard block
 block discarded – undo
748 748
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
749 749
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
750 750
 
751
-		    foreach($globalAirportIgnore as $airportIgnore) {
751
+		    foreach ($globalAirportIgnore as $airportIgnore) {
752 752
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
753 753
 			    $ignoreImport = true;
754 754
 			}
755 755
 		    }
756 756
 		    if (count($globalAirportAccept) > 0) {
757 757
 		        $ignoreImport = true;
758
-		        foreach($globalAirportIgnore as $airportIgnore) {
758
+		        foreach ($globalAirportIgnore as $airportIgnore) {
759 759
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
760 760
 				$ignoreImport = false;
761 761
 			    }
762 762
 			}
763 763
 		    }
764 764
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
765
-			foreach($globalAirlineIgnore as $airlineIgnore) {
766
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
765
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
766
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
767 767
 				$ignoreImport = true;
768 768
 			    }
769 769
 			}
770 770
 		    }
771 771
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
772 772
 			$ignoreImport = true;
773
-			foreach($globalAirlineAccept as $airlineAccept) {
774
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
773
+			foreach ($globalAirlineAccept as $airlineAccept) {
774
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
775 775
 				$ignoreImport = false;
776 776
 			    }
777 777
 			}
778 778
 		    }
779 779
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
780 780
 			$ignoreImport = true;
781
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
781
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
782 782
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
783 783
 			        $ignoreImport = false;
784 784
 			    }
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 		    }
787 787
 
788 788
 		    if (!$ignoreImport) {
789
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
789
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
790 790
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
791 791
 				$timeelapsed = microtime(true);
792 792
 				$SpotterLive = new SpotterLive($this->db);
793
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
793
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
794 794
 				$SpotterLive->db = null;
795
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
795
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
796 796
 
797 797
 				// Put statistics in $this->stats variable
798 798
 				//if ($line['format_source'] != 'aprs') {
@@ -810,19 +810,19 @@  discard block
 block discarded – undo
810 810
 							$latitude = $globalCenterLatitude;
811 811
 							$longitude = $globalCenterLongitude;
812 812
 						}
813
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
813
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
814 814
 					} else {
815 815
 						$latitude = $this->source_location[$source]['latitude'];
816 816
 						$longitude = $this->source_location[$source]['longitude'];
817 817
 					}
818
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
818
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
819 819
 					//$stats_heading = $stats_heading%22.5;
820 820
 					$stats_heading = round($stats_heading/22.5);
821
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
821
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
822 822
 					$current_date = date('Y-m-d');
823 823
 					if ($stats_heading == 16) $stats_heading = 0;
824 824
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
825
-						for ($i=0;$i<=15;$i++) {
825
+						for ($i = 0; $i <= 15; $i++) {
826 826
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
827 827
 						}
828 828
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
838 838
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
839 839
 						    end($this->stats[$current_date][$source]['hist']);
840
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
840
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
841 841
 						} else $mini = 0;
842
-						for ($i=$mini;$i<=$distance;$i+=10) {
842
+						for ($i = $mini; $i <= $distance; $i += 10) {
843 843
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
844 844
 						}
845 845
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
853 853
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
854 854
 				if ($globalDebug) echo $result."\n";
855
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
855
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
856 856
 			//$this->del();
857 857
 			
858 858
 			
Please login to merge, or discard this patch.
incident-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;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 print '<div class="table column">';
36 36
 print '<p>'._("The table below shows the latest Incidents.").'</p>';
37
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident');
37
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident');
38 38
 //print_r($spotter_array);
39 39
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
40 40
 	include('table-output.php');
Please login to merge, or discard this patch.
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;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 print '<div class="table column">';
36 36
 print '<p>'._("The table below shows the latest Accidents.").'</p>';
37
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident');
37
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'accident');
38 38
 //print_r($spotter_array);
39 39
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
40 40
 	include('table-output.php');
Please login to merge, or discard this patch.
incident-detailed.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 {
11 11
 	$date = date('Y-m-d');
12 12
 } else {
13
-	$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
13
+	$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
14 14
 }
15 15
 
16
-if(!isset($_GET['limit']))
16
+if (!isset($_GET['limit']))
17 17
 {
18 18
 	$limit_start = 0;
19 19
 	$limit_end = 25;
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 print '<br />';
49 49
 
50 50
 print '<div class="info column">';
51
-print '<h1>'.sprintf(_("Incidents from %s"),date("l F j, Y",strtotime($date))).'</h1>';
51
+print '<h1>'.sprintf(_("Incidents from %s"), date("l F j, Y", strtotime($date))).'</h1>';
52 52
 print '</div>';
53 53
 
54 54
 print '<div class="table column">';
55
-print '<p>'.sprintf(_("The table below shows the Incidents on <strong>%s</strong>."),date("l M j, Y",strtotime($date))).'</p>';
56
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident',$date);
55
+print '<p>'.sprintf(_("The table below shows the Incidents on <strong>%s</strong>."), date("l M j, Y", strtotime($date))).'</p>';
56
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident', $date);
57 57
 //print_r($spotter_array);
58 58
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
59 59
 	include('table-output.php');
Please login to merge, or discard this patch.