Completed
Push — master ( eac4f3...3eb940 )
by Yannick
33:30
created
install/class.update_db.php 1 patch
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -95,38 +95,38 @@  discard block
 block discarded – undo
95 95
 		try {
96 96
 			//$Connection = new Connection();
97 97
 			$sth = $Connection->db->prepare($query);
98
-                        $sth->execute(array(':source' => $database_file));
99
-                } catch(PDOException $e) {
100
-                        return "error : ".$e->getMessage();
101
-                }
98
+						$sth->execute(array(':source' => $database_file));
99
+				} catch(PDOException $e) {
100
+						return "error : ".$e->getMessage();
101
+				}
102 102
 
103
-    		if ($globalDebug) echo " - Add routes to DB -";
104
-    		update_db::connect_sqlite($database_file);
103
+			if ($globalDebug) echo " - Add routes to DB -";
104
+			update_db::connect_sqlite($database_file);
105 105
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
106 106
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
107 107
 		try {
108
-                        $sth = update_db::$db_sqlite->prepare($query);
109
-                        $sth->execute();
110
-                } catch(PDOException $e) {
111
-                        return "error : ".$e->getMessage();
112
-                }
108
+						$sth = update_db::$db_sqlite->prepare($query);
109
+						$sth->execute();
110
+				} catch(PDOException $e) {
111
+						return "error : ".$e->getMessage();
112
+				}
113 113
 		//$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)';
114 114
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
115 115
 		$Connection = new Connection();
116 116
 		$sth_dest = $Connection->db->prepare($query_dest);
117 117
 		try {
118 118
 			if ($globalTransaction) $Connection->db->beginTransaction();
119
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
119
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
120 120
 				//$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);
121 121
 				$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);
122 122
 				$sth_dest->execute($query_dest_values);
123
-            		}
123
+					}
124 124
 			if ($globalTransaction) $Connection->db->commit();
125 125
 		} catch(PDOException $e) {
126 126
 			if ($globalTransaction) $Connection->db->rollBack(); 
127 127
 			return "error : ".$e->getMessage();
128 128
 		}
129
-                return '';
129
+				return '';
130 130
 	}
131 131
 	public static function retrieve_route_oneworld($database_file) {
132 132
 		global $globalDebug, $globalTransaction;
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 		try {
138 138
 			//$Connection = new Connection();
139 139
 			$sth = $Connection->db->prepare($query);
140
-                        $sth->execute(array(':source' => 'oneworld'));
141
-                } catch(PDOException $e) {
142
-                        return "error : ".$e->getMessage();
143
-                }
140
+						$sth->execute(array(':source' => 'oneworld'));
141
+				} catch(PDOException $e) {
142
+						return "error : ".$e->getMessage();
143
+				}
144 144
 
145
-    		if ($globalDebug) echo " - Add routes to DB -";
145
+			if ($globalDebug) echo " - Add routes to DB -";
146 146
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
147 147
 		$Spotter = new Spotter();
148 148
 		if ($fh = fopen($database_file,"r")) {
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			if ($globalTransaction) $Connection->db->commit();
168 168
 		}
169
-                return '';
169
+				return '';
170 170
 	}
171 171
 	
172 172
 	public static function retrieve_route_skyteam($database_file) {
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 		try {
179 179
 			//$Connection = new Connection();
180 180
 			$sth = $Connection->db->prepare($query);
181
-                        $sth->execute(array(':source' => 'skyteam'));
182
-                } catch(PDOException $e) {
183
-                        return "error : ".$e->getMessage();
184
-                }
181
+						$sth->execute(array(':source' => 'skyteam'));
182
+				} catch(PDOException $e) {
183
+						return "error : ".$e->getMessage();
184
+				}
185 185
 
186
-    		if ($globalDebug) echo " - Add routes to DB -";
186
+			if ($globalDebug) echo " - Add routes to DB -";
187 187
 
188 188
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
189 189
 		$Spotter = new Spotter();
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 				return "error : ".$e->getMessage();
210 210
 			}
211 211
 		}
212
-                return '';
212
+				return '';
213 213
 	}
214 214
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
215 215
 		global $globalTransaction;
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 		try {
219 219
 			$Connection = new Connection();
220 220
 			$sth = $Connection->db->prepare($query);
221
-                        $sth->execute(array(':source' => $database_file));
222
-                } catch(PDOException $e) {
223
-                        return "error : ".$e->getMessage();
224
-                }
221
+						$sth->execute(array(':source' => $database_file));
222
+				} catch(PDOException $e) {
223
+						return "error : ".$e->getMessage();
224
+				}
225 225
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
226 226
 		try {
227 227
 			$Connection = new Connection();
228 228
 			$sth = $Connection->db->prepare($query);
229
-                        $sth->execute(array(':source' => $database_file));
230
-                } catch(PDOException $e) {
231
-                        return "error : ".$e->getMessage();
232
-                }
229
+						$sth->execute(array(':source' => $database_file));
230
+				} catch(PDOException $e) {
231
+						return "error : ".$e->getMessage();
232
+				}
233 233
 
234
-    		update_db::connect_sqlite($database_file);
234
+			update_db::connect_sqlite($database_file);
235 235
 		$query = 'select * from Aircraft';
236 236
 		try {
237
-                        $sth = update_db::$db_sqlite->prepare($query);
238
-                        $sth->execute();
239
-                } catch(PDOException $e) {
240
-                        return "error : ".$e->getMessage();
241
-                }
237
+						$sth = update_db::$db_sqlite->prepare($query);
238
+						$sth->execute();
239
+				} catch(PDOException $e) {
240
+						return "error : ".$e->getMessage();
241
+				}
242 242
 		//$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)';
243 243
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
244 244
 		
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
250 250
 		try {
251 251
 			if ($globalTransaction) $Connection->db->beginTransaction();
252
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
252
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
253 253
 			//$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']);
254 254
 				if ($values['UserString4'] == 'M') $type = 'military';
255 255
 				else $type = null;
256 256
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
257 257
 				$sth_dest->execute($query_dest_values);
258 258
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
259
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
260
-				    $sth_dest_owner->execute($query_dest_owner_values);
259
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
260
+					$sth_dest_owner->execute($query_dest_owner_values);
261 261
 				}
262
-            		}
262
+					}
263 263
 			if ($globalTransaction) $Connection->db->commit();
264 264
 		} catch(PDOException $e) {
265 265
 			return "error : ".$e->getMessage();
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 		try {
271 271
 			$Connection = new Connection();
272 272
 			$sth = $Connection->db->prepare($query);
273
-                        $sth->execute(array(':source' => $database_file));
274
-                } catch(PDOException $e) {
275
-                        return "error : ".$e->getMessage();
276
-                }
273
+						$sth->execute(array(':source' => $database_file));
274
+				} catch(PDOException $e) {
275
+						return "error : ".$e->getMessage();
276
+				}
277 277
 		return '';
278 278
 	}
279 279
 
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 		try {
286 286
 			$Connection = new Connection();
287 287
 			$sth = $Connection->db->prepare($query);
288
-                        $sth->execute(array(':source' => $database_file));
289
-                } catch(PDOException $e) {
290
-                        return "error : ".$e->getMessage();
291
-                }
288
+						$sth->execute(array(':source' => $database_file));
289
+				} catch(PDOException $e) {
290
+						return "error : ".$e->getMessage();
291
+				}
292 292
 		
293 293
 		if ($fh = fopen($database_file,"r")) {
294 294
 			//$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)';
@@ -298,26 +298,26 @@  discard block
 block discarded – undo
298 298
 			$sth_dest = $Connection->db->prepare($query_dest);
299 299
 			try {
300 300
 				if ($globalTransaction) $Connection->db->beginTransaction();
301
-            			while (!feof($fh)) {
302
-            				$values = array();
303
-            				$line = $Common->hex2str(fgets($fh,9999));
301
+						while (!feof($fh)) {
302
+							$values = array();
303
+							$line = $Common->hex2str(fgets($fh,9999));
304 304
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
305
-            				$values['ModeS'] = substr($line,0,6);
306
-            				$values['Registration'] = trim(substr($line,69,6));
307
-            				$aircraft_name = trim(substr($line,48,6));
308
-            				// Check if we can find ICAO, else set it to GLID
309
-            				$aircraft_name_split = explode(' ',$aircraft_name);
310
-            				$search_more = '';
311
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
312
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
313
-            				$sth_search = $Connection->db->prepare($query_search);
305
+							$values['ModeS'] = substr($line,0,6);
306
+							$values['Registration'] = trim(substr($line,69,6));
307
+							$aircraft_name = trim(substr($line,48,6));
308
+							// Check if we can find ICAO, else set it to GLID
309
+							$aircraft_name_split = explode(' ',$aircraft_name);
310
+							$search_more = '';
311
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
312
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
313
+							$sth_search = $Connection->db->prepare($query_search);
314 314
 					try {
315
-                                    		$sth_search->execute();
316
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
317
-	            				//if (count($result) > 0) {
318
-	            				if (isset($result['icao']) && $result['icao'] != '') {
319
-	            				    $values['ICAOTypeCode'] = $result['icao'];
320
-	            				} 
315
+											$sth_search->execute();
316
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
317
+								//if (count($result) > 0) {
318
+								if (isset($result['icao']) && $result['icao'] != '') {
319
+									$values['ICAOTypeCode'] = $result['icao'];
320
+								} 
321 321
 					} catch(PDOException $e) {
322 322
 						return "error : ".$e->getMessage();
323 323
 					}
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 		try {
341 341
 			$Connection = new Connection();
342 342
 			$sth = $Connection->db->prepare($query);
343
-                        $sth->execute(array(':source' => $database_file));
344
-                } catch(PDOException $e) {
345
-                        return "error : ".$e->getMessage();
346
-                }
343
+						$sth->execute(array(':source' => $database_file));
344
+				} catch(PDOException $e) {
345
+						return "error : ".$e->getMessage();
346
+				}
347 347
 		return '';
348 348
 	}
349 349
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 		try {
355 355
 			$Connection = new Connection();
356 356
 			$sth = $Connection->db->prepare($query);
357
-                        $sth->execute(array(':source' => $database_file));
358
-                } catch(PDOException $e) {
359
-                        return "error : ".$e->getMessage();
360
-                }
357
+						$sth->execute(array(':source' => $database_file));
358
+				} catch(PDOException $e) {
359
+						return "error : ".$e->getMessage();
360
+				}
361 361
 		
362 362
 		if ($fh = fopen($database_file,"r")) {
363 363
 			//$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)';
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
 			try {
369 369
 				if ($globalTransaction) $Connection->db->beginTransaction();
370 370
 				$tmp = fgetcsv($fh,9999,',',"'");
371
-            			while (!feof($fh)) {
372
-            				$line = fgetcsv($fh,9999,',',"'");
371
+						while (!feof($fh)) {
372
+							$line = fgetcsv($fh,9999,',',"'");
373 373
             				
374 374
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
375 375
 					//print_r($line);
376
-            				$values['ModeS'] = $line[1];
377
-            				$values['Registration'] = $line[3];
378
-            				$values['ICAOTypeCode'] = '';
379
-            				$aircraft_name = $line[2];
380
-            				// Check if we can find ICAO, else set it to GLID
381
-            				$aircraft_name_split = explode(' ',$aircraft_name);
382
-            				$search_more = '';
383
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
384
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
385
-            				$sth_search = $Connection->db->prepare($query_search);
376
+							$values['ModeS'] = $line[1];
377
+							$values['Registration'] = $line[3];
378
+							$values['ICAOTypeCode'] = '';
379
+							$aircraft_name = $line[2];
380
+							// Check if we can find ICAO, else set it to GLID
381
+							$aircraft_name_split = explode(' ',$aircraft_name);
382
+							$search_more = '';
383
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
384
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
385
+							$sth_search = $Connection->db->prepare($query_search);
386 386
 					try {
387
-                                    		$sth_search->execute();
388
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
389
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
387
+											$sth_search->execute();
388
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
389
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
390 390
 					} catch(PDOException $e) {
391 391
 						return "error : ".$e->getMessage();
392 392
 					}
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 		try {
410 410
 			$Connection = new Connection();
411 411
 			$sth = $Connection->db->prepare($query);
412
-                        $sth->execute(array(':source' => $database_file));
413
-                } catch(PDOException $e) {
414
-                        return "error : ".$e->getMessage();
415
-                }
412
+						$sth->execute(array(':source' => $database_file));
413
+				} catch(PDOException $e) {
414
+						return "error : ".$e->getMessage();
415
+				}
416 416
 		return '';
417 417
 	}
418 418
 
@@ -423,16 +423,16 @@  discard block
 block discarded – undo
423 423
 		try {
424 424
 			$Connection = new Connection();
425 425
 			$sth = $Connection->db->prepare($query);
426
-                        $sth->execute(array(':source' => $database_file));
427
-                } catch(PDOException $e) {
428
-                        return "error : ".$e->getMessage();
429
-                }
426
+						$sth->execute(array(':source' => $database_file));
427
+				} catch(PDOException $e) {
428
+						return "error : ".$e->getMessage();
429
+				}
430 430
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
431 431
 		$Spotter = new Spotter();
432 432
 		if ($fh = fopen($database_file,"r")) {
433 433
 			//$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)';
434 434
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
435
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
435
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
436 436
 		        
437 437
 			$Connection = new Connection();
438 438
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -440,126 +440,126 @@  discard block
 block discarded – undo
440 440
 			try {
441 441
 				if ($globalTransaction) $Connection->db->beginTransaction();
442 442
 				$tmp = fgetcsv($fh,9999,',','"');
443
-            			while (!feof($fh)) {
444
-            				$line = fgetcsv($fh,9999,',','"');
445
-            				$values = array();
446
-            				//print_r($line);
447
-            				if ($country == 'F') {
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = $line[4];
450
-            				    $values['owner'] = $line[5];
451
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
452
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
453
-					    $values['cancel'] = $line[7];
443
+						while (!feof($fh)) {
444
+							$line = fgetcsv($fh,9999,',','"');
445
+							$values = array();
446
+							//print_r($line);
447
+							if ($country == 'F') {
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = $line[4];
450
+								$values['owner'] = $line[5];
451
+								if ($line[6] == '') $values['date_first_reg'] = null;
452
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
453
+						$values['cancel'] = $line[7];
454 454
 					} elseif ($country == 'EI') {
455
-					    // TODO : add modeS & reg to aircraft_modes
456
-            				    $values['registration'] = $line[0];
457
-            				    $values['base'] = $line[3];
458
-            				    $values['owner'] = $line[2];
459
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
461
-					    $values['cancel'] = '';
462
-					    $values['modes'] = $line[7];
463
-					    $values['icao'] = $line[8];
455
+						// TODO : add modeS & reg to aircraft_modes
456
+								$values['registration'] = $line[0];
457
+								$values['base'] = $line[3];
458
+								$values['owner'] = $line[2];
459
+								if ($line[1] == '') $values['date_first_reg'] = null;
460
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
461
+						$values['cancel'] = '';
462
+						$values['modes'] = $line[7];
463
+						$values['icao'] = $line[8];
464 464
 					    
465 465
 					} elseif ($country == 'HB') {
466
-					    // TODO : add modeS & reg to aircraft_modes
467
-            				    $values['registration'] = $line[0];
468
-            				    $values['base'] = null;
469
-            				    $values['owner'] = $line[5];
470
-            				    $values['date_first_reg'] = null;
471
-					    $values['cancel'] = '';
472
-					    $values['modes'] = $line[4];
473
-					    $values['icao'] = $line[7];
466
+						// TODO : add modeS & reg to aircraft_modes
467
+								$values['registration'] = $line[0];
468
+								$values['base'] = null;
469
+								$values['owner'] = $line[5];
470
+								$values['date_first_reg'] = null;
471
+						$values['cancel'] = '';
472
+						$values['modes'] = $line[4];
473
+						$values['icao'] = $line[7];
474 474
 					} elseif ($country == 'OK') {
475
-					    // TODO : add modeS & reg to aircraft_modes
476
-            				    $values['registration'] = $line[3];
477
-            				    $values['base'] = null;
478
-            				    $values['owner'] = $line[5];
479
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
480
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
481
-					    $values['cancel'] = '';
475
+						// TODO : add modeS & reg to aircraft_modes
476
+								$values['registration'] = $line[3];
477
+								$values['base'] = null;
478
+								$values['owner'] = $line[5];
479
+								if ($line[18] == '') $values['date_first_reg'] = null;
480
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
481
+						$values['cancel'] = '';
482 482
 					} elseif ($country == 'VH') {
483
-					    // TODO : add modeS & reg to aircraft_modes
484
-            				    $values['registration'] = $line[0];
485
-            				    $values['base'] = null;
486
-            				    $values['owner'] = $line[12];
487
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
489
-
490
-					    $values['cancel'] = $line[39];
483
+						// TODO : add modeS & reg to aircraft_modes
484
+								$values['registration'] = $line[0];
485
+								$values['base'] = null;
486
+								$values['owner'] = $line[12];
487
+								if ($line[28] == '') $values['date_first_reg'] = null;
488
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
489
+
490
+						$values['cancel'] = $line[39];
491 491
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    $values['date_first_reg'] = null;
496
-					    $values['cancel'] = '';
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								$values['date_first_reg'] = null;
496
+						$values['cancel'] = '';
497 497
 					} elseif ($country == 'CC') {
498
-            				    $values['registration'] = $line[0];
499
-            				    $values['base'] = null;
500
-            				    $values['owner'] = $line[6];
501
-            				    $values['date_first_reg'] = null;
502
-					    $values['cancel'] = '';
498
+								$values['registration'] = $line[0];
499
+								$values['base'] = null;
500
+								$values['owner'] = $line[6];
501
+								$values['date_first_reg'] = null;
502
+						$values['cancel'] = '';
503 503
 					} elseif ($country == 'HJ') {
504
-            				    $values['registration'] = $line[0];
505
-            				    $values['base'] = null;
506
-            				    $values['owner'] = $line[8];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
-					    $values['cancel'] = '';
504
+								$values['registration'] = $line[0];
505
+								$values['base'] = null;
506
+								$values['owner'] = $line[8];
507
+								if ($line[7] == '') $values['date_first_reg'] = null;
508
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
+						$values['cancel'] = '';
510 510
 					} elseif ($country == 'PP') {
511
-            				    $values['registration'] = $line[0];
512
-            				    $values['base'] = null;
513
-            				    $values['owner'] = $line[4];
514
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
515
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
516
-					    $values['cancel'] = $line[7];
511
+								$values['registration'] = $line[0];
512
+								$values['base'] = null;
513
+								$values['owner'] = $line[4];
514
+								if ($line[6] == '') $values['date_first_reg'] = null;
515
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
516
+						$values['cancel'] = $line[7];
517 517
 					} elseif ($country == 'E7') {
518
-            				    $values['registration'] = $line[0];
519
-            				    $values['base'] = null;
520
-            				    $values['owner'] = $line[4];
521
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
522
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = '';
518
+								$values['registration'] = $line[0];
519
+								$values['base'] = null;
520
+								$values['owner'] = $line[4];
521
+								if ($line[5] == '') $values['date_first_reg'] = null;
522
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
+						$values['cancel'] = '';
524 524
 					} elseif ($country == '8Q') {
525
-            				    $values['registration'] = $line[0];
526
-            				    $values['base'] = null;
527
-            				    $values['owner'] = $line[3];
528
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
529
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
530
-					    $values['cancel'] = '';
525
+								$values['registration'] = $line[0];
526
+								$values['base'] = null;
527
+								$values['owner'] = $line[3];
528
+								if ($line[7] == '') $values['date_first_reg'] = null;
529
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
530
+						$values['cancel'] = '';
531 531
 					} elseif ($country == 'ZK') {
532
-            				    $values['registration'] = $line[0];
533
-            				    $values['base'] = null;
534
-            				    $values['owner'] = $line[3];
535
-            				    $values['date_first_reg'] = null;
536
-					    $values['cancel'] = '';
537
-					    $values['modes'] = $line[5];
538
-					    $values['icao'] = $line[9];
532
+								$values['registration'] = $line[0];
533
+								$values['base'] = null;
534
+								$values['owner'] = $line[3];
535
+								$values['date_first_reg'] = null;
536
+						$values['cancel'] = '';
537
+						$values['modes'] = $line[5];
538
+						$values['icao'] = $line[9];
539 539
 					} elseif ($country == 'M') {
540
-            				    $values['registration'] = $line[0];
541
-            				    $values['base'] = null;
542
-            				    $values['owner'] = $line[6];
543
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
544
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
545
-					    $values['modes'] = $line[4];
546
-					    $values['icao'] = $line[10];
540
+								$values['registration'] = $line[0];
541
+								$values['base'] = null;
542
+								$values['owner'] = $line[6];
543
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
544
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
545
+						$values['modes'] = $line[4];
546
+						$values['icao'] = $line[10];
547 547
 					} elseif ($country == 'OY') {
548
-            				    $values['registration'] = $line[0];
549
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
550
-					    $values['modes'] = $line[5];
551
-					    $values['icao'] = $line[6];
548
+								$values['registration'] = $line[0];
549
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
550
+						$values['modes'] = $line[5];
551
+						$values['icao'] = $line[6];
552 552
 					} elseif ($country == 'PH') {
553
-            				    $values['registration'] = $line[0];
554
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
555
-					    $values['modes'] = $line[4];
556
-					    $values['icao'] = $line[5];
553
+								$values['registration'] = $line[0];
554
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
555
+						$values['modes'] = $line[4];
556
+						$values['icao'] = $line[5];
557 557
 					} elseif ($country == 'OM' || $country == 'TF') {
558
-            				    $values['registration'] = $line[0];
559
-            				    $values['base'] = null;
560
-            				    $values['owner'] = $line[3];
561
-            				    $values['date_first_reg'] = null;
562
-					    $values['cancel'] = '';
558
+								$values['registration'] = $line[0];
559
+								$values['base'] = null;
560
+								$values['owner'] = $line[3];
561
+								$values['date_first_reg'] = null;
562
+						$values['cancel'] = '';
563 563
 					}
564 564
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
565 565
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
                         return "error : ".$e->getMessage();
693 693
                 }
694 694
                 */
695
-                /*
695
+				/*
696 696
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
697 697
 		try {
698 698
 			$Connection = new Connection();
@@ -937,10 +937,10 @@  discard block
 block discarded – undo
937 937
 		try {
938 938
 			$Connection = new Connection();
939 939
 			$sth = $Connection->db->prepare($query);
940
-                        $sth->execute(array(':source' => 'translation.csv'));
941
-                } catch(PDOException $e) {
942
-                        return "error : ".$e->getMessage();
943
-                }
940
+						$sth->execute(array(':source' => 'translation.csv'));
941
+				} catch(PDOException $e) {
942
+						return "error : ".$e->getMessage();
943
+				}
944 944
 
945 945
 		
946 946
 		//update_db::unzip($out_file);
@@ -959,21 +959,21 @@  discard block
 block discarded – undo
959 959
 					$data = $row;
960 960
 					$operator = $data[2];
961 961
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
962
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
963
-                                                //echo substr($operator, 0, 2)."\n";;
964
-                                                if (count($airline_array) > 0) {
962
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
963
+												//echo substr($operator, 0, 2)."\n";;
964
+												if (count($airline_array) > 0) {
965 965
 							//print_r($airline_array);
966 966
 							$operator = $airline_array[0]['icao'].substr($operator,2);
967
-                                                }
968
-                                        }
967
+												}
968
+										}
969 969
 					
970 970
 					$operator_correct = $data[3];
971 971
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
972
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
973
-                                                if (count($airline_array) > 0) {
974
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
975
-                                            	}
976
-                                        }
972
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
973
+												if (count($airline_array) > 0) {
974
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
975
+												}
976
+										}
977 977
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
978 978
 					try {
979 979
 						$sth = $Connection->db->prepare($query);
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 			//$Connection->db->commit();
988 988
 		}
989 989
 		return '';
990
-        }
990
+		}
991 991
 	
992 992
 	public static function translation_fam() {
993 993
 		global $tmp_dir, $globalTransaction;
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 			//$Connection->db->commit();
1026 1026
 		}
1027 1027
 		return '';
1028
-        }
1028
+		}
1029 1029
 
1030 1030
 	public static function diagrams_fam() {
1031 1031
 		global $tmp_dir, $globalTransaction;
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 			$Connection->db->commit();
1052 1052
 		}
1053 1053
 		return '';
1054
-        }
1054
+		}
1055 1055
 
1056 1056
 	/*
1057 1057
 	* This function use FAA public data.
@@ -1063,19 +1063,19 @@  discard block
 block discarded – undo
1063 1063
 		try {
1064 1064
 			$Connection = new Connection();
1065 1065
 			$sth = $Connection->db->prepare($query);
1066
-                        $sth->execute(array(':source' => 'website_faa'));
1067
-                } catch(PDOException $e) {
1068
-                        return "error : ".$e->getMessage();
1069
-                }
1066
+						$sth->execute(array(':source' => 'website_faa'));
1067
+				} catch(PDOException $e) {
1068
+						return "error : ".$e->getMessage();
1069
+				}
1070 1070
 
1071 1071
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1072 1072
 		try {
1073 1073
 			$Connection = new Connection();
1074 1074
 			$sth = $Connection->db->prepare($query);
1075
-                        $sth->execute(array(':source' => 'website_faa'));
1076
-                } catch(PDOException $e) {
1077
-                        return "error : ".$e->getMessage();
1078
-                }
1075
+						$sth->execute(array(':source' => 'website_faa'));
1076
+				} catch(PDOException $e) {
1077
+						return "error : ".$e->getMessage();
1078
+				}
1079 1079
 
1080 1080
 		$delimiter = ",";
1081 1081
 		$mfr = array();
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 		}
1244 1244
 		*/
1245 1245
 		return '';
1246
-        }
1246
+		}
1247 1247
         
1248 1248
 	public static function owner_fam() {
1249 1249
 		global $tmp_dir, $globalTransaction;
@@ -1251,10 +1251,10 @@  discard block
 block discarded – undo
1251 1251
 		try {
1252 1252
 			$Connection = new Connection();
1253 1253
 			$sth = $Connection->db->prepare($query);
1254
-                        $sth->execute(array(':source' => 'website_fam'));
1255
-                } catch(PDOException $e) {
1256
-                        return "error : ".$e->getMessage();
1257
-                }
1254
+						$sth->execute(array(':source' => 'website_fam'));
1255
+				} catch(PDOException $e) {
1256
+						return "error : ".$e->getMessage();
1257
+				}
1258 1258
 
1259 1259
 		$delimiter = "\t";
1260 1260
 		$Connection = new Connection();
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 			if ($globalTransaction) $Connection->db->commit();
1281 1281
 		}
1282 1282
 		return '';
1283
-        }
1283
+		}
1284 1284
 
1285 1285
 	public static function routes_fam() {
1286 1286
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 			if ($globalTransaction) $Connection->db->commit();
1361 1361
 		}
1362 1362
 		return '';
1363
-        }
1363
+		}
1364 1364
 
1365 1365
 	public static function marine_identity_fam() {
1366 1366
 		global $tmp_dir, $globalTransaction;
@@ -1368,10 +1368,10 @@  discard block
 block discarded – undo
1368 1368
 		try {
1369 1369
 			$Connection = new Connection();
1370 1370
 			$sth = $Connection->db->prepare($query);
1371
-                        $sth->execute();
1372
-                } catch(PDOException $e) {
1373
-                        return "error : ".$e->getMessage();
1374
-                }
1371
+						$sth->execute();
1372
+				} catch(PDOException $e) {
1373
+						return "error : ".$e->getMessage();
1374
+				}
1375 1375
 
1376 1376
 		
1377 1377
 		//update_db::unzip($out_file);
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 			if ($globalTransaction) $Connection->db->commit();
1402 1402
 		}
1403 1403
 		return '';
1404
-        }
1404
+		}
1405 1405
 
1406 1406
 	public static function satellite_fam() {
1407 1407
 		global $tmp_dir, $globalTransaction;
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 			if ($globalTransaction) $Connection->db->commit();
1473 1473
 		}
1474 1474
 		return '';
1475
-        }
1475
+		}
1476 1476
 
1477 1477
 	public static function tle($filename,$tletype) {
1478 1478
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1483,10 +1483,10 @@  discard block
 block discarded – undo
1483 1483
 		try {
1484 1484
 			$Connection = new Connection();
1485 1485
 			$sth = $Connection->db->prepare($query);
1486
-                        $sth->execute(array(':source' => $filename));
1487
-                } catch(PDOException $e) {
1488
-                        return "error : ".$e->getMessage();
1489
-                }
1486
+						$sth->execute(array(':source' => $filename));
1487
+				} catch(PDOException $e) {
1488
+						return "error : ".$e->getMessage();
1489
+				}
1490 1490
 		
1491 1491
 		$Connection = new Connection();
1492 1492
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1521,7 +1521,7 @@  discard block
 block discarded – undo
1521 1521
 			//$Connection->db->commit();
1522 1522
 		}
1523 1523
 		return '';
1524
-        }
1524
+		}
1525 1525
 
1526 1526
 	public static function satellite_ucsdb($filename) {
1527 1527
 		global $tmp_dir, $globalTransaction;
@@ -1781,11 +1781,11 @@  discard block
 block discarded – undo
1781 1781
 							try {
1782 1782
 								$sth = $Connection->db->prepare($query);
1783 1783
 								$sth->execute(array(
1784
-								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1785
-								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1786
-								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1787
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1788
-								    )
1784
+									':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1785
+									':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1786
+									':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1787
+									':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1788
+									)
1789 1789
 								);
1790 1790
 							} catch(PDOException $e) {
1791 1791
 								return "error : ".$e->getMessage();
@@ -1809,13 +1809,13 @@  discard block
 block discarded – undo
1809 1809
 			//$Connection->db->commit();
1810 1810
 		}
1811 1811
 		return '';
1812
-        }
1812
+		}
1813 1813
 
1814 1814
 	/**
1815
-        * Convert a HTML table to an array
1816
-        * @param String $data HTML page
1817
-        * @return Array array of the tables in HTML page
1818
-        */
1815
+	 * Convert a HTML table to an array
1816
+	 * @param String $data HTML page
1817
+	 * @return Array array of the tables in HTML page
1818
+	 */
1819 1819
 /*
1820 1820
         private static function table2array($data) {
1821 1821
                 $html = str_get_html($data);
@@ -1845,11 +1845,11 @@  discard block
 block discarded – undo
1845 1845
                 return(array_filter($tabledata));
1846 1846
         }
1847 1847
 */
1848
-       /**
1849
-        * Get data from form result
1850
-        * @param String $url form URL
1851
-        * @return String the result
1852
-        */
1848
+	   /**
1849
+	    * Get data from form result
1850
+	    * @param String $url form URL
1851
+	    * @return String the result
1852
+	    */
1853 1853
 /*
1854 1854
         private static function getData($url) {
1855 1855
                 $ch = curl_init();
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 			if ($globalTransaction) $Connection->db->commit();
2009 2009
 		}
2010 2010
 		return '';
2011
-        }
2011
+		}
2012 2012
 	
2013 2013
 	public static function update_airspace() {
2014 2014
 		global $tmp_dir, $globalDBdriver;
@@ -2018,11 +2018,11 @@  discard block
 block discarded – undo
2018 2018
 			$query = 'DROP TABLE airspace';
2019 2019
 			try {
2020 2020
 				$sth = $Connection->db->prepare($query);
2021
-                    		$sth->execute();
2022
-	                } catch(PDOException $e) {
2021
+							$sth->execute();
2022
+					} catch(PDOException $e) {
2023 2023
 				return "error : ".$e->getMessage();
2024
-	                }
2025
-	        }
2024
+					}
2025
+			}
2026 2026
 
2027 2027
 
2028 2028
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -2087,10 +2087,10 @@  discard block
 block discarded – undo
2087 2087
 			$query = 'DROP TABLE countries';
2088 2088
 			try {
2089 2089
 				$sth = $Connection->db->prepare($query);
2090
-            	        	$sth->execute();
2091
-	                } catch(PDOException $e) {
2092
-    	                	echo "error : ".$e->getMessage();
2093
-	                }
2090
+							$sth->execute();
2091
+					} catch(PDOException $e) {
2092
+							echo "error : ".$e->getMessage();
2093
+					}
2094 2094
 		}
2095 2095
 		if ($globalDBdriver == 'mysql') {
2096 2096
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
 						$error = update_db::airlines_fam();
2550 2550
 						update_db::insert_airlines_version($airlines_md5);
2551 2551
 					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2552
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2552
+				} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2553 2553
 			} elseif ($globalDebug) echo "No update.";
2554 2554
 		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2555 2555
 		if ($error != '') {
@@ -3137,10 +3137,10 @@  discard block
 block discarded – undo
3137 3137
 		try {
3138 3138
 			$Connection = new Connection();
3139 3139
 			$sth = $Connection->db->prepare($query);
3140
-                        $sth->execute();
3141
-                } catch(PDOException $e) {
3142
-                        return "error : ".$e->getMessage();
3143
-                }
3140
+						$sth->execute();
3141
+				} catch(PDOException $e) {
3142
+						return "error : ".$e->getMessage();
3143
+				}
3144 3144
 
3145 3145
 		$error = '';
3146 3146
 		if ($globalDebug) echo "Notam : Download...";
@@ -3196,8 +3196,8 @@  discard block
 block discarded – undo
3196 3196
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3197 3197
 					$data['permanent'] = 0;
3198 3198
 				} else {
3199
-				    $data['date_end'] = NULL;
3200
-				    $data['permanent'] = 1;
3199
+					$data['date_end'] = NULL;
3200
+					$data['permanent'] = 1;
3201 3201
 				}
3202 3202
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3203 3203
 				$NOTAM = new NOTAM();
@@ -3271,13 +3271,13 @@  discard block
 block discarded – undo
3271 3271
 		try {
3272 3272
 			$Connection = new Connection();
3273 3273
 			$sth = $Connection->db->prepare($query);
3274
-                        $sth->execute();
3275
-                } catch(PDOException $e) {
3276
-                        return "error : ".$e->getMessage();
3277
-                }
3278
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3279
-                if ($row['nb'] > 0) return false;
3280
-                else return true;
3274
+						$sth->execute();
3275
+				} catch(PDOException $e) {
3276
+						return "error : ".$e->getMessage();
3277
+				}
3278
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3279
+				if ($row['nb'] > 0) return false;
3280
+				else return true;
3281 3281
 	}
3282 3282
 
3283 3283
 	public static function insert_last_update() {
@@ -3286,10 +3286,10 @@  discard block
 block discarded – undo
3286 3286
 		try {
3287 3287
 			$Connection = new Connection();
3288 3288
 			$sth = $Connection->db->prepare($query);
3289
-                        $sth->execute();
3290
-                } catch(PDOException $e) {
3291
-                        return "error : ".$e->getMessage();
3292
-                }
3289
+						$sth->execute();
3290
+				} catch(PDOException $e) {
3291
+						return "error : ".$e->getMessage();
3292
+				}
3293 3293
 	}
3294 3294
 
3295 3295
 	public static function check_airspace_version($version) {
@@ -3297,13 +3297,13 @@  discard block
 block discarded – undo
3297 3297
 		try {
3298 3298
 			$Connection = new Connection();
3299 3299
 			$sth = $Connection->db->prepare($query);
3300
-                        $sth->execute(array(':version' => $version));
3301
-                } catch(PDOException $e) {
3302
-                        return "error : ".$e->getMessage();
3303
-                }
3304
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3305
-                if ($row['nb'] > 0) return true;
3306
-                else return false;
3300
+						$sth->execute(array(':version' => $version));
3301
+				} catch(PDOException $e) {
3302
+						return "error : ".$e->getMessage();
3303
+				}
3304
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3305
+				if ($row['nb'] > 0) return true;
3306
+				else return false;
3307 3307
 	}
3308 3308
 
3309 3309
 	public static function check_geoid_version($version) {
@@ -3311,13 +3311,13 @@  discard block
 block discarded – undo
3311 3311
 		try {
3312 3312
 			$Connection = new Connection();
3313 3313
 			$sth = $Connection->db->prepare($query);
3314
-                        $sth->execute(array(':version' => $version));
3315
-                } catch(PDOException $e) {
3316
-                        return "error : ".$e->getMessage();
3317
-                }
3318
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3319
-                if ($row['nb'] > 0) return true;
3320
-                else return false;
3314
+						$sth->execute(array(':version' => $version));
3315
+				} catch(PDOException $e) {
3316
+						return "error : ".$e->getMessage();
3317
+				}
3318
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3319
+				if ($row['nb'] > 0) return true;
3320
+				else return false;
3321 3321
 	}
3322 3322
 
3323 3323
 	public static function check_marine_identity_version($version) {
@@ -3431,10 +3431,10 @@  discard block
 block discarded – undo
3431 3431
 		try {
3432 3432
 			$Connection = new Connection();
3433 3433
 			$sth = $Connection->db->prepare($query);
3434
-                        $sth->execute(array(':version' => $version));
3435
-                } catch(PDOException $e) {
3436
-                        return "error : ".$e->getMessage();
3437
-                }
3434
+						$sth->execute(array(':version' => $version));
3435
+				} catch(PDOException $e) {
3436
+						return "error : ".$e->getMessage();
3437
+				}
3438 3438
 	}
3439 3439
 
3440 3440
 	public static function insert_marine_identity_version($version) {
@@ -3482,13 +3482,13 @@  discard block
 block discarded – undo
3482 3482
 		try {
3483 3483
 			$Connection = new Connection();
3484 3484
 			$sth = $Connection->db->prepare($query);
3485
-                        $sth->execute();
3486
-                } catch(PDOException $e) {
3487
-                        return "error : ".$e->getMessage();
3488
-                }
3489
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3490
-                if ($row['nb'] > 0) return false;
3491
-                else return true;
3485
+						$sth->execute();
3486
+				} catch(PDOException $e) {
3487
+						return "error : ".$e->getMessage();
3488
+				}
3489
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3490
+				if ($row['nb'] > 0) return false;
3491
+				else return true;
3492 3492
 	}
3493 3493
 
3494 3494
 	public static function insert_last_notam_update() {
@@ -3497,10 +3497,10 @@  discard block
 block discarded – undo
3497 3497
 		try {
3498 3498
 			$Connection = new Connection();
3499 3499
 			$sth = $Connection->db->prepare($query);
3500
-                        $sth->execute();
3501
-                } catch(PDOException $e) {
3502
-                        return "error : ".$e->getMessage();
3503
-                }
3500
+						$sth->execute();
3501
+				} catch(PDOException $e) {
3502
+						return "error : ".$e->getMessage();
3503
+				}
3504 3504
 	}
3505 3505
 
3506 3506
 	public static function check_last_airspace_update() {
@@ -3513,13 +3513,13 @@  discard block
 block discarded – undo
3513 3513
 		try {
3514 3514
 			$Connection = new Connection();
3515 3515
 			$sth = $Connection->db->prepare($query);
3516
-                        $sth->execute();
3517
-                } catch(PDOException $e) {
3518
-                        return "error : ".$e->getMessage();
3519
-                }
3520
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3521
-                if ($row['nb'] > 0) return false;
3522
-                else return true;
3516
+						$sth->execute();
3517
+				} catch(PDOException $e) {
3518
+						return "error : ".$e->getMessage();
3519
+				}
3520
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3521
+				if ($row['nb'] > 0) return false;
3522
+				else return true;
3523 3523
 	}
3524 3524
 
3525 3525
 	public static function insert_last_airspace_update() {
@@ -3528,10 +3528,10 @@  discard block
 block discarded – undo
3528 3528
 		try {
3529 3529
 			$Connection = new Connection();
3530 3530
 			$sth = $Connection->db->prepare($query);
3531
-                        $sth->execute();
3532
-                } catch(PDOException $e) {
3533
-                        return "error : ".$e->getMessage();
3534
-                }
3531
+						$sth->execute();
3532
+				} catch(PDOException $e) {
3533
+						return "error : ".$e->getMessage();
3534
+				}
3535 3535
 	}
3536 3536
 
3537 3537
 	public static function check_last_geoid_update() {
@@ -3544,13 +3544,13 @@  discard block
 block discarded – undo
3544 3544
 		try {
3545 3545
 			$Connection = new Connection();
3546 3546
 			$sth = $Connection->db->prepare($query);
3547
-                        $sth->execute();
3548
-                } catch(PDOException $e) {
3549
-                        return "error : ".$e->getMessage();
3550
-                }
3551
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3552
-                if ($row['nb'] > 0) return false;
3553
-                else return true;
3547
+						$sth->execute();
3548
+				} catch(PDOException $e) {
3549
+						return "error : ".$e->getMessage();
3550
+				}
3551
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3552
+				if ($row['nb'] > 0) return false;
3553
+				else return true;
3554 3554
 	}
3555 3555
 
3556 3556
 	public static function insert_last_geoid_update() {
@@ -3559,10 +3559,10 @@  discard block
 block discarded – undo
3559 3559
 		try {
3560 3560
 			$Connection = new Connection();
3561 3561
 			$sth = $Connection->db->prepare($query);
3562
-                        $sth->execute();
3563
-                } catch(PDOException $e) {
3564
-                        return "error : ".$e->getMessage();
3565
-                }
3562
+						$sth->execute();
3563
+				} catch(PDOException $e) {
3564
+						return "error : ".$e->getMessage();
3565
+				}
3566 3566
 	}
3567 3567
 
3568 3568
 	public static function check_last_owner_update() {
@@ -3668,13 +3668,13 @@  discard block
 block discarded – undo
3668 3668
 		try {
3669 3669
 			$Connection = new Connection();
3670 3670
 			$sth = $Connection->db->prepare($query);
3671
-                        $sth->execute();
3672
-                } catch(PDOException $e) {
3673
-                        return "error : ".$e->getMessage();
3674
-                }
3675
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3676
-                if ($row['nb'] > 0) return false;
3677
-                else return true;
3671
+						$sth->execute();
3672
+				} catch(PDOException $e) {
3673
+						return "error : ".$e->getMessage();
3674
+				}
3675
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3676
+				if ($row['nb'] > 0) return false;
3677
+				else return true;
3678 3678
 	}
3679 3679
 
3680 3680
 	public static function insert_last_schedules_update() {
@@ -3854,10 +3854,10 @@  discard block
 block discarded – undo
3854 3854
 		try {
3855 3855
 			$Connection = new Connection();
3856 3856
 			$sth = $Connection->db->prepare($query);
3857
-                        $sth->execute();
3858
-                } catch(PDOException $e) {
3859
-                        return "error : ".$e->getMessage();
3860
-                }
3857
+						$sth->execute();
3858
+				} catch(PDOException $e) {
3859
+						return "error : ".$e->getMessage();
3860
+				}
3861 3861
 	}
3862 3862
 	public static function delete_duplicateowner() {
3863 3863
 		global $globalDBdriver;
@@ -3869,10 +3869,10 @@  discard block
 block discarded – undo
3869 3869
 		try {
3870 3870
 			$Connection = new Connection();
3871 3871
 			$sth = $Connection->db->prepare($query);
3872
-                        $sth->execute();
3873
-                } catch(PDOException $e) {
3874
-                        return "error : ".$e->getMessage();
3875
-                }
3872
+						$sth->execute();
3873
+				} catch(PDOException $e) {
3874
+						return "error : ".$e->getMessage();
3875
+				}
3876 3876
 	}
3877 3877
 	
3878 3878
 	public static function update_all() {
Please login to merge, or discard this patch.