Completed
Push — master ( 14281c...6f3189 )
by Yannick
30:26
created
install/class.update_db.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 		try {
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88
-                        $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
90
-                        return "error : ".$e->getMessage();
91
-                }
88
+						$sth->execute(array(':source' => $database_file));
89
+				} catch(PDOException $e) {
90
+						return "error : ".$e->getMessage();
91
+				}
92 92
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
94
-    		update_db::connect_sqlite($database_file);
93
+			if ($globalDebug) echo " - Add routes to DB -";
94
+			update_db::connect_sqlite($database_file);
95 95
 		//$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';
96 96
 		$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";
97 97
 		try {
98
-                        $sth = update_db::$db_sqlite->prepare($query);
99
-                        $sth->execute();
100
-                } catch(PDOException $e) {
101
-                        return "error : ".$e->getMessage();
102
-                }
98
+						$sth = update_db::$db_sqlite->prepare($query);
99
+						$sth->execute();
100
+				} catch(PDOException $e) {
101
+						return "error : ".$e->getMessage();
102
+				}
103 103
 		//$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)';
104 104
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
105 105
 		$Connection = new Connection();
106 106
 		$sth_dest = $Connection->db->prepare($query_dest);
107 107
 		try {
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
109
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$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);
111 111
 				$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);
112 112
 				$sth_dest->execute($query_dest_values);
113
-            		}
113
+					}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115 115
 		} catch(PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
119
-                return '';
119
+				return '';
120 120
 	}
121 121
 	public static function retrieve_route_oneworld($database_file) {
122 122
 		global $globalDebug, $globalTransaction;
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 		try {
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130
-                        $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
132
-                        return "error : ".$e->getMessage();
133
-                }
130
+						$sth->execute(array(':source' => 'oneworld'));
131
+				} catch(PDOException $e) {
132
+						return "error : ".$e->getMessage();
133
+				}
134 134
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
135
+			if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138 138
 		if ($fh = fopen($database_file,"r")) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 			if ($globalTransaction) $Connection->db->commit();
158 158
 		}
159
-                return '';
159
+				return '';
160 160
 	}
161 161
 	
162 162
 	public static function retrieve_route_skyteam($database_file) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		try {
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171
-                        $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
173
-                        return "error : ".$e->getMessage();
174
-                }
171
+						$sth->execute(array(':source' => 'skyteam'));
172
+				} catch(PDOException $e) {
173
+						return "error : ".$e->getMessage();
174
+				}
175 175
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
176
+			if ($globalDebug) echo " - Add routes to DB -";
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
201 201
 		}
202
-                return '';
202
+				return '';
203 203
 	}
204 204
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 205
 		global $globalTransaction;
@@ -208,27 +208,27 @@  discard block
 block discarded – undo
208 208
 		try {
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211
-                        $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
213
-                        return "error : ".$e->getMessage();
214
-                }
211
+						$sth->execute(array(':source' => $database_file));
212
+				} catch(PDOException $e) {
213
+						return "error : ".$e->getMessage();
214
+				}
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
216 216
 		try {
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219
-                        $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
219
+						$sth->execute(array(':source' => $database_file));
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 
224
-    		update_db::connect_sqlite($database_file);
224
+			update_db::connect_sqlite($database_file);
225 225
 		$query = 'select * from Aircraft';
226 226
 		try {
227
-                        $sth = update_db::$db_sqlite->prepare($query);
228
-                        $sth->execute();
229
-                } catch(PDOException $e) {
230
-                        return "error : ".$e->getMessage();
231
-                }
227
+						$sth = update_db::$db_sqlite->prepare($query);
228
+						$sth->execute();
229
+				} catch(PDOException $e) {
230
+						return "error : ".$e->getMessage();
231
+				}
232 232
 		//$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 233
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
234 234
 		
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 240
 		try {
241 241
 			if ($globalTransaction) $Connection->db->beginTransaction();
242
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
242
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 243
 			//$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']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246 246
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
-				    $sth_dest_owner->execute($query_dest_owner_values);
249
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
+					$sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252
-            		}
252
+					}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254 254
 		} catch(PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 		try {
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263
-                        $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
265
-                        return "error : ".$e->getMessage();
266
-                }
263
+						$sth->execute(array(':source' => $database_file));
264
+				} catch(PDOException $e) {
265
+						return "error : ".$e->getMessage();
266
+				}
267 267
 		return '';
268 268
 	}
269 269
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 		try {
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278
-                        $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
280
-                        return "error : ".$e->getMessage();
281
-                }
278
+						$sth->execute(array(':source' => $database_file));
279
+				} catch(PDOException $e) {
280
+						return "error : ".$e->getMessage();
281
+				}
282 282
 		
283 283
 		if ($fh = fopen($database_file,"r")) {
284 284
 			//$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)';
@@ -288,26 +288,26 @@  discard block
 block discarded – undo
288 288
 			$sth_dest = $Connection->db->prepare($query_dest);
289 289
 			try {
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291
-            			while (!feof($fh)) {
292
-            				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
291
+						while (!feof($fh)) {
292
+							$values = array();
293
+							$line = $Common->hex2str(fgets($fh,9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
298
-            				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
300
-            				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
-            				$sth_search = $Connection->db->prepare($query_search);
295
+							$values['ModeS'] = substr($line,0,6);
296
+							$values['Registration'] = trim(substr($line,69,6));
297
+							$aircraft_name = trim(substr($line,48,6));
298
+							// Check if we can find ICAO, else set it to GLID
299
+							$aircraft_name_split = explode(' ',$aircraft_name);
300
+							$search_more = '';
301
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
+							$sth_search = $Connection->db->prepare($query_search);
304 304
 					try {
305
-                                    		$sth_search->execute();
306
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
-	            				//if (count($result) > 0) {
308
-	            				if (isset($result['icao']) && $result['icao'] != '') {
309
-	            				    $values['ICAOTypeCode'] = $result['icao'];
310
-	            				} 
305
+											$sth_search->execute();
306
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
+								//if (count($result) > 0) {
308
+								if (isset($result['icao']) && $result['icao'] != '') {
309
+									$values['ICAOTypeCode'] = $result['icao'];
310
+								} 
311 311
 					} catch(PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		try {
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333
-                        $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
335
-                        return "error : ".$e->getMessage();
336
-                }
333
+						$sth->execute(array(':source' => $database_file));
334
+				} catch(PDOException $e) {
335
+						return "error : ".$e->getMessage();
336
+				}
337 337
 		return '';
338 338
 	}
339 339
 
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 		try {
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347
-                        $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
349
-                        return "error : ".$e->getMessage();
350
-                }
347
+						$sth->execute(array(':source' => $database_file));
348
+				} catch(PDOException $e) {
349
+						return "error : ".$e->getMessage();
350
+				}
351 351
 		
352 352
 		if ($fh = fopen($database_file,"r")) {
353 353
 			//$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)';
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360 360
 				$tmp = fgetcsv($fh,9999,',',"'");
361
-            			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
361
+						while (!feof($fh)) {
362
+							$line = fgetcsv($fh,9999,',',"'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
366
-            				$values['ModeS'] = $line[1];
367
-            				$values['Registration'] = $line[3];
368
-            				$values['ICAOTypeCode'] = '';
369
-            				$aircraft_name = $line[2];
370
-            				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
372
-            				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
-            				$sth_search = $Connection->db->prepare($query_search);
366
+							$values['ModeS'] = $line[1];
367
+							$values['Registration'] = $line[3];
368
+							$values['ICAOTypeCode'] = '';
369
+							$aircraft_name = $line[2];
370
+							// Check if we can find ICAO, else set it to GLID
371
+							$aircraft_name_split = explode(' ',$aircraft_name);
372
+							$search_more = '';
373
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
+							$sth_search = $Connection->db->prepare($query_search);
376 376
 					try {
377
-                                    		$sth_search->execute();
378
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
377
+											$sth_search->execute();
378
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380 380
 					} catch(PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 		try {
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402
-                        $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
404
-                        return "error : ".$e->getMessage();
405
-                }
402
+						$sth->execute(array(':source' => $database_file));
403
+				} catch(PDOException $e) {
404
+						return "error : ".$e->getMessage();
405
+				}
406 406
 		return '';
407 407
 	}
408 408
 
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		try {
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416
-                        $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
418
-                        return "error : ".$e->getMessage();
419
-                }
416
+						$sth->execute(array(':source' => $database_file));
417
+				} catch(PDOException $e) {
418
+						return "error : ".$e->getMessage();
419
+				}
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422 422
 		if ($fh = fopen($database_file,"r")) {
423 423
 			//$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)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
425
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
426 426
 		        
427 427
 			$Connection = new Connection();
428 428
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -430,126 +430,126 @@  discard block
 block discarded – undo
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432 432
 				$tmp = fgetcsv($fh,9999,',','"');
433
-            			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
435
-            				$values = array();
436
-            				//print_r($line);
437
-            				if ($country == 'F') {
438
-            				    $values['registration'] = $line[0];
439
-            				    $values['base'] = $line[4];
440
-            				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
-					    $values['cancel'] = $line[7];
433
+						while (!feof($fh)) {
434
+							$line = fgetcsv($fh,9999,',','"');
435
+							$values = array();
436
+							//print_r($line);
437
+							if ($country == 'F') {
438
+								$values['registration'] = $line[0];
439
+								$values['base'] = $line[4];
440
+								$values['owner'] = $line[5];
441
+								if ($line[6] == '') $values['date_first_reg'] = null;
442
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
+						$values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = $line[3];
448
-            				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
-					    $values['cancel'] = '';
452
-					    $values['modes'] = $line[7];
453
-					    $values['icao'] = $line[8];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = $line[3];
448
+								$values['owner'] = $line[2];
449
+								if ($line[1] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
+						$values['cancel'] = '';
452
+						$values['modes'] = $line[7];
453
+						$values['icao'] = $line[8];
454 454
 					    
455 455
 					} elseif ($country == 'HB') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[0];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    $values['date_first_reg'] = null;
461
-					    $values['cancel'] = '';
462
-					    $values['modes'] = $line[4];
463
-					    $values['icao'] = $line[7];
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[0];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								$values['date_first_reg'] = null;
461
+						$values['cancel'] = '';
462
+						$values['modes'] = $line[4];
463
+						$values['icao'] = $line[7];
464 464
 					} elseif ($country == 'OK') {
465
-					    // TODO : add modeS & reg to aircraft_modes
466
-            				    $values['registration'] = $line[3];
467
-            				    $values['base'] = null;
468
-            				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
-					    $values['cancel'] = '';
465
+						// TODO : add modeS & reg to aircraft_modes
466
+								$values['registration'] = $line[3];
467
+								$values['base'] = null;
468
+								$values['owner'] = $line[5];
469
+								if ($line[18] == '') $values['date_first_reg'] = null;
470
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
+						$values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473
-					    // TODO : add modeS & reg to aircraft_modes
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
-
480
-					    $values['cancel'] = $line[39];
473
+						// TODO : add modeS & reg to aircraft_modes
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[12];
477
+								if ($line[28] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
+
480
+						$values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    $values['date_first_reg'] = null;
486
-					    $values['cancel'] = '';
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								$values['date_first_reg'] = null;
486
+						$values['cancel'] = '';
487 487
 					} elseif ($country == 'CC') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[6];
491
-            				    $values['date_first_reg'] = null;
492
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[6];
491
+								$values['date_first_reg'] = null;
492
+						$values['cancel'] = '';
493 493
 					} elseif ($country == 'HJ') {
494
-            				    $values['registration'] = $line[0];
495
-            				    $values['base'] = null;
496
-            				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
-					    $values['cancel'] = '';
494
+								$values['registration'] = $line[0];
495
+								$values['base'] = null;
496
+								$values['owner'] = $line[8];
497
+								if ($line[7] == '') $values['date_first_reg'] = null;
498
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+						$values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501
-            				    $values['registration'] = $line[0];
502
-            				    $values['base'] = null;
503
-            				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
-					    $values['cancel'] = $line[7];
501
+								$values['registration'] = $line[0];
502
+								$values['base'] = null;
503
+								$values['owner'] = $line[4];
504
+								if ($line[6] == '') $values['date_first_reg'] = null;
505
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+						$values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508
-            				    $values['registration'] = $line[0];
509
-            				    $values['base'] = null;
510
-            				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
-					    $values['cancel'] = '';
508
+								$values['registration'] = $line[0];
509
+								$values['base'] = null;
510
+								$values['owner'] = $line[4];
511
+								if ($line[5] == '') $values['date_first_reg'] = null;
512
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
+						$values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515
-            				    $values['registration'] = $line[0];
516
-            				    $values['base'] = null;
517
-            				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
-					    $values['cancel'] = '';
515
+								$values['registration'] = $line[0];
516
+								$values['base'] = null;
517
+								$values['owner'] = $line[3];
518
+								if ($line[7] == '') $values['date_first_reg'] = null;
519
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
+						$values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522
-            				    $values['registration'] = $line[0];
523
-            				    $values['base'] = null;
524
-            				    $values['owner'] = $line[3];
525
-            				    $values['date_first_reg'] = null;
526
-					    $values['cancel'] = '';
527
-					    $values['modes'] = $line[5];
528
-					    $values['icao'] = $line[9];
522
+								$values['registration'] = $line[0];
523
+								$values['base'] = null;
524
+								$values['owner'] = $line[3];
525
+								$values['date_first_reg'] = null;
526
+						$values['cancel'] = '';
527
+						$values['modes'] = $line[5];
528
+						$values['icao'] = $line[9];
529 529
 					} elseif ($country == 'M') {
530
-            				    $values['registration'] = $line[0];
531
-            				    $values['base'] = null;
532
-            				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
-					    $values['modes'] = $line[4];
536
-					    $values['icao'] = $line[10];
530
+								$values['registration'] = $line[0];
531
+								$values['base'] = null;
532
+								$values['owner'] = $line[6];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
+						$values['modes'] = $line[4];
536
+						$values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538
-            				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
-					    $values['modes'] = $line[5];
541
-					    $values['icao'] = $line[6];
538
+								$values['registration'] = $line[0];
539
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
+						$values['modes'] = $line[5];
541
+						$values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543
-            				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
-					    $values['modes'] = $line[4];
546
-					    $values['icao'] = $line[5];
543
+								$values['registration'] = $line[0];
544
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
+						$values['modes'] = $line[4];
546
+						$values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
548
-            				    $values['registration'] = $line[0];
549
-            				    $values['base'] = null;
550
-            				    $values['owner'] = $line[3];
551
-            				    $values['date_first_reg'] = null;
552
-					    $values['cancel'] = '';
548
+								$values['registration'] = $line[0];
549
+								$values['base'] = null;
550
+								$values['owner'] = $line[3];
551
+								$values['date_first_reg'] = null;
552
+						$values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555 555
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
                 */
685
-                /*
685
+				/*
686 686
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
687 687
 		try {
688 688
 			$Connection = new Connection();
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 		try {
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930
-                        $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
932
-                        return "error : ".$e->getMessage();
933
-                }
930
+						$sth->execute(array(':source' => 'translation.csv'));
931
+				} catch(PDOException $e) {
932
+						return "error : ".$e->getMessage();
933
+				}
934 934
 
935 935
 		
936 936
 		//update_db::unzip($out_file);
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
952
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
-                                                //echo substr($operator, 0, 2)."\n";;
954
-                                                if (count($airline_array) > 0) {
952
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
+												//echo substr($operator, 0, 2)."\n";;
954
+												if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956 956
 							$operator = $airline_array[0]['icao'].substr($operator,2);
957
-                                                }
958
-                                        }
957
+												}
958
+										}
959 959
 					
960 960
 					$operator_correct = $data[3];
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
-                                                if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
-                                            	}
966
-                                        }
962
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
+												if (count($airline_array) > 0) {
964
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
+												}
966
+										}
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			//$Connection->db->commit();
978 978
 		}
979 979
 		return '';
980
-        }
980
+		}
981 981
 	
982 982
 	public static function translation_fam() {
983 983
 		global $tmp_dir, $globalTransaction;
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 			//$Connection->db->commit();
1016 1016
 		}
1017 1017
 		return '';
1018
-        }
1018
+		}
1019 1019
 
1020 1020
 	/*
1021 1021
 	* This function use FAA public data.
@@ -1027,19 +1027,19 @@  discard block
 block discarded – undo
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1036 1036
 		try {
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039
-                        $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1041
-                        return "error : ".$e->getMessage();
1042
-                }
1039
+						$sth->execute(array(':source' => 'website_faa'));
1040
+				} catch(PDOException $e) {
1041
+						return "error : ".$e->getMessage();
1042
+				}
1043 1043
 
1044 1044
 		$delimiter = ",";
1045 1045
 		$mfr = array();
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 		}
1208 1208
 		*/
1209 1209
 		return '';
1210
-        }
1210
+		}
1211 1211
         
1212 1212
 	public static function owner_fam() {
1213 1213
 		global $tmp_dir, $globalTransaction;
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
 		try {
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218
-                        $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1220
-                        return "error : ".$e->getMessage();
1221
-                }
1218
+						$sth->execute(array(':source' => 'website_fam'));
1219
+				} catch(PDOException $e) {
1220
+						return "error : ".$e->getMessage();
1221
+				}
1222 1222
 
1223 1223
 		$delimiter = "\t";
1224 1224
 		$Connection = new Connection();
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 			if ($globalTransaction) $Connection->db->commit();
1245 1245
 		}
1246 1246
 		return '';
1247
-        }
1247
+		}
1248 1248
 
1249 1249
 	public static function routes_fam() {
1250 1250
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 			if ($globalTransaction) $Connection->db->commit();
1287 1287
 		}
1288 1288
 		return '';
1289
-        }
1289
+		}
1290 1290
 
1291 1291
 	public static function marine_identity_fam() {
1292 1292
 		global $tmp_dir, $globalTransaction;
@@ -1294,10 +1294,10 @@  discard block
 block discarded – undo
1294 1294
 		try {
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297
-                        $sth->execute();
1298
-                } catch(PDOException $e) {
1299
-                        return "error : ".$e->getMessage();
1300
-                }
1297
+						$sth->execute();
1298
+				} catch(PDOException $e) {
1299
+						return "error : ".$e->getMessage();
1300
+				}
1301 1301
 
1302 1302
 		
1303 1303
 		//update_db::unzip($out_file);
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 			if ($globalTransaction) $Connection->db->commit();
1328 1328
 		}
1329 1329
 		return '';
1330
-        }
1330
+		}
1331 1331
 
1332 1332
 	public static function satellite_fam() {
1333 1333
 		global $tmp_dir, $globalTransaction;
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 			if ($globalTransaction) $Connection->db->commit();
1399 1399
 		}
1400 1400
 		return '';
1401
-        }
1401
+		}
1402 1402
 
1403 1403
 	public static function tle($filename,$tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
 		try {
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412
-                        $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1414
-                        return "error : ".$e->getMessage();
1415
-                }
1412
+						$sth->execute(array(':source' => $filename));
1413
+				} catch(PDOException $e) {
1414
+						return "error : ".$e->getMessage();
1415
+				}
1416 1416
 		
1417 1417
 		$Connection = new Connection();
1418 1418
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 			//$Connection->db->commit();
1448 1448
 		}
1449 1449
 		return '';
1450
-        }
1450
+		}
1451 1451
 
1452 1452
 	public static function satellite_ucsdb($filename) {
1453 1453
 		global $tmp_dir, $globalTransaction;
@@ -1706,11 +1706,11 @@  discard block
 block discarded – undo
1706 1706
 							try {
1707 1707
 								$sth = $Connection->db->prepare($query);
1708 1708
 								$sth->execute(array(
1709
-								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
-								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
-								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
-								    )
1709
+									':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
+									':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
+									':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
+									':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
+									)
1714 1714
 								);
1715 1715
 							} catch(PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
 			//$Connection->db->commit();
1735 1735
 		}
1736 1736
 		return '';
1737
-        }
1737
+		}
1738 1738
 
1739 1739
 	/**
1740
-        * Convert a HTML table to an array
1741
-        * @param String $data HTML page
1742
-        * @return Array array of the tables in HTML page
1743
-        */
1740
+	 * Convert a HTML table to an array
1741
+	 * @param String $data HTML page
1742
+	 * @return Array array of the tables in HTML page
1743
+	 */
1744 1744
 /*
1745 1745
         private static function table2array($data) {
1746 1746
                 $html = str_get_html($data);
@@ -1770,11 +1770,11 @@  discard block
 block discarded – undo
1770 1770
                 return(array_filter($tabledata));
1771 1771
         }
1772 1772
 */
1773
-       /**
1774
-        * Get data from form result
1775
-        * @param String $url form URL
1776
-        * @return String the result
1777
-        */
1773
+	   /**
1774
+	    * Get data from form result
1775
+	    * @param String $url form URL
1776
+	    * @return String the result
1777
+	    */
1778 1778
 /*
1779 1779
         private static function getData($url) {
1780 1780
                 $ch = curl_init();
@@ -1924,7 +1924,7 @@  discard block
 block discarded – undo
1924 1924
 			if ($globalTransaction) $Connection->db->commit();
1925 1925
 		}
1926 1926
 		return '';
1927
-        }
1927
+		}
1928 1928
 	
1929 1929
 	public static function update_airspace() {
1930 1930
 		global $tmp_dir, $globalDBdriver;
@@ -1934,11 +1934,11 @@  discard block
 block discarded – undo
1934 1934
 			$query = 'DROP TABLE airspace';
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937
-                    		$sth->execute();
1938
-	                } catch(PDOException $e) {
1937
+							$sth->execute();
1938
+					} catch(PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940
-	                }
1941
-	        }
1940
+					}
1941
+			}
1942 1942
 
1943 1943
 
1944 1944
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -2003,10 +2003,10 @@  discard block
 block discarded – undo
2003 2003
 			$query = 'DROP TABLE countries';
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006
-            	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2008
-    	                	echo "error : ".$e->getMessage();
2009
-	                }
2006
+							$sth->execute();
2007
+					} catch(PDOException $e) {
2008
+							echo "error : ".$e->getMessage();
2009
+					}
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012 2012
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2465,7 +2465,7 @@  discard block
 block discarded – undo
2465 2465
 						$error = update_db::airlines_fam();
2466 2466
 						update_db::insert_airlines_version($airlines_md5);
2467 2467
 					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2468
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2468
+				} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2469 2469
 			} elseif ($globalDebug) echo "No update.";
2470 2470
 		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2471 2471
 		if ($error != '') {
@@ -2956,10 +2956,10 @@  discard block
 block discarded – undo
2956 2956
 		try {
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959
-                        $sth->execute();
2960
-                } catch(PDOException $e) {
2961
-                        return "error : ".$e->getMessage();
2962
-                }
2959
+						$sth->execute();
2960
+				} catch(PDOException $e) {
2961
+						return "error : ".$e->getMessage();
2962
+				}
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
@@ -3015,8 +3015,8 @@  discard block
 block discarded – undo
3015 3015
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018
-				    $data['date_end'] = NULL;
3019
-				    $data['permanent'] = 1;
3018
+					$data['date_end'] = NULL;
3019
+					$data['permanent'] = 1;
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
@@ -3090,13 +3090,13 @@  discard block
 block discarded – undo
3090 3090
 		try {
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093
-                        $sth->execute();
3094
-                } catch(PDOException $e) {
3095
-                        return "error : ".$e->getMessage();
3096
-                }
3097
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3098
-                if ($row['nb'] > 0) return false;
3099
-                else return true;
3093
+						$sth->execute();
3094
+				} catch(PDOException $e) {
3095
+						return "error : ".$e->getMessage();
3096
+				}
3097
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3098
+				if ($row['nb'] > 0) return false;
3099
+				else return true;
3100 3100
 	}
3101 3101
 
3102 3102
 	public static function insert_last_update() {
@@ -3105,10 +3105,10 @@  discard block
 block discarded – undo
3105 3105
 		try {
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108
-                        $sth->execute();
3109
-                } catch(PDOException $e) {
3110
-                        return "error : ".$e->getMessage();
3111
-                }
3108
+						$sth->execute();
3109
+				} catch(PDOException $e) {
3110
+						return "error : ".$e->getMessage();
3111
+				}
3112 3112
 	}
3113 3113
 
3114 3114
 	public static function check_airspace_version($version) {
@@ -3116,13 +3116,13 @@  discard block
 block discarded – undo
3116 3116
 		try {
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119
-                        $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3121
-                        return "error : ".$e->getMessage();
3122
-                }
3123
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3124
-                if ($row['nb'] > 0) return true;
3125
-                else return false;
3119
+						$sth->execute(array(':version' => $version));
3120
+				} catch(PDOException $e) {
3121
+						return "error : ".$e->getMessage();
3122
+				}
3123
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3124
+				if ($row['nb'] > 0) return true;
3125
+				else return false;
3126 3126
 	}
3127 3127
 
3128 3128
 	public static function check_geoid_version($version) {
@@ -3130,13 +3130,13 @@  discard block
 block discarded – undo
3130 3130
 		try {
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133
-                        $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3135
-                        return "error : ".$e->getMessage();
3136
-                }
3137
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return true;
3139
-                else return false;
3133
+						$sth->execute(array(':version' => $version));
3134
+				} catch(PDOException $e) {
3135
+						return "error : ".$e->getMessage();
3136
+				}
3137
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3138
+				if ($row['nb'] > 0) return true;
3139
+				else return false;
3140 3140
 	}
3141 3141
 
3142 3142
 	public static function check_marine_identity_version($version) {
@@ -3237,10 +3237,10 @@  discard block
 block discarded – undo
3237 3237
 		try {
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240
-                        $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3242
-                        return "error : ".$e->getMessage();
3243
-                }
3240
+						$sth->execute(array(':version' => $version));
3241
+				} catch(PDOException $e) {
3242
+						return "error : ".$e->getMessage();
3243
+				}
3244 3244
 	}
3245 3245
 
3246 3246
 	public static function insert_marine_identity_version($version) {
@@ -3277,13 +3277,13 @@  discard block
 block discarded – undo
3277 3277
 		try {
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280
-                        $sth->execute();
3281
-                } catch(PDOException $e) {
3282
-                        return "error : ".$e->getMessage();
3283
-                }
3284
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-                if ($row['nb'] > 0) return false;
3286
-                else return true;
3280
+						$sth->execute();
3281
+				} catch(PDOException $e) {
3282
+						return "error : ".$e->getMessage();
3283
+				}
3284
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3285
+				if ($row['nb'] > 0) return false;
3286
+				else return true;
3287 3287
 	}
3288 3288
 
3289 3289
 	public static function insert_last_notam_update() {
@@ -3292,10 +3292,10 @@  discard block
 block discarded – undo
3292 3292
 		try {
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295
-                        $sth->execute();
3296
-                } catch(PDOException $e) {
3297
-                        return "error : ".$e->getMessage();
3298
-                }
3295
+						$sth->execute();
3296
+				} catch(PDOException $e) {
3297
+						return "error : ".$e->getMessage();
3298
+				}
3299 3299
 	}
3300 3300
 
3301 3301
 	public static function check_last_airspace_update() {
@@ -3308,13 +3308,13 @@  discard block
 block discarded – undo
3308 3308
 		try {
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311
-                        $sth->execute();
3312
-                } catch(PDOException $e) {
3313
-                        return "error : ".$e->getMessage();
3314
-                }
3315
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3316
-                if ($row['nb'] > 0) return false;
3317
-                else return true;
3311
+						$sth->execute();
3312
+				} catch(PDOException $e) {
3313
+						return "error : ".$e->getMessage();
3314
+				}
3315
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3316
+				if ($row['nb'] > 0) return false;
3317
+				else return true;
3318 3318
 	}
3319 3319
 
3320 3320
 	public static function insert_last_airspace_update() {
@@ -3323,10 +3323,10 @@  discard block
 block discarded – undo
3323 3323
 		try {
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326
-                        $sth->execute();
3327
-                } catch(PDOException $e) {
3328
-                        return "error : ".$e->getMessage();
3329
-                }
3326
+						$sth->execute();
3327
+				} catch(PDOException $e) {
3328
+						return "error : ".$e->getMessage();
3329
+				}
3330 3330
 	}
3331 3331
 
3332 3332
 	public static function check_last_geoid_update() {
@@ -3339,13 +3339,13 @@  discard block
 block discarded – undo
3339 3339
 		try {
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342
-                        $sth->execute();
3343
-                } catch(PDOException $e) {
3344
-                        return "error : ".$e->getMessage();
3345
-                }
3346
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3347
-                if ($row['nb'] > 0) return false;
3348
-                else return true;
3342
+						$sth->execute();
3343
+				} catch(PDOException $e) {
3344
+						return "error : ".$e->getMessage();
3345
+				}
3346
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3347
+				if ($row['nb'] > 0) return false;
3348
+				else return true;
3349 3349
 	}
3350 3350
 
3351 3351
 	public static function insert_last_geoid_update() {
@@ -3354,10 +3354,10 @@  discard block
 block discarded – undo
3354 3354
 		try {
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357
-                        $sth->execute();
3358
-                } catch(PDOException $e) {
3359
-                        return "error : ".$e->getMessage();
3360
-                }
3357
+						$sth->execute();
3358
+				} catch(PDOException $e) {
3359
+						return "error : ".$e->getMessage();
3360
+				}
3361 3361
 	}
3362 3362
 
3363 3363
 	public static function check_last_owner_update() {
@@ -3463,13 +3463,13 @@  discard block
 block discarded – undo
3463 3463
 		try {
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466
-                        $sth->execute();
3467
-                } catch(PDOException $e) {
3468
-                        return "error : ".$e->getMessage();
3469
-                }
3470
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3471
-                if ($row['nb'] > 0) return false;
3472
-                else return true;
3466
+						$sth->execute();
3467
+				} catch(PDOException $e) {
3468
+						return "error : ".$e->getMessage();
3469
+				}
3470
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3471
+				if ($row['nb'] > 0) return false;
3472
+				else return true;
3473 3473
 	}
3474 3474
 
3475 3475
 	public static function insert_last_schedules_update() {
@@ -3649,10 +3649,10 @@  discard block
 block discarded – undo
3649 3649
 		try {
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652
-                        $sth->execute();
3653
-                } catch(PDOException $e) {
3654
-                        return "error : ".$e->getMessage();
3655
-                }
3652
+						$sth->execute();
3653
+				} catch(PDOException $e) {
3654
+						return "error : ".$e->getMessage();
3655
+				}
3656 3656
 	}
3657 3657
 	public static function delete_duplicateowner() {
3658 3658
 		global $globalDBdriver;
@@ -3664,10 +3664,10 @@  discard block
 block discarded – undo
3664 3664
 		try {
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667
-                        $sth->execute();
3668
-                } catch(PDOException $e) {
3669
-                        return "error : ".$e->getMessage();
3670
-                }
3667
+						$sth->execute();
3668
+				} catch(PDOException $e) {
3669
+						return "error : ".$e->getMessage();
3670
+				}
3671 3671
 	}
3672 3672
 	
3673 3673
 	public static function update_all() {
Please login to merge, or discard this patch.