| @@ -76,38 +76,38 @@ discard block | ||
| 76 | 76 |  		try { | 
| 77 | 77 | //$Connection = new Connection(); | 
| 78 | 78 | $sth = $Connection->db->prepare($query); | 
| 79 | -                        $sth->execute(array(':source' => $database_file)); | |
| 80 | -                } catch(PDOException $e) { | |
| 81 | - return "error : ".$e->getMessage(); | |
| 82 | - } | |
| 79 | +						$sth->execute(array(':source' => $database_file)); | |
| 80 | +				} catch(PDOException $e) { | |
| 81 | + return "error : ".$e->getMessage(); | |
| 82 | + } | |
| 83 | 83 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; | |
| 85 | - update_db::connect_sqlite($database_file); | |
| 84 | + if ($globalDebug) echo " - Add routes to DB -"; | |
| 85 | + update_db::connect_sqlite($database_file); | |
| 86 | 86 | //$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'; | 
| 87 | 87 | $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"; | 
| 88 | 88 |  		try { | 
| 89 | - $sth = update_db::$db_sqlite->prepare($query); | |
| 90 | - $sth->execute(); | |
| 91 | -                } catch(PDOException $e) { | |
| 92 | - return "error : ".$e->getMessage(); | |
| 93 | - } | |
| 89 | + $sth = update_db::$db_sqlite->prepare($query); | |
| 90 | + $sth->execute(); | |
| 91 | +				} catch(PDOException $e) { | |
| 92 | + return "error : ".$e->getMessage(); | |
| 93 | + } | |
| 94 | 94 | //$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)'; | 
| 95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; | 
| 96 | 96 | $Connection = new Connection(); | 
| 97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); | 
| 98 | 98 |  		try { | 
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 100 | -            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 100 | +					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 101 | 101 |  				//$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); | 
| 102 | 102 |  				$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); | 
| 103 | 103 | $sth_dest->execute($query_dest_values); | 
| 104 | - } | |
| 104 | + } | |
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); | 
| 106 | 106 |  		} catch(PDOException $e) { | 
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); | 
| 108 | 108 | return "error : ".$e->getMessage(); | 
| 109 | 109 | } | 
| 110 | - return ''; | |
| 110 | + return ''; | |
| 111 | 111 | } | 
| 112 | 112 |  	public static function retrieve_route_oneworld($database_file) { | 
| 113 | 113 | global $globalDebug, $globalTransaction; | 
| @@ -118,12 +118,12 @@ discard block | ||
| 118 | 118 |  		try { | 
| 119 | 119 | //$Connection = new Connection(); | 
| 120 | 120 | $sth = $Connection->db->prepare($query); | 
| 121 | -                        $sth->execute(array(':source' => 'oneworld')); | |
| 122 | -                } catch(PDOException $e) { | |
| 123 | - return "error : ".$e->getMessage(); | |
| 124 | - } | |
| 121 | +						$sth->execute(array(':source' => 'oneworld')); | |
| 122 | +				} catch(PDOException $e) { | |
| 123 | + return "error : ".$e->getMessage(); | |
| 124 | + } | |
| 125 | 125 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; | |
| 126 | + if ($globalDebug) echo " - Add routes to DB -"; | |
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 128 | 128 | $Spotter = new Spotter(); | 
| 129 | 129 |  		if ($fh = fopen($database_file,"r")) { | 
| @@ -147,7 +147,7 @@ discard block | ||
| 147 | 147 | } | 
| 148 | 148 | if ($globalTransaction) $Connection->db->commit(); | 
| 149 | 149 | } | 
| 150 | - return ''; | |
| 150 | + return ''; | |
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 |  	public static function retrieve_route_skyteam($database_file) { | 
| @@ -159,12 +159,12 @@ discard block | ||
| 159 | 159 |  		try { | 
| 160 | 160 | //$Connection = new Connection(); | 
| 161 | 161 | $sth = $Connection->db->prepare($query); | 
| 162 | -                        $sth->execute(array(':source' => 'skyteam')); | |
| 163 | -                } catch(PDOException $e) { | |
| 164 | - return "error : ".$e->getMessage(); | |
| 165 | - } | |
| 162 | +						$sth->execute(array(':source' => 'skyteam')); | |
| 163 | +				} catch(PDOException $e) { | |
| 164 | + return "error : ".$e->getMessage(); | |
| 165 | + } | |
| 166 | 166 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; | |
| 167 | + if ($globalDebug) echo " - Add routes to DB -"; | |
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 170 | 170 | $Spotter = new Spotter(); | 
| @@ -190,7 +190,7 @@ discard block | ||
| 190 | 190 | return "error : ".$e->getMessage(); | 
| 191 | 191 | } | 
| 192 | 192 | } | 
| 193 | - return ''; | |
| 193 | + return ''; | |
| 194 | 194 | } | 
| 195 | 195 |  	public static function retrieve_modes_sqlite_to_dest($database_file) { | 
| 196 | 196 | global $globalTransaction; | 
| @@ -199,27 +199,27 @@ discard block | ||
| 199 | 199 |  		try { | 
| 200 | 200 | $Connection = new Connection(); | 
| 201 | 201 | $sth = $Connection->db->prepare($query); | 
| 202 | -                        $sth->execute(array(':source' => $database_file)); | |
| 203 | -                } catch(PDOException $e) { | |
| 204 | - return "error : ".$e->getMessage(); | |
| 205 | - } | |
| 202 | +						$sth->execute(array(':source' => $database_file)); | |
| 203 | +				} catch(PDOException $e) { | |
| 204 | + return "error : ".$e->getMessage(); | |
| 205 | + } | |
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; | 
| 207 | 207 |  		try { | 
| 208 | 208 | $Connection = new Connection(); | 
| 209 | 209 | $sth = $Connection->db->prepare($query); | 
| 210 | -                        $sth->execute(array(':source' => $database_file)); | |
| 211 | -                } catch(PDOException $e) { | |
| 212 | - return "error : ".$e->getMessage(); | |
| 213 | - } | |
| 210 | +						$sth->execute(array(':source' => $database_file)); | |
| 211 | +				} catch(PDOException $e) { | |
| 212 | + return "error : ".$e->getMessage(); | |
| 213 | + } | |
| 214 | 214 | |
| 215 | - update_db::connect_sqlite($database_file); | |
| 215 | + update_db::connect_sqlite($database_file); | |
| 216 | 216 | $query = 'select * from Aircraft'; | 
| 217 | 217 |  		try { | 
| 218 | - $sth = update_db::$db_sqlite->prepare($query); | |
| 219 | - $sth->execute(); | |
| 220 | -                } catch(PDOException $e) { | |
| 221 | - return "error : ".$e->getMessage(); | |
| 222 | - } | |
| 218 | + $sth = update_db::$db_sqlite->prepare($query); | |
| 219 | + $sth->execute(); | |
| 220 | +				} catch(PDOException $e) { | |
| 221 | + return "error : ".$e->getMessage(); | |
| 222 | + } | |
| 223 | 223 | //$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)'; | 
| 224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; | 
| 225 | 225 | |
| @@ -230,17 +230,17 @@ discard block | ||
| 230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); | 
| 231 | 231 |  		try { | 
| 232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 233 | -            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 233 | +					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 234 | 234 |  			//$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']); | 
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; | 
| 236 | 236 | else $type = null; | 
| 237 | 237 |  				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); | 
| 238 | 238 | $sth_dest->execute($query_dest_values); | 
| 239 | 239 |  				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { | 
| 240 | -				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); | |
| 241 | - $sth_dest_owner->execute($query_dest_owner_values); | |
| 240 | +					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); | |
| 241 | + $sth_dest_owner->execute($query_dest_owner_values); | |
| 242 | 242 | } | 
| 243 | - } | |
| 243 | + } | |
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); | 
| 245 | 245 |  		} catch(PDOException $e) { | 
| 246 | 246 | return "error : ".$e->getMessage(); | 
| @@ -251,10 +251,10 @@ discard block | ||
| 251 | 251 |  		try { | 
| 252 | 252 | $Connection = new Connection(); | 
| 253 | 253 | $sth = $Connection->db->prepare($query); | 
| 254 | -                        $sth->execute(array(':source' => $database_file)); | |
| 255 | -                } catch(PDOException $e) { | |
| 256 | - return "error : ".$e->getMessage(); | |
| 257 | - } | |
| 254 | +						$sth->execute(array(':source' => $database_file)); | |
| 255 | +				} catch(PDOException $e) { | |
| 256 | + return "error : ".$e->getMessage(); | |
| 257 | + } | |
| 258 | 258 | return ''; | 
| 259 | 259 | } | 
| 260 | 260 | |
| @@ -266,10 +266,10 @@ discard block | ||
| 266 | 266 |  		try { | 
| 267 | 267 | $Connection = new Connection(); | 
| 268 | 268 | $sth = $Connection->db->prepare($query); | 
| 269 | -                        $sth->execute(array(':source' => $database_file)); | |
| 270 | -                } catch(PDOException $e) { | |
| 271 | - return "error : ".$e->getMessage(); | |
| 272 | - } | |
| 269 | +						$sth->execute(array(':source' => $database_file)); | |
| 270 | +				} catch(PDOException $e) { | |
| 271 | + return "error : ".$e->getMessage(); | |
| 272 | + } | |
| 273 | 273 | |
| 274 | 274 |  		if ($fh = fopen($database_file,"r")) { | 
| 275 | 275 | //$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)'; | 
| @@ -279,26 +279,26 @@ discard block | ||
| 279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); | 
| 280 | 280 |  			try { | 
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 282 | -            			while (!feof($fh)) { | |
| 283 | - $values = array(); | |
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); | |
| 282 | +						while (!feof($fh)) { | |
| 283 | + $values = array(); | |
| 284 | + $line = $Common->hex2str(fgets($fh,9999)); | |
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 | 
| 286 | - $values['ModeS'] = substr($line,0,6); | |
| 287 | - $values['Registration'] = trim(substr($line,69,6)); | |
| 288 | - $aircraft_name = trim(substr($line,48,6)); | |
| 289 | - // Check if we can find ICAO, else set it to GLID | |
| 290 | -            				$aircraft_name_split = explode(' ',$aircraft_name); | |
| 291 | - $search_more = ''; | |
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | |
| 293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | |
| 294 | - $sth_search = $Connection->db->prepare($query_search); | |
| 286 | + $values['ModeS'] = substr($line,0,6); | |
| 287 | + $values['Registration'] = trim(substr($line,69,6)); | |
| 288 | + $aircraft_name = trim(substr($line,48,6)); | |
| 289 | + // Check if we can find ICAO, else set it to GLID | |
| 290 | +							$aircraft_name_split = explode(' ',$aircraft_name); | |
| 291 | + $search_more = ''; | |
| 292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | |
| 293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | |
| 294 | + $sth_search = $Connection->db->prepare($query_search); | |
| 295 | 295 |  					try { | 
| 296 | - $sth_search->execute(); | |
| 297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); | |
| 298 | -	            				//if (count($result) > 0) { | |
| 299 | -	            				if (isset($result['icao']) && $result['icao'] != '') { | |
| 300 | - $values['ICAOTypeCode'] = $result['icao']; | |
| 301 | - } | |
| 296 | + $sth_search->execute(); | |
| 297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); | |
| 298 | +								//if (count($result) > 0) { | |
| 299 | +								if (isset($result['icao']) && $result['icao'] != '') { | |
| 300 | + $values['ICAOTypeCode'] = $result['icao']; | |
| 301 | + } | |
| 302 | 302 |  					} catch(PDOException $e) { | 
| 303 | 303 | return "error : ".$e->getMessage(); | 
| 304 | 304 | } | 
| @@ -321,10 +321,10 @@ discard block | ||
| 321 | 321 |  		try { | 
| 322 | 322 | $Connection = new Connection(); | 
| 323 | 323 | $sth = $Connection->db->prepare($query); | 
| 324 | -                        $sth->execute(array(':source' => $database_file)); | |
| 325 | -                } catch(PDOException $e) { | |
| 326 | - return "error : ".$e->getMessage(); | |
| 327 | - } | |
| 324 | +						$sth->execute(array(':source' => $database_file)); | |
| 325 | +				} catch(PDOException $e) { | |
| 326 | + return "error : ".$e->getMessage(); | |
| 327 | + } | |
| 328 | 328 | return ''; | 
| 329 | 329 | } | 
| 330 | 330 | |
| @@ -335,10 +335,10 @@ discard block | ||
| 335 | 335 |  		try { | 
| 336 | 336 | $Connection = new Connection(); | 
| 337 | 337 | $sth = $Connection->db->prepare($query); | 
| 338 | -                        $sth->execute(array(':source' => $database_file)); | |
| 339 | -                } catch(PDOException $e) { | |
| 340 | - return "error : ".$e->getMessage(); | |
| 341 | - } | |
| 338 | +						$sth->execute(array(':source' => $database_file)); | |
| 339 | +				} catch(PDOException $e) { | |
| 340 | + return "error : ".$e->getMessage(); | |
| 341 | + } | |
| 342 | 342 | |
| 343 | 343 |  		if ($fh = fopen($database_file,"r")) { | 
| 344 | 344 | //$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)'; | 
| @@ -349,25 +349,25 @@ discard block | ||
| 349 | 349 |  			try { | 
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); | 
| 352 | -            			while (!feof($fh)) { | |
| 353 | - $line = fgetcsv($fh,9999,',',"'"); | |
| 352 | +						while (!feof($fh)) { | |
| 353 | + $line = fgetcsv($fh,9999,',',"'"); | |
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 | 
| 356 | 356 | //print_r($line); | 
| 357 | - $values['ModeS'] = $line[1]; | |
| 358 | - $values['Registration'] = $line[3]; | |
| 359 | - $values['ICAOTypeCode'] = ''; | |
| 360 | - $aircraft_name = $line[2]; | |
| 361 | - // Check if we can find ICAO, else set it to GLID | |
| 362 | -            				$aircraft_name_split = explode(' ',$aircraft_name); | |
| 363 | - $search_more = ''; | |
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | |
| 365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | |
| 366 | - $sth_search = $Connection->db->prepare($query_search); | |
| 357 | + $values['ModeS'] = $line[1]; | |
| 358 | + $values['Registration'] = $line[3]; | |
| 359 | + $values['ICAOTypeCode'] = ''; | |
| 360 | + $aircraft_name = $line[2]; | |
| 361 | + // Check if we can find ICAO, else set it to GLID | |
| 362 | +							$aircraft_name_split = explode(' ',$aircraft_name); | |
| 363 | + $search_more = ''; | |
| 364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | |
| 365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | |
| 366 | + $sth_search = $Connection->db->prepare($query_search); | |
| 367 | 367 |  					try { | 
| 368 | - $sth_search->execute(); | |
| 369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); | |
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; | |
| 368 | + $sth_search->execute(); | |
| 369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); | |
| 370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; | |
| 371 | 371 |  					} catch(PDOException $e) { | 
| 372 | 372 | return "error : ".$e->getMessage(); | 
| 373 | 373 | } | 
| @@ -390,10 +390,10 @@ discard block | ||
| 390 | 390 |  		try { | 
| 391 | 391 | $Connection = new Connection(); | 
| 392 | 392 | $sth = $Connection->db->prepare($query); | 
| 393 | -                        $sth->execute(array(':source' => $database_file)); | |
| 394 | -                } catch(PDOException $e) { | |
| 395 | - return "error : ".$e->getMessage(); | |
| 396 | - } | |
| 393 | +						$sth->execute(array(':source' => $database_file)); | |
| 394 | +				} catch(PDOException $e) { | |
| 395 | + return "error : ".$e->getMessage(); | |
| 396 | + } | |
| 397 | 397 | return ''; | 
| 398 | 398 | } | 
| 399 | 399 | |
| @@ -404,16 +404,16 @@ discard block | ||
| 404 | 404 |  		try { | 
| 405 | 405 | $Connection = new Connection(); | 
| 406 | 406 | $sth = $Connection->db->prepare($query); | 
| 407 | -                        $sth->execute(array(':source' => $database_file)); | |
| 408 | -                } catch(PDOException $e) { | |
| 409 | - return "error : ".$e->getMessage(); | |
| 410 | - } | |
| 407 | +						$sth->execute(array(':source' => $database_file)); | |
| 408 | +				} catch(PDOException $e) { | |
| 409 | + return "error : ".$e->getMessage(); | |
| 410 | + } | |
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 412 | 412 | $Spotter = new Spotter(); | 
| 413 | 413 |  		if ($fh = fopen($database_file,"r")) { | 
| 414 | 414 | //$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)'; | 
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; | 
| 416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; | |
| 416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; | |
| 417 | 417 | |
| 418 | 418 | $Connection = new Connection(); | 
| 419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); | 
| @@ -421,126 +421,126 @@ discard block | ||
| 421 | 421 |  			try { | 
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); | 
| 424 | -            			while (!feof($fh)) { | |
| 425 | - $line = fgetcsv($fh,9999,',','"'); | |
| 426 | - $values = array(); | |
| 427 | - //print_r($line); | |
| 428 | -            				if ($country == 'F') { | |
| 429 | - $values['registration'] = $line[0]; | |
| 430 | - $values['base'] = $line[4]; | |
| 431 | - $values['owner'] = $line[5]; | |
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; | |
| 433 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 434 | - $values['cancel'] = $line[7]; | |
| 424 | +						while (!feof($fh)) { | |
| 425 | + $line = fgetcsv($fh,9999,',','"'); | |
| 426 | + $values = array(); | |
| 427 | + //print_r($line); | |
| 428 | +							if ($country == 'F') { | |
| 429 | + $values['registration'] = $line[0]; | |
| 430 | + $values['base'] = $line[4]; | |
| 431 | + $values['owner'] = $line[5]; | |
| 432 | + if ($line[6] == '') $values['date_first_reg'] = null; | |
| 433 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 434 | + $values['cancel'] = $line[7]; | |
| 435 | 435 |  					} elseif ($country == 'EI') { | 
| 436 | - // TODO : add modeS & reg to aircraft_modes | |
| 437 | - $values['registration'] = $line[0]; | |
| 438 | - $values['base'] = $line[3]; | |
| 439 | - $values['owner'] = $line[2]; | |
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; | |
| 441 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); | |
| 442 | - $values['cancel'] = ''; | |
| 443 | - $values['modes'] = $line[7]; | |
| 444 | - $values['icao'] = $line[8]; | |
| 436 | + // TODO : add modeS & reg to aircraft_modes | |
| 437 | + $values['registration'] = $line[0]; | |
| 438 | + $values['base'] = $line[3]; | |
| 439 | + $values['owner'] = $line[2]; | |
| 440 | + if ($line[1] == '') $values['date_first_reg'] = null; | |
| 441 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); | |
| 442 | + $values['cancel'] = ''; | |
| 443 | + $values['modes'] = $line[7]; | |
| 444 | + $values['icao'] = $line[8]; | |
| 445 | 445 | |
| 446 | 446 |  					} elseif ($country == 'HB') { | 
| 447 | - // TODO : add modeS & reg to aircraft_modes | |
| 448 | - $values['registration'] = $line[0]; | |
| 449 | - $values['base'] = null; | |
| 450 | - $values['owner'] = $line[5]; | |
| 451 | - $values['date_first_reg'] = null; | |
| 452 | - $values['cancel'] = ''; | |
| 453 | - $values['modes'] = $line[4]; | |
| 454 | - $values['icao'] = $line[7]; | |
| 447 | + // TODO : add modeS & reg to aircraft_modes | |
| 448 | + $values['registration'] = $line[0]; | |
| 449 | + $values['base'] = null; | |
| 450 | + $values['owner'] = $line[5]; | |
| 451 | + $values['date_first_reg'] = null; | |
| 452 | + $values['cancel'] = ''; | |
| 453 | + $values['modes'] = $line[4]; | |
| 454 | + $values['icao'] = $line[7]; | |
| 455 | 455 |  					} elseif ($country == 'OK') { | 
| 456 | - // TODO : add modeS & reg to aircraft_modes | |
| 457 | - $values['registration'] = $line[3]; | |
| 458 | - $values['base'] = null; | |
| 459 | - $values['owner'] = $line[5]; | |
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; | |
| 461 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); | |
| 462 | - $values['cancel'] = ''; | |
| 456 | + // TODO : add modeS & reg to aircraft_modes | |
| 457 | + $values['registration'] = $line[3]; | |
| 458 | + $values['base'] = null; | |
| 459 | + $values['owner'] = $line[5]; | |
| 460 | + if ($line[18] == '') $values['date_first_reg'] = null; | |
| 461 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); | |
| 462 | + $values['cancel'] = ''; | |
| 463 | 463 |  					} elseif ($country == 'VH') { | 
| 464 | - // TODO : add modeS & reg to aircraft_modes | |
| 465 | - $values['registration'] = $line[0]; | |
| 466 | - $values['base'] = null; | |
| 467 | - $values['owner'] = $line[12]; | |
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; | |
| 469 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); | |
| 470 | - | |
| 471 | - $values['cancel'] = $line[39]; | |
| 464 | + // TODO : add modeS & reg to aircraft_modes | |
| 465 | + $values['registration'] = $line[0]; | |
| 466 | + $values['base'] = null; | |
| 467 | + $values['owner'] = $line[12]; | |
| 468 | + if ($line[28] == '') $values['date_first_reg'] = null; | |
| 469 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); | |
| 470 | + | |
| 471 | + $values['cancel'] = $line[39]; | |
| 472 | 472 |  					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { | 
| 473 | - $values['registration'] = $line[0]; | |
| 474 | - $values['base'] = null; | |
| 475 | - $values['owner'] = $line[4]; | |
| 476 | - $values['date_first_reg'] = null; | |
| 477 | - $values['cancel'] = ''; | |
| 473 | + $values['registration'] = $line[0]; | |
| 474 | + $values['base'] = null; | |
| 475 | + $values['owner'] = $line[4]; | |
| 476 | + $values['date_first_reg'] = null; | |
| 477 | + $values['cancel'] = ''; | |
| 478 | 478 |  					} elseif ($country == 'CC') { | 
| 479 | - $values['registration'] = $line[0]; | |
| 480 | - $values['base'] = null; | |
| 481 | - $values['owner'] = $line[6]; | |
| 482 | - $values['date_first_reg'] = null; | |
| 483 | - $values['cancel'] = ''; | |
| 479 | + $values['registration'] = $line[0]; | |
| 480 | + $values['base'] = null; | |
| 481 | + $values['owner'] = $line[6]; | |
| 482 | + $values['date_first_reg'] = null; | |
| 483 | + $values['cancel'] = ''; | |
| 484 | 484 |  					} elseif ($country == 'HJ') { | 
| 485 | - $values['registration'] = $line[0]; | |
| 486 | - $values['base'] = null; | |
| 487 | - $values['owner'] = $line[8]; | |
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; | |
| 489 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 490 | - $values['cancel'] = ''; | |
| 485 | + $values['registration'] = $line[0]; | |
| 486 | + $values['base'] = null; | |
| 487 | + $values['owner'] = $line[8]; | |
| 488 | + if ($line[7] == '') $values['date_first_reg'] = null; | |
| 489 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 490 | + $values['cancel'] = ''; | |
| 491 | 491 |  					} elseif ($country == 'PP') { | 
| 492 | - $values['registration'] = $line[0]; | |
| 493 | - $values['base'] = null; | |
| 494 | - $values['owner'] = $line[4]; | |
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; | |
| 496 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 497 | - $values['cancel'] = $line[7]; | |
| 492 | + $values['registration'] = $line[0]; | |
| 493 | + $values['base'] = null; | |
| 494 | + $values['owner'] = $line[4]; | |
| 495 | + if ($line[6] == '') $values['date_first_reg'] = null; | |
| 496 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 497 | + $values['cancel'] = $line[7]; | |
| 498 | 498 |  					} elseif ($country == 'E7') { | 
| 499 | - $values['registration'] = $line[0]; | |
| 500 | - $values['base'] = null; | |
| 501 | - $values['owner'] = $line[4]; | |
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; | |
| 503 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 504 | - $values['cancel'] = ''; | |
| 499 | + $values['registration'] = $line[0]; | |
| 500 | + $values['base'] = null; | |
| 501 | + $values['owner'] = $line[4]; | |
| 502 | + if ($line[5] == '') $values['date_first_reg'] = null; | |
| 503 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 504 | + $values['cancel'] = ''; | |
| 505 | 505 |  					} elseif ($country == '8Q') { | 
| 506 | - $values['registration'] = $line[0]; | |
| 507 | - $values['base'] = null; | |
| 508 | - $values['owner'] = $line[3]; | |
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; | |
| 510 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 511 | - $values['cancel'] = ''; | |
| 506 | + $values['registration'] = $line[0]; | |
| 507 | + $values['base'] = null; | |
| 508 | + $values['owner'] = $line[3]; | |
| 509 | + if ($line[7] == '') $values['date_first_reg'] = null; | |
| 510 | +						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 511 | + $values['cancel'] = ''; | |
| 512 | 512 |  					} elseif ($country == 'ZK') { | 
| 513 | - $values['registration'] = $line[0]; | |
| 514 | - $values['base'] = null; | |
| 515 | - $values['owner'] = $line[3]; | |
| 516 | - $values['date_first_reg'] = null; | |
| 517 | - $values['cancel'] = ''; | |
| 518 | - $values['modes'] = $line[5]; | |
| 519 | - $values['icao'] = $line[9]; | |
| 513 | + $values['registration'] = $line[0]; | |
| 514 | + $values['base'] = null; | |
| 515 | + $values['owner'] = $line[3]; | |
| 516 | + $values['date_first_reg'] = null; | |
| 517 | + $values['cancel'] = ''; | |
| 518 | + $values['modes'] = $line[5]; | |
| 519 | + $values['icao'] = $line[9]; | |
| 520 | 520 |  					} elseif ($country == 'M') { | 
| 521 | - $values['registration'] = $line[0]; | |
| 522 | - $values['base'] = null; | |
| 523 | - $values['owner'] = $line[6]; | |
| 524 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 525 | -					    $values['cancel'] = date("Y-m-d",strtotime($line[8])); | |
| 526 | - $values['modes'] = $line[4]; | |
| 527 | - $values['icao'] = $line[10]; | |
| 521 | + $values['registration'] = $line[0]; | |
| 522 | + $values['base'] = null; | |
| 523 | + $values['owner'] = $line[6]; | |
| 524 | +								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 525 | +						$values['cancel'] = date("Y-m-d",strtotime($line[8])); | |
| 526 | + $values['modes'] = $line[4]; | |
| 527 | + $values['icao'] = $line[10]; | |
| 528 | 528 |  					} elseif ($country == 'OY') { | 
| 529 | - $values['registration'] = $line[0]; | |
| 530 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); | |
| 531 | - $values['modes'] = $line[5]; | |
| 532 | - $values['icao'] = $line[6]; | |
| 529 | + $values['registration'] = $line[0]; | |
| 530 | +								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); | |
| 531 | + $values['modes'] = $line[5]; | |
| 532 | + $values['icao'] = $line[6]; | |
| 533 | 533 |  					} elseif ($country == 'PH') { | 
| 534 | - $values['registration'] = $line[0]; | |
| 535 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); | |
| 536 | - $values['modes'] = $line[4]; | |
| 537 | - $values['icao'] = $line[5]; | |
| 534 | + $values['registration'] = $line[0]; | |
| 535 | +								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); | |
| 536 | + $values['modes'] = $line[4]; | |
| 537 | + $values['icao'] = $line[5]; | |
| 538 | 538 |  					} elseif ($country == 'OM' || $country == 'TF') { | 
| 539 | - $values['registration'] = $line[0]; | |
| 540 | - $values['base'] = null; | |
| 541 | - $values['owner'] = $line[3]; | |
| 542 | - $values['date_first_reg'] = null; | |
| 543 | - $values['cancel'] = ''; | |
| 539 | + $values['registration'] = $line[0]; | |
| 540 | + $values['base'] = null; | |
| 541 | + $values['owner'] = $line[3]; | |
| 542 | + $values['date_first_reg'] = null; | |
| 543 | + $values['cancel'] = ''; | |
| 544 | 544 | } | 
| 545 | 545 |  					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { | 
| 546 | 546 |  						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); | 
| @@ -667,20 +667,20 @@ discard block | ||
| 667 | 667 |  		try { | 
| 668 | 668 | $Connection = new Connection(); | 
| 669 | 669 | $sth = $Connection->db->prepare($query); | 
| 670 | - $sth->execute(); | |
| 671 | -                } catch(PDOException $e) { | |
| 672 | - return "error : ".$e->getMessage(); | |
| 673 | - } | |
| 670 | + $sth->execute(); | |
| 671 | +				} catch(PDOException $e) { | |
| 672 | + return "error : ".$e->getMessage(); | |
| 673 | + } | |
| 674 | 674 | |
| 675 | 675 | |
| 676 | 676 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; | 
| 677 | 677 |  		try { | 
| 678 | 678 | $Connection = new Connection(); | 
| 679 | 679 | $sth = $Connection->db->prepare($query); | 
| 680 | - $sth->execute(); | |
| 681 | -                } catch(PDOException $e) { | |
| 682 | - return "error : ".$e->getMessage(); | |
| 683 | - } | |
| 680 | + $sth->execute(); | |
| 681 | +				} catch(PDOException $e) { | |
| 682 | + return "error : ".$e->getMessage(); | |
| 683 | + } | |
| 684 | 684 | |
| 685 | 685 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) | 
| 686 | 686 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; | 
| @@ -746,10 +746,10 @@ discard block | ||
| 746 | 746 |  		try { | 
| 747 | 747 | $Connection = new Connection(); | 
| 748 | 748 | $sth = $Connection->db->prepare($query); | 
| 749 | - $sth->execute(); | |
| 750 | -                } catch(PDOException $e) { | |
| 751 | - return "error : ".$e->getMessage(); | |
| 752 | - } | |
| 749 | + $sth->execute(); | |
| 750 | +				} catch(PDOException $e) { | |
| 751 | + return "error : ".$e->getMessage(); | |
| 752 | + } | |
| 753 | 753 | |
| 754 | 754 | |
| 755 | 755 | if ($globalDebug) echo "Insert Not available Airport...\n"; | 
| @@ -759,10 +759,10 @@ discard block | ||
| 759 | 759 |  		try { | 
| 760 | 760 | $Connection = new Connection(); | 
| 761 | 761 | $sth = $Connection->db->prepare($query); | 
| 762 | - $sth->execute($query_values); | |
| 763 | -                } catch(PDOException $e) { | |
| 764 | - return "error : ".$e->getMessage(); | |
| 765 | - } | |
| 762 | + $sth->execute($query_values); | |
| 763 | +				} catch(PDOException $e) { | |
| 764 | + return "error : ".$e->getMessage(); | |
| 765 | + } | |
| 766 | 766 | $i++; | 
| 767 | 767 | /* | 
| 768 | 768 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; | 
| @@ -876,7 +876,7 @@ discard block | ||
| 876 | 876 | |
| 877 | 877 | |
| 878 | 878 | |
| 879 | - return "success"; | |
| 879 | + return "success"; | |
| 880 | 880 | } | 
| 881 | 881 | |
| 882 | 882 |  	public static function translation() { | 
| @@ -892,10 +892,10 @@ discard block | ||
| 892 | 892 |  		try { | 
| 893 | 893 | $Connection = new Connection(); | 
| 894 | 894 | $sth = $Connection->db->prepare($query); | 
| 895 | -                        $sth->execute(array(':source' => 'translation.csv')); | |
| 896 | -                } catch(PDOException $e) { | |
| 897 | - return "error : ".$e->getMessage(); | |
| 898 | - } | |
| 895 | +						$sth->execute(array(':source' => 'translation.csv')); | |
| 896 | +				} catch(PDOException $e) { | |
| 897 | + return "error : ".$e->getMessage(); | |
| 898 | + } | |
| 899 | 899 | |
| 900 | 900 | |
| 901 | 901 | //update_db::unzip($out_file); | 
| @@ -914,21 +914,21 @@ discard block | ||
| 914 | 914 | $data = $row; | 
| 915 | 915 | $operator = $data[2]; | 
| 916 | 916 |  					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { | 
| 917 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); | |
| 918 | - //echo substr($operator, 0, 2)."\n";; | |
| 919 | -                                                if (count($airline_array) > 0) { | |
| 917 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); | |
| 918 | + //echo substr($operator, 0, 2)."\n";; | |
| 919 | +												if (count($airline_array) > 0) { | |
| 920 | 920 | //print_r($airline_array); | 
| 921 | 921 | $operator = $airline_array[0]['icao'].substr($operator,2); | 
| 922 | - } | |
| 923 | - } | |
| 922 | + } | |
| 923 | + } | |
| 924 | 924 | |
| 925 | 925 | $operator_correct = $data[3]; | 
| 926 | 926 |  					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { | 
| 927 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); | |
| 928 | -                                                if (count($airline_array) > 0) { | |
| 929 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); | |
| 930 | - } | |
| 931 | - } | |
| 927 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); | |
| 928 | +												if (count($airline_array) > 0) { | |
| 929 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); | |
| 930 | + } | |
| 931 | + } | |
| 932 | 932 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; | 
| 933 | 933 |  					try { | 
| 934 | 934 | $sth = $Connection->db->prepare($query); | 
| @@ -942,7 +942,7 @@ discard block | ||
| 942 | 942 | //$Connection->db->commit(); | 
| 943 | 943 | } | 
| 944 | 944 | return ''; | 
| 945 | - } | |
| 945 | + } | |
| 946 | 946 | |
| 947 | 947 |  	public static function translation_fam() { | 
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| @@ -952,10 +952,10 @@ discard block | ||
| 952 | 952 |  		try { | 
| 953 | 953 | $Connection = new Connection(); | 
| 954 | 954 | $sth = $Connection->db->prepare($query); | 
| 955 | -                        $sth->execute(array(':source' => 'website_fam')); | |
| 956 | -                } catch(PDOException $e) { | |
| 957 | - return "error : ".$e->getMessage(); | |
| 958 | - } | |
| 955 | +						$sth->execute(array(':source' => 'website_fam')); | |
| 956 | +				} catch(PDOException $e) { | |
| 957 | + return "error : ".$e->getMessage(); | |
| 958 | + } | |
| 959 | 959 | |
| 960 | 960 | |
| 961 | 961 | //update_db::unzip($out_file); | 
| @@ -984,7 +984,7 @@ discard block | ||
| 984 | 984 | //$Connection->db->commit(); | 
| 985 | 985 | } | 
| 986 | 986 | return ''; | 
| 987 | - } | |
| 987 | + } | |
| 988 | 988 | |
| 989 | 989 | /* | 
| 990 | 990 | * This function use FAA public data. | 
| @@ -996,19 +996,19 @@ discard block | ||
| 996 | 996 |  		try { | 
| 997 | 997 | $Connection = new Connection(); | 
| 998 | 998 | $sth = $Connection->db->prepare($query); | 
| 999 | -                        $sth->execute(array(':source' => 'website_faa')); | |
| 1000 | -                } catch(PDOException $e) { | |
| 1001 | - return "error : ".$e->getMessage(); | |
| 1002 | - } | |
| 999 | +						$sth->execute(array(':source' => 'website_faa')); | |
| 1000 | +				} catch(PDOException $e) { | |
| 1001 | + return "error : ".$e->getMessage(); | |
| 1002 | + } | |
| 1003 | 1003 | |
| 1004 | 1004 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; | 
| 1005 | 1005 |  		try { | 
| 1006 | 1006 | $Connection = new Connection(); | 
| 1007 | 1007 | $sth = $Connection->db->prepare($query); | 
| 1008 | -                        $sth->execute(array(':source' => 'website_faa')); | |
| 1009 | -                } catch(PDOException $e) { | |
| 1010 | - return "error : ".$e->getMessage(); | |
| 1011 | - } | |
| 1008 | +						$sth->execute(array(':source' => 'website_faa')); | |
| 1009 | +				} catch(PDOException $e) { | |
| 1010 | + return "error : ".$e->getMessage(); | |
| 1011 | + } | |
| 1012 | 1012 | |
| 1013 | 1013 | $delimiter = ","; | 
| 1014 | 1014 | $mfr = array(); | 
| @@ -1084,17 +1084,17 @@ discard block | ||
| 1084 | 1084 | } | 
| 1085 | 1085 | print_r($mfr); | 
| 1086 | 1086 | return ''; | 
| 1087 | - } | |
| 1087 | + } | |
| 1088 | 1088 |  	public static function modes_fam() { | 
| 1089 | 1089 | global $tmp_dir, $globalTransaction; | 
| 1090 | 1090 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; | 
| 1091 | 1091 |  		try { | 
| 1092 | 1092 | $Connection = new Connection(); | 
| 1093 | 1093 | $sth = $Connection->db->prepare($query); | 
| 1094 | -                        $sth->execute(array(':source' => 'website_fam')); | |
| 1095 | -                } catch(PDOException $e) { | |
| 1096 | - return "error : ".$e->getMessage(); | |
| 1097 | - } | |
| 1094 | +						$sth->execute(array(':source' => 'website_fam')); | |
| 1095 | +				} catch(PDOException $e) { | |
| 1096 | + return "error : ".$e->getMessage(); | |
| 1097 | + } | |
| 1098 | 1098 | |
| 1099 | 1099 | |
| 1100 | 1100 | //update_db::unzip($out_file); | 
| @@ -1124,7 +1124,7 @@ discard block | ||
| 1124 | 1124 | if ($globalTransaction) $Connection->db->commit(); | 
| 1125 | 1125 | } | 
| 1126 | 1126 | return ''; | 
| 1127 | - } | |
| 1127 | + } | |
| 1128 | 1128 | |
| 1129 | 1129 |  	public static function owner_fam() { | 
| 1130 | 1130 | global $tmp_dir, $globalTransaction; | 
| @@ -1132,10 +1132,10 @@ discard block | ||
| 1132 | 1132 |  		try { | 
| 1133 | 1133 | $Connection = new Connection(); | 
| 1134 | 1134 | $sth = $Connection->db->prepare($query); | 
| 1135 | -                        $sth->execute(array(':source' => 'website_fam')); | |
| 1136 | -                } catch(PDOException $e) { | |
| 1137 | - return "error : ".$e->getMessage(); | |
| 1138 | - } | |
| 1135 | +						$sth->execute(array(':source' => 'website_fam')); | |
| 1136 | +				} catch(PDOException $e) { | |
| 1137 | + return "error : ".$e->getMessage(); | |
| 1138 | + } | |
| 1139 | 1139 | |
| 1140 | 1140 | $delimiter = "\t"; | 
| 1141 | 1141 | $Connection = new Connection(); | 
| @@ -1161,7 +1161,7 @@ discard block | ||
| 1161 | 1161 | if ($globalTransaction) $Connection->db->commit(); | 
| 1162 | 1162 | } | 
| 1163 | 1163 | return ''; | 
| 1164 | - } | |
| 1164 | + } | |
| 1165 | 1165 | |
| 1166 | 1166 |  	public static function routes_fam() { | 
| 1167 | 1167 | global $tmp_dir, $globalTransaction; | 
| @@ -1169,10 +1169,10 @@ discard block | ||
| 1169 | 1169 |  		try { | 
| 1170 | 1170 | $Connection = new Connection(); | 
| 1171 | 1171 | $sth = $Connection->db->prepare($query); | 
| 1172 | -                        $sth->execute(array(':source' => 'website_fam')); | |
| 1173 | -                } catch(PDOException $e) { | |
| 1174 | - return "error : ".$e->getMessage(); | |
| 1175 | - } | |
| 1172 | +						$sth->execute(array(':source' => 'website_fam')); | |
| 1173 | +				} catch(PDOException $e) { | |
| 1174 | + return "error : ".$e->getMessage(); | |
| 1175 | + } | |
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | 1178 | //update_db::unzip($out_file); | 
| @@ -1201,7 +1201,7 @@ discard block | ||
| 1201 | 1201 | if ($globalTransaction) $Connection->db->commit(); | 
| 1202 | 1202 | } | 
| 1203 | 1203 | return ''; | 
| 1204 | - } | |
| 1204 | + } | |
| 1205 | 1205 | |
| 1206 | 1206 |  	public static function marine_identity_fam() { | 
| 1207 | 1207 | global $tmp_dir, $globalTransaction; | 
| @@ -1209,10 +1209,10 @@ discard block | ||
| 1209 | 1209 |  		try { | 
| 1210 | 1210 | $Connection = new Connection(); | 
| 1211 | 1211 | $sth = $Connection->db->prepare($query); | 
| 1212 | - $sth->execute(); | |
| 1213 | -                } catch(PDOException $e) { | |
| 1214 | - return "error : ".$e->getMessage(); | |
| 1215 | - } | |
| 1212 | + $sth->execute(); | |
| 1213 | +				} catch(PDOException $e) { | |
| 1214 | + return "error : ".$e->getMessage(); | |
| 1215 | + } | |
| 1216 | 1216 | |
| 1217 | 1217 | |
| 1218 | 1218 | //update_db::unzip($out_file); | 
| @@ -1242,7 +1242,7 @@ discard block | ||
| 1242 | 1242 | if ($globalTransaction) $Connection->db->commit(); | 
| 1243 | 1243 | } | 
| 1244 | 1244 | return ''; | 
| 1245 | - } | |
| 1245 | + } | |
| 1246 | 1246 | |
| 1247 | 1247 |  	public static function banned_fam() { | 
| 1248 | 1248 | global $tmp_dir, $globalTransaction; | 
| @@ -1276,7 +1276,7 @@ discard block | ||
| 1276 | 1276 | if ($globalTransaction) $Connection->db->commit(); | 
| 1277 | 1277 | } | 
| 1278 | 1278 | return ''; | 
| 1279 | - } | |
| 1279 | + } | |
| 1280 | 1280 | |
| 1281 | 1281 |  	public static function tle($filename,$tletype) { | 
| 1282 | 1282 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| @@ -1287,10 +1287,10 @@ discard block | ||
| 1287 | 1287 |  		try { | 
| 1288 | 1288 | $Connection = new Connection(); | 
| 1289 | 1289 | $sth = $Connection->db->prepare($query); | 
| 1290 | -                        $sth->execute(array(':source' => $filename)); | |
| 1291 | -                } catch(PDOException $e) { | |
| 1292 | - return "error : ".$e->getMessage(); | |
| 1293 | - } | |
| 1290 | +						$sth->execute(array(':source' => $filename)); | |
| 1291 | +				} catch(PDOException $e) { | |
| 1292 | + return "error : ".$e->getMessage(); | |
| 1293 | + } | |
| 1294 | 1294 | |
| 1295 | 1295 | $Connection = new Connection(); | 
| 1296 | 1296 | if (($handle = fopen($filename, 'r')) !== FALSE) | 
| @@ -1325,54 +1325,54 @@ discard block | ||
| 1325 | 1325 | //$Connection->db->commit(); | 
| 1326 | 1326 | } | 
| 1327 | 1327 | return ''; | 
| 1328 | - } | |
| 1328 | + } | |
| 1329 | 1329 | |
| 1330 | 1330 | /** | 
| 1331 | - * Convert a HTML table to an array | |
| 1332 | - * @param String $data HTML page | |
| 1333 | - * @return Array array of the tables in HTML page | |
| 1334 | - */ | |
| 1335 | -        private static function table2array($data) { | |
| 1336 | - $html = str_get_html($data); | |
| 1337 | - $tabledata=array(); | |
| 1338 | -                foreach($html->find('tr') as $element) | |
| 1339 | -                { | |
| 1340 | - $td = array(); | |
| 1341 | -                        foreach( $element->find('th') as $row) | |
| 1342 | -                        { | |
| 1343 | - $td [] = trim($row->plaintext); | |
| 1344 | - } | |
| 1345 | - $td=array_filter($td); | |
| 1346 | - $tabledata[] = $td; | |
| 1347 | - | |
| 1348 | - $td = array(); | |
| 1349 | - $tdi = array(); | |
| 1350 | -                        foreach( $element->find('td') as $row) | |
| 1351 | -                        { | |
| 1352 | - $td [] = trim($row->plaintext); | |
| 1353 | - $tdi [] = trim($row->innertext); | |
| 1354 | - } | |
| 1355 | - $td=array_filter($td); | |
| 1356 | - $tdi=array_filter($tdi); | |
| 1357 | - // $tabledata[]=array_merge($td,$tdi); | |
| 1358 | - $tabledata[]=$td; | |
| 1359 | - } | |
| 1360 | - return(array_filter($tabledata)); | |
| 1361 | - } | |
| 1362 | - | |
| 1363 | - /** | |
| 1364 | - * Get data from form result | |
| 1365 | - * @param String $url form URL | |
| 1366 | - * @return String the result | |
| 1367 | - */ | |
| 1368 | -        private static function getData($url) { | |
| 1369 | - $ch = curl_init(); | |
| 1370 | - curl_setopt($ch, CURLOPT_URL, $url); | |
| 1371 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| 1372 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
| 1373 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); | |
| 1374 | - return curl_exec($ch); | |
| 1375 | - } | |
| 1331 | + * Convert a HTML table to an array | |
| 1332 | + * @param String $data HTML page | |
| 1333 | + * @return Array array of the tables in HTML page | |
| 1334 | + */ | |
| 1335 | +		private static function table2array($data) { | |
| 1336 | + $html = str_get_html($data); | |
| 1337 | + $tabledata=array(); | |
| 1338 | +				foreach($html->find('tr') as $element) | |
| 1339 | +				{ | |
| 1340 | + $td = array(); | |
| 1341 | +						foreach( $element->find('th') as $row) | |
| 1342 | +						{ | |
| 1343 | + $td [] = trim($row->plaintext); | |
| 1344 | + } | |
| 1345 | + $td=array_filter($td); | |
| 1346 | + $tabledata[] = $td; | |
| 1347 | + | |
| 1348 | + $td = array(); | |
| 1349 | + $tdi = array(); | |
| 1350 | +						foreach( $element->find('td') as $row) | |
| 1351 | +						{ | |
| 1352 | + $td [] = trim($row->plaintext); | |
| 1353 | + $tdi [] = trim($row->innertext); | |
| 1354 | + } | |
| 1355 | + $td=array_filter($td); | |
| 1356 | + $tdi=array_filter($tdi); | |
| 1357 | + // $tabledata[]=array_merge($td,$tdi); | |
| 1358 | + $tabledata[]=$td; | |
| 1359 | + } | |
| 1360 | + return(array_filter($tabledata)); | |
| 1361 | + } | |
| 1362 | + | |
| 1363 | + /** | |
| 1364 | + * Get data from form result | |
| 1365 | + * @param String $url form URL | |
| 1366 | + * @return String the result | |
| 1367 | + */ | |
| 1368 | +		private static function getData($url) { | |
| 1369 | + $ch = curl_init(); | |
| 1370 | + curl_setopt($ch, CURLOPT_URL, $url); | |
| 1371 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| 1372 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
| 1373 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); | |
| 1374 | + return curl_exec($ch); | |
| 1375 | + } | |
| 1376 | 1376 | /* | 
| 1377 | 1377 |  	public static function waypoints() { | 
| 1378 | 1378 |  		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); | 
| @@ -1455,7 +1455,7 @@ discard block | ||
| 1455 | 1455 | if ($globalTransaction) $Connection->db->commit(); | 
| 1456 | 1456 | } | 
| 1457 | 1457 | return ''; | 
| 1458 | - } | |
| 1458 | + } | |
| 1459 | 1459 | |
| 1460 | 1460 |  	public static function ivao_airlines($filename) { | 
| 1461 | 1461 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| @@ -1465,10 +1465,10 @@ discard block | ||
| 1465 | 1465 |  		try { | 
| 1466 | 1466 | $Connection = new Connection(); | 
| 1467 | 1467 | $sth = $Connection->db->prepare($query); | 
| 1468 | - $sth->execute(); | |
| 1469 | -                } catch(PDOException $e) { | |
| 1470 | - return "error : ".$e->getMessage(); | |
| 1471 | - } | |
| 1468 | + $sth->execute(); | |
| 1469 | +				} catch(PDOException $e) { | |
| 1470 | + return "error : ".$e->getMessage(); | |
| 1471 | + } | |
| 1472 | 1472 | |
| 1473 | 1473 | $header = NULL; | 
| 1474 | 1474 | $delimiter = ':'; | 
| @@ -1492,7 +1492,7 @@ discard block | ||
| 1492 | 1492 | if ($globalTransaction) $Connection->db->commit(); | 
| 1493 | 1493 | } | 
| 1494 | 1494 | return ''; | 
| 1495 | - } | |
| 1495 | + } | |
| 1496 | 1496 | |
| 1497 | 1497 |  	public static function update_airspace() { | 
| 1498 | 1498 | global $tmp_dir, $globalDBdriver; | 
| @@ -1502,11 +1502,11 @@ discard block | ||
| 1502 | 1502 | $query = 'DROP TABLE airspace'; | 
| 1503 | 1503 |  			try { | 
| 1504 | 1504 | $sth = $Connection->db->prepare($query); | 
| 1505 | - $sth->execute(); | |
| 1506 | -	                } catch(PDOException $e) { | |
| 1505 | + $sth->execute(); | |
| 1506 | +					} catch(PDOException $e) { | |
| 1507 | 1507 | return "error : ".$e->getMessage(); | 
| 1508 | - } | |
| 1509 | - } | |
| 1508 | + } | |
| 1509 | + } | |
| 1510 | 1510 | |
| 1511 | 1511 | |
| 1512 | 1512 |  		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); | 
| @@ -1561,10 +1561,10 @@ discard block | ||
| 1561 | 1561 | $query = 'DROP TABLE countries'; | 
| 1562 | 1562 |  			try { | 
| 1563 | 1563 | $sth = $Connection->db->prepare($query); | 
| 1564 | - $sth->execute(); | |
| 1565 | -	                } catch(PDOException $e) { | |
| 1566 | - echo "error : ".$e->getMessage(); | |
| 1567 | - } | |
| 1564 | + $sth->execute(); | |
| 1565 | +					} catch(PDOException $e) { | |
| 1566 | + echo "error : ".$e->getMessage(); | |
| 1567 | + } | |
| 1568 | 1568 | } | 
| 1569 | 1569 |  		if ($globalDBdriver == 'mysql') { | 
| 1570 | 1570 |  			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); | 
| @@ -2093,11 +2093,11 @@ discard block | ||
| 2093 | 2093 | $query = 'DROP TABLE airspace'; | 
| 2094 | 2094 |  						try { | 
| 2095 | 2095 | $sth = $Connection->db->prepare($query); | 
| 2096 | - $sth->execute(); | |
| 2097 | -			            		} catch(PDOException $e) { | |
| 2096 | + $sth->execute(); | |
| 2097 | +								} catch(PDOException $e) { | |
| 2098 | 2098 | return "error : ".$e->getMessage(); | 
| 2099 | - } | |
| 2100 | - } | |
| 2099 | + } | |
| 2100 | + } | |
| 2101 | 2101 | $error = create_db::import_file($tmp_dir.'airspace.sql'); | 
| 2102 | 2102 | update_db::insert_airspace_version($airspace_md5); | 
| 2103 | 2103 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; | 
| @@ -2254,12 +2254,12 @@ discard block | ||
| 2254 | 2254 | echo $data; | 
| 2255 | 2255 | */ | 
| 2256 | 2256 |  		if (file_exists($tmp_dir.'aircrafts.html')) { | 
| 2257 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); | |
| 2258 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); | |
| 2259 | - $result = fread($fh,100000000); | |
| 2260 | - //echo $result; | |
| 2261 | - //var_dump(str_get_html($result)); | |
| 2262 | - //print_r(self::table2array($result)); | |
| 2257 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); | |
| 2258 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); | |
| 2259 | + $result = fread($fh,100000000); | |
| 2260 | + //echo $result; | |
| 2261 | + //var_dump(str_get_html($result)); | |
| 2262 | + //print_r(self::table2array($result)); | |
| 2263 | 2263 | } | 
| 2264 | 2264 | |
| 2265 | 2265 | } | 
| @@ -2273,10 +2273,10 @@ discard block | ||
| 2273 | 2273 |  		try { | 
| 2274 | 2274 | $Connection = new Connection(); | 
| 2275 | 2275 | $sth = $Connection->db->prepare($query); | 
| 2276 | - $sth->execute(); | |
| 2277 | -                } catch(PDOException $e) { | |
| 2278 | - return "error : ".$e->getMessage(); | |
| 2279 | - } | |
| 2276 | + $sth->execute(); | |
| 2277 | +				} catch(PDOException $e) { | |
| 2278 | + return "error : ".$e->getMessage(); | |
| 2279 | + } | |
| 2280 | 2280 | |
| 2281 | 2281 | $error = ''; | 
| 2282 | 2282 | if ($globalDebug) echo "Notam : Download..."; | 
| @@ -2332,8 +2332,8 @@ discard block | ||
| 2332 | 2332 |  					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); | 
| 2333 | 2333 | $data['permanent'] = 0; | 
| 2334 | 2334 |  				} else { | 
| 2335 | - $data['date_end'] = NULL; | |
| 2336 | - $data['permanent'] = 1; | |
| 2335 | + $data['date_end'] = NULL; | |
| 2336 | + $data['permanent'] = 1; | |
| 2337 | 2337 | } | 
| 2338 | 2338 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; | 
| 2339 | 2339 | $NOTAM = new NOTAM(); | 
| @@ -2407,13 +2407,13 @@ discard block | ||
| 2407 | 2407 |  		try { | 
| 2408 | 2408 | $Connection = new Connection(); | 
| 2409 | 2409 | $sth = $Connection->db->prepare($query); | 
| 2410 | - $sth->execute(); | |
| 2411 | -                } catch(PDOException $e) { | |
| 2412 | - return "error : ".$e->getMessage(); | |
| 2413 | - } | |
| 2414 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2415 | - if ($row['nb'] > 0) return false; | |
| 2416 | - else return true; | |
| 2410 | + $sth->execute(); | |
| 2411 | +				} catch(PDOException $e) { | |
| 2412 | + return "error : ".$e->getMessage(); | |
| 2413 | + } | |
| 2414 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2415 | + if ($row['nb'] > 0) return false; | |
| 2416 | + else return true; | |
| 2417 | 2417 | } | 
| 2418 | 2418 | |
| 2419 | 2419 |  	public static function insert_last_update() { | 
| @@ -2422,10 +2422,10 @@ discard block | ||
| 2422 | 2422 |  		try { | 
| 2423 | 2423 | $Connection = new Connection(); | 
| 2424 | 2424 | $sth = $Connection->db->prepare($query); | 
| 2425 | - $sth->execute(); | |
| 2426 | -                } catch(PDOException $e) { | |
| 2427 | - return "error : ".$e->getMessage(); | |
| 2428 | - } | |
| 2425 | + $sth->execute(); | |
| 2426 | +				} catch(PDOException $e) { | |
| 2427 | + return "error : ".$e->getMessage(); | |
| 2428 | + } | |
| 2429 | 2429 | } | 
| 2430 | 2430 | |
| 2431 | 2431 |  	public static function check_airspace_version($version) { | 
| @@ -2433,13 +2433,13 @@ discard block | ||
| 2433 | 2433 |  		try { | 
| 2434 | 2434 | $Connection = new Connection(); | 
| 2435 | 2435 | $sth = $Connection->db->prepare($query); | 
| 2436 | -                        $sth->execute(array(':version' => $version)); | |
| 2437 | -                } catch(PDOException $e) { | |
| 2438 | - return "error : ".$e->getMessage(); | |
| 2439 | - } | |
| 2440 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2441 | - if ($row['nb'] > 0) return true; | |
| 2442 | - else return false; | |
| 2436 | +						$sth->execute(array(':version' => $version)); | |
| 2437 | +				} catch(PDOException $e) { | |
| 2438 | + return "error : ".$e->getMessage(); | |
| 2439 | + } | |
| 2440 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2441 | + if ($row['nb'] > 0) return true; | |
| 2442 | + else return false; | |
| 2443 | 2443 | } | 
| 2444 | 2444 | |
| 2445 | 2445 |  	public static function check_marine_identity_version($version) { | 
| @@ -2447,13 +2447,13 @@ discard block | ||
| 2447 | 2447 |  		try { | 
| 2448 | 2448 | $Connection = new Connection(); | 
| 2449 | 2449 | $sth = $Connection->db->prepare($query); | 
| 2450 | -                        $sth->execute(array(':version' => $version)); | |
| 2451 | -                } catch(PDOException $e) { | |
| 2452 | - return "error : ".$e->getMessage(); | |
| 2453 | - } | |
| 2454 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2455 | - if ($row['nb'] > 0) return true; | |
| 2456 | - else return false; | |
| 2450 | +						$sth->execute(array(':version' => $version)); | |
| 2451 | +				} catch(PDOException $e) { | |
| 2452 | + return "error : ".$e->getMessage(); | |
| 2453 | + } | |
| 2454 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2455 | + if ($row['nb'] > 0) return true; | |
| 2456 | + else return false; | |
| 2457 | 2457 | } | 
| 2458 | 2458 | |
| 2459 | 2459 | |
| @@ -2463,10 +2463,10 @@ discard block | ||
| 2463 | 2463 |  		try { | 
| 2464 | 2464 | $Connection = new Connection(); | 
| 2465 | 2465 | $sth = $Connection->db->prepare($query); | 
| 2466 | -                        $sth->execute(array(':version' => $version)); | |
| 2467 | -                } catch(PDOException $e) { | |
| 2468 | - return "error : ".$e->getMessage(); | |
| 2469 | - } | |
| 2466 | +						$sth->execute(array(':version' => $version)); | |
| 2467 | +				} catch(PDOException $e) { | |
| 2468 | + return "error : ".$e->getMessage(); | |
| 2469 | + } | |
| 2470 | 2470 | } | 
| 2471 | 2471 | |
| 2472 | 2472 |  	public static function insert_marine_identity_version($version) { | 
| @@ -2475,10 +2475,10 @@ discard block | ||
| 2475 | 2475 |  		try { | 
| 2476 | 2476 | $Connection = new Connection(); | 
| 2477 | 2477 | $sth = $Connection->db->prepare($query); | 
| 2478 | -                        $sth->execute(array(':version' => $version)); | |
| 2479 | -                } catch(PDOException $e) { | |
| 2480 | - return "error : ".$e->getMessage(); | |
| 2481 | - } | |
| 2478 | +						$sth->execute(array(':version' => $version)); | |
| 2479 | +				} catch(PDOException $e) { | |
| 2480 | + return "error : ".$e->getMessage(); | |
| 2481 | + } | |
| 2482 | 2482 | } | 
| 2483 | 2483 | |
| 2484 | 2484 |  	public static function check_last_notam_update() { | 
| @@ -2491,13 +2491,13 @@ discard block | ||
| 2491 | 2491 |  		try { | 
| 2492 | 2492 | $Connection = new Connection(); | 
| 2493 | 2493 | $sth = $Connection->db->prepare($query); | 
| 2494 | - $sth->execute(); | |
| 2495 | -                } catch(PDOException $e) { | |
| 2496 | - return "error : ".$e->getMessage(); | |
| 2497 | - } | |
| 2498 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2499 | - if ($row['nb'] > 0) return false; | |
| 2500 | - else return true; | |
| 2494 | + $sth->execute(); | |
| 2495 | +				} catch(PDOException $e) { | |
| 2496 | + return "error : ".$e->getMessage(); | |
| 2497 | + } | |
| 2498 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2499 | + if ($row['nb'] > 0) return false; | |
| 2500 | + else return true; | |
| 2501 | 2501 | } | 
| 2502 | 2502 | |
| 2503 | 2503 |  	public static function insert_last_notam_update() { | 
| @@ -2506,10 +2506,10 @@ discard block | ||
| 2506 | 2506 |  		try { | 
| 2507 | 2507 | $Connection = new Connection(); | 
| 2508 | 2508 | $sth = $Connection->db->prepare($query); | 
| 2509 | - $sth->execute(); | |
| 2510 | -                } catch(PDOException $e) { | |
| 2511 | - return "error : ".$e->getMessage(); | |
| 2512 | - } | |
| 2509 | + $sth->execute(); | |
| 2510 | +				} catch(PDOException $e) { | |
| 2511 | + return "error : ".$e->getMessage(); | |
| 2512 | + } | |
| 2513 | 2513 | } | 
| 2514 | 2514 |  	public static function check_last_airspace_update() { | 
| 2515 | 2515 | global $globalDBdriver; | 
| @@ -2521,13 +2521,13 @@ discard block | ||
| 2521 | 2521 |  		try { | 
| 2522 | 2522 | $Connection = new Connection(); | 
| 2523 | 2523 | $sth = $Connection->db->prepare($query); | 
| 2524 | - $sth->execute(); | |
| 2525 | -                } catch(PDOException $e) { | |
| 2526 | - return "error : ".$e->getMessage(); | |
| 2527 | - } | |
| 2528 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2529 | - if ($row['nb'] > 0) return false; | |
| 2530 | - else return true; | |
| 2524 | + $sth->execute(); | |
| 2525 | +				} catch(PDOException $e) { | |
| 2526 | + return "error : ".$e->getMessage(); | |
| 2527 | + } | |
| 2528 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2529 | + if ($row['nb'] > 0) return false; | |
| 2530 | + else return true; | |
| 2531 | 2531 | } | 
| 2532 | 2532 | |
| 2533 | 2533 |  	public static function insert_last_airspace_update() { | 
| @@ -2536,10 +2536,10 @@ discard block | ||
| 2536 | 2536 |  		try { | 
| 2537 | 2537 | $Connection = new Connection(); | 
| 2538 | 2538 | $sth = $Connection->db->prepare($query); | 
| 2539 | - $sth->execute(); | |
| 2540 | -                } catch(PDOException $e) { | |
| 2541 | - return "error : ".$e->getMessage(); | |
| 2542 | - } | |
| 2539 | + $sth->execute(); | |
| 2540 | +				} catch(PDOException $e) { | |
| 2541 | + return "error : ".$e->getMessage(); | |
| 2542 | + } | |
| 2543 | 2543 | } | 
| 2544 | 2544 | |
| 2545 | 2545 |  	public static function check_last_owner_update() { | 
| @@ -2552,13 +2552,13 @@ discard block | ||
| 2552 | 2552 |  		try { | 
| 2553 | 2553 | $Connection = new Connection(); | 
| 2554 | 2554 | $sth = $Connection->db->prepare($query); | 
| 2555 | - $sth->execute(); | |
| 2556 | -                } catch(PDOException $e) { | |
| 2557 | - return "error : ".$e->getMessage(); | |
| 2558 | - } | |
| 2559 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2560 | - if ($row['nb'] > 0) return false; | |
| 2561 | - else return true; | |
| 2555 | + $sth->execute(); | |
| 2556 | +				} catch(PDOException $e) { | |
| 2557 | + return "error : ".$e->getMessage(); | |
| 2558 | + } | |
| 2559 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2560 | + if ($row['nb'] > 0) return false; | |
| 2561 | + else return true; | |
| 2562 | 2562 | } | 
| 2563 | 2563 | |
| 2564 | 2564 |  	public static function insert_last_owner_update() { | 
| @@ -2567,10 +2567,10 @@ discard block | ||
| 2567 | 2567 |  		try { | 
| 2568 | 2568 | $Connection = new Connection(); | 
| 2569 | 2569 | $sth = $Connection->db->prepare($query); | 
| 2570 | - $sth->execute(); | |
| 2571 | -                } catch(PDOException $e) { | |
| 2572 | - return "error : ".$e->getMessage(); | |
| 2573 | - } | |
| 2570 | + $sth->execute(); | |
| 2571 | +				} catch(PDOException $e) { | |
| 2572 | + return "error : ".$e->getMessage(); | |
| 2573 | + } | |
| 2574 | 2574 | } | 
| 2575 | 2575 |  	public static function check_last_schedules_update() { | 
| 2576 | 2576 | global $globalDBdriver; | 
| @@ -2582,13 +2582,13 @@ discard block | ||
| 2582 | 2582 |  		try { | 
| 2583 | 2583 | $Connection = new Connection(); | 
| 2584 | 2584 | $sth = $Connection->db->prepare($query); | 
| 2585 | - $sth->execute(); | |
| 2586 | -                } catch(PDOException $e) { | |
| 2587 | - return "error : ".$e->getMessage(); | |
| 2588 | - } | |
| 2589 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2590 | - if ($row['nb'] > 0) return false; | |
| 2591 | - else return true; | |
| 2585 | + $sth->execute(); | |
| 2586 | +				} catch(PDOException $e) { | |
| 2587 | + return "error : ".$e->getMessage(); | |
| 2588 | + } | |
| 2589 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2590 | + if ($row['nb'] > 0) return false; | |
| 2591 | + else return true; | |
| 2592 | 2592 | } | 
| 2593 | 2593 | |
| 2594 | 2594 |  	public static function insert_last_schedules_update() { | 
| @@ -2597,10 +2597,10 @@ discard block | ||
| 2597 | 2597 |  		try { | 
| 2598 | 2598 | $Connection = new Connection(); | 
| 2599 | 2599 | $sth = $Connection->db->prepare($query); | 
| 2600 | - $sth->execute(); | |
| 2601 | -                } catch(PDOException $e) { | |
| 2602 | - return "error : ".$e->getMessage(); | |
| 2603 | - } | |
| 2600 | + $sth->execute(); | |
| 2601 | +				} catch(PDOException $e) { | |
| 2602 | + return "error : ".$e->getMessage(); | |
| 2603 | + } | |
| 2604 | 2604 | } | 
| 2605 | 2605 |  	public static function check_last_tle_update() { | 
| 2606 | 2606 | global $globalDBdriver; | 
| @@ -2612,13 +2612,13 @@ discard block | ||
| 2612 | 2612 |  		try { | 
| 2613 | 2613 | $Connection = new Connection(); | 
| 2614 | 2614 | $sth = $Connection->db->prepare($query); | 
| 2615 | - $sth->execute(); | |
| 2616 | -                } catch(PDOException $e) { | |
| 2617 | - return "error : ".$e->getMessage(); | |
| 2618 | - } | |
| 2619 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2620 | - if ($row['nb'] > 0) return false; | |
| 2621 | - else return true; | |
| 2615 | + $sth->execute(); | |
| 2616 | +				} catch(PDOException $e) { | |
| 2617 | + return "error : ".$e->getMessage(); | |
| 2618 | + } | |
| 2619 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2620 | + if ($row['nb'] > 0) return false; | |
| 2621 | + else return true; | |
| 2622 | 2622 | } | 
| 2623 | 2623 | |
| 2624 | 2624 |  	public static function insert_last_tle_update() { | 
| @@ -2627,10 +2627,10 @@ discard block | ||
| 2627 | 2627 |  		try { | 
| 2628 | 2628 | $Connection = new Connection(); | 
| 2629 | 2629 | $sth = $Connection->db->prepare($query); | 
| 2630 | - $sth->execute(); | |
| 2631 | -                } catch(PDOException $e) { | |
| 2632 | - return "error : ".$e->getMessage(); | |
| 2633 | - } | |
| 2630 | + $sth->execute(); | |
| 2631 | +				} catch(PDOException $e) { | |
| 2632 | + return "error : ".$e->getMessage(); | |
| 2633 | + } | |
| 2634 | 2634 | } | 
| 2635 | 2635 |  	public static function check_last_marine_identity_update() { | 
| 2636 | 2636 | global $globalDBdriver; | 
| @@ -2642,13 +2642,13 @@ discard block | ||
| 2642 | 2642 |  		try { | 
| 2643 | 2643 | $Connection = new Connection(); | 
| 2644 | 2644 | $sth = $Connection->db->prepare($query); | 
| 2645 | - $sth->execute(); | |
| 2646 | -                } catch(PDOException $e) { | |
| 2647 | - return "error : ".$e->getMessage(); | |
| 2648 | - } | |
| 2649 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2650 | - if ($row['nb'] > 0) return false; | |
| 2651 | - else return true; | |
| 2645 | + $sth->execute(); | |
| 2646 | +				} catch(PDOException $e) { | |
| 2647 | + return "error : ".$e->getMessage(); | |
| 2648 | + } | |
| 2649 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2650 | + if ($row['nb'] > 0) return false; | |
| 2651 | + else return true; | |
| 2652 | 2652 | } | 
| 2653 | 2653 | |
| 2654 | 2654 |  	public static function insert_last_marine_identity_update() { | 
| @@ -2657,10 +2657,10 @@ discard block | ||
| 2657 | 2657 |  		try { | 
| 2658 | 2658 | $Connection = new Connection(); | 
| 2659 | 2659 | $sth = $Connection->db->prepare($query); | 
| 2660 | - $sth->execute(); | |
| 2661 | -                } catch(PDOException $e) { | |
| 2662 | - return "error : ".$e->getMessage(); | |
| 2663 | - } | |
| 2660 | + $sth->execute(); | |
| 2661 | +				} catch(PDOException $e) { | |
| 2662 | + return "error : ".$e->getMessage(); | |
| 2663 | + } | |
| 2664 | 2664 | } | 
| 2665 | 2665 |  	public static function delete_duplicatemodes() { | 
| 2666 | 2666 | global $globalDBdriver; | 
| @@ -2672,10 +2672,10 @@ discard block | ||
| 2672 | 2672 |  		try { | 
| 2673 | 2673 | $Connection = new Connection(); | 
| 2674 | 2674 | $sth = $Connection->db->prepare($query); | 
| 2675 | - $sth->execute(); | |
| 2676 | -                } catch(PDOException $e) { | |
| 2677 | - return "error : ".$e->getMessage(); | |
| 2678 | - } | |
| 2675 | + $sth->execute(); | |
| 2676 | +				} catch(PDOException $e) { | |
| 2677 | + return "error : ".$e->getMessage(); | |
| 2678 | + } | |
| 2679 | 2679 | } | 
| 2680 | 2680 |  	public static function delete_duplicateowner() { | 
| 2681 | 2681 | global $globalDBdriver; | 
| @@ -2687,10 +2687,10 @@ discard block | ||
| 2687 | 2687 |  		try { | 
| 2688 | 2688 | $Connection = new Connection(); | 
| 2689 | 2689 | $sth = $Connection->db->prepare($query); | 
| 2690 | - $sth->execute(); | |
| 2691 | -                } catch(PDOException $e) { | |
| 2692 | - return "error : ".$e->getMessage(); | |
| 2693 | - } | |
| 2690 | + $sth->execute(); | |
| 2691 | +				} catch(PDOException $e) { | |
| 2692 | + return "error : ".$e->getMessage(); | |
| 2693 | + } | |
| 2694 | 2694 | } | 
| 2695 | 2695 | |
| 2696 | 2696 |  	public static function update_all() { | 
| @@ -25,20 +25,20 @@ discard block | ||
| 25 | 25 | fclose($fp); | 
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | -	public static function gunzip($in_file,$out_file_name = '') { | |
| 28 | +	public static function gunzip($in_file, $out_file_name = '') { | |
| 29 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; | 
| 30 | 30 | $buffer_size = 4096; // read 4kb at a time | 
| 31 | 31 |  		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file);  | 
| 32 | 32 |  		if ($in_file != '' && file_exists($in_file)) { | 
| 33 | 33 | // PHP version of Ubuntu use gzopen64 instead of gzopen | 
| 34 | -			if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); | |
| 35 | -			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); | |
| 34 | +			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); | |
| 35 | +			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); | |
| 36 | 36 |  			else { | 
| 37 | 37 | echo 'gzopen not available'; | 
| 38 | 38 | die; | 
| 39 | 39 | } | 
| 40 | 40 | $out_file = fopen($out_file_name, 'wb'); | 
| 41 | -			while(!gzeof($file)) { | |
| 41 | +			while (!gzeof($file)) { | |
| 42 | 42 | fwrite($out_file, gzread($file, $buffer_size)); | 
| 43 | 43 | } | 
| 44 | 44 | fclose($out_file); | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |  		try { | 
| 63 | 63 |  			self::$db_sqlite = new PDO('sqlite:'.$database); | 
| 64 | 64 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 
| 65 | -		} catch(PDOException $e) { | |
| 65 | +		} catch (PDOException $e) { | |
| 66 | 66 | return "error : ".$e->getMessage(); | 
| 67 | 67 | } | 
| 68 | 68 | } | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | //$Connection = new Connection(); | 
| 78 | 78 | $sth = $Connection->db->prepare($query); | 
| 79 | 79 |                          $sth->execute(array(':source' => $database_file)); | 
| 80 | -                } catch(PDOException $e) { | |
| 80 | +                } catch (PDOException $e) { | |
| 81 | 81 | return "error : ".$e->getMessage(); | 
| 82 | 82 | } | 
| 83 | 83 | |
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 |  		try { | 
| 89 | 89 | $sth = update_db::$db_sqlite->prepare($query); | 
| 90 | 90 | $sth->execute(); | 
| 91 | -                } catch(PDOException $e) { | |
| 91 | +                } catch (PDOException $e) { | |
| 92 | 92 | return "error : ".$e->getMessage(); | 
| 93 | 93 | } | 
| 94 | 94 | //$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)'; | 
| @@ -99,11 +99,11 @@ discard block | ||
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 100 | 100 |              		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | 
| 101 | 101 |  				//$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); | 
| 102 | -				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); | |
| 102 | +				$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); | |
| 103 | 103 | $sth_dest->execute($query_dest_values); | 
| 104 | 104 | } | 
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); | 
| 106 | -		} catch(PDOException $e) { | |
| 106 | +		} catch (PDOException $e) { | |
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); | 
| 108 | 108 | return "error : ".$e->getMessage(); | 
| 109 | 109 | } | 
| @@ -119,26 +119,26 @@ discard block | ||
| 119 | 119 | //$Connection = new Connection(); | 
| 120 | 120 | $sth = $Connection->db->prepare($query); | 
| 121 | 121 |                          $sth->execute(array(':source' => 'oneworld')); | 
| 122 | -                } catch(PDOException $e) { | |
| 122 | +                } catch (PDOException $e) { | |
| 123 | 123 | return "error : ".$e->getMessage(); | 
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | 126 | if ($globalDebug) echo " - Add routes to DB -"; | 
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 128 | 128 | $Spotter = new Spotter(); | 
| 129 | -		if ($fh = fopen($database_file,"r")) { | |
| 129 | +		if ($fh = fopen($database_file, "r")) { | |
| 130 | 130 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; | 
| 131 | 131 | $Connection = new Connection(); | 
| 132 | 132 | $sth_dest = $Connection->db->prepare($query_dest); | 
| 133 | 133 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 134 | 134 |  			while (!feof($fh)) { | 
| 135 | - $line = fgetcsv($fh,9999,','); | |
| 135 | + $line = fgetcsv($fh, 9999, ','); | |
| 136 | 136 |  				if ($line[0] != '') { | 
| 137 | 137 |  					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { | 
| 138 | 138 |  						try { | 
| 139 | -							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); | |
| 139 | +							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); | |
| 140 | 140 | $sth_dest->execute($query_dest_values); | 
| 141 | -						} catch(PDOException $e) { | |
| 141 | +						} catch (PDOException $e) { | |
| 142 | 142 | if ($globalTransaction) $Connection->db->rollBack(); | 
| 143 | 143 | return "error : ".$e->getMessage(); | 
| 144 | 144 | } | 
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | //$Connection = new Connection(); | 
| 161 | 161 | $sth = $Connection->db->prepare($query); | 
| 162 | 162 |                          $sth->execute(array(':source' => 'skyteam')); | 
| 163 | -                } catch(PDOException $e) { | |
| 163 | +                } catch (PDOException $e) { | |
| 164 | 164 | return "error : ".$e->getMessage(); | 
| 165 | 165 | } | 
| 166 | 166 | |
| @@ -168,24 +168,24 @@ discard block | ||
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 170 | 170 | $Spotter = new Spotter(); | 
| 171 | -		if ($fh = fopen($database_file,"r")) { | |
| 171 | +		if ($fh = fopen($database_file, "r")) { | |
| 172 | 172 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; | 
| 173 | 173 | $Connection = new Connection(); | 
| 174 | 174 | $sth_dest = $Connection->db->prepare($query_dest); | 
| 175 | 175 |  			try { | 
| 176 | 176 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 177 | 177 |  				while (!feof($fh)) { | 
| 178 | - $line = fgetcsv($fh,9999,','); | |
| 178 | + $line = fgetcsv($fh, 9999, ','); | |
| 179 | 179 |  					if ($line[0] != '') { | 
| 180 | -						$datebe = explode('  -  ',$line[2]); | |
| 180 | +						$datebe = explode('  -  ', $line[2]); | |
| 181 | 181 |  						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { | 
| 182 | -							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); | |
| 182 | +							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); | |
| 183 | 183 | $sth_dest->execute($query_dest_values); | 
| 184 | 184 | } | 
| 185 | 185 | } | 
| 186 | 186 | } | 
| 187 | 187 | if ($globalTransaction) $Connection->db->commit(); | 
| 188 | -			} catch(PDOException $e) { | |
| 188 | +			} catch (PDOException $e) { | |
| 189 | 189 | if ($globalTransaction) $Connection->db->rollBack(); | 
| 190 | 190 | return "error : ".$e->getMessage(); | 
| 191 | 191 | } | 
| @@ -200,7 +200,7 @@ discard block | ||
| 200 | 200 | $Connection = new Connection(); | 
| 201 | 201 | $sth = $Connection->db->prepare($query); | 
| 202 | 202 |                          $sth->execute(array(':source' => $database_file)); | 
| 203 | -                } catch(PDOException $e) { | |
| 203 | +                } catch (PDOException $e) { | |
| 204 | 204 | return "error : ".$e->getMessage(); | 
| 205 | 205 | } | 
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; | 
| @@ -208,7 +208,7 @@ discard block | ||
| 208 | 208 | $Connection = new Connection(); | 
| 209 | 209 | $sth = $Connection->db->prepare($query); | 
| 210 | 210 |                          $sth->execute(array(':source' => $database_file)); | 
| 211 | -                } catch(PDOException $e) { | |
| 211 | +                } catch (PDOException $e) { | |
| 212 | 212 | return "error : ".$e->getMessage(); | 
| 213 | 213 | } | 
| 214 | 214 | |
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 |  		try { | 
| 218 | 218 | $sth = update_db::$db_sqlite->prepare($query); | 
| 219 | 219 | $sth->execute(); | 
| 220 | -                } catch(PDOException $e) { | |
| 220 | +                } catch (PDOException $e) { | |
| 221 | 221 | return "error : ".$e->getMessage(); | 
| 222 | 222 | } | 
| 223 | 223 | //$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)'; | 
| @@ -234,15 +234,15 @@ discard block | ||
| 234 | 234 |  			//$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']); | 
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; | 
| 236 | 236 | else $type = null; | 
| 237 | -				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); | |
| 237 | +				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); | |
| 238 | 238 | $sth_dest->execute($query_dest_values); | 
| 239 | 239 |  				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { | 
| 240 | -				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); | |
| 240 | +				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); | |
| 241 | 241 | $sth_dest_owner->execute($query_dest_owner_values); | 
| 242 | 242 | } | 
| 243 | 243 | } | 
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); | 
| 245 | -		} catch(PDOException $e) { | |
| 245 | +		} catch (PDOException $e) { | |
| 246 | 246 | return "error : ".$e->getMessage(); | 
| 247 | 247 | } | 
| 248 | 248 | |
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | $Connection = new Connection(); | 
| 253 | 253 | $sth = $Connection->db->prepare($query); | 
| 254 | 254 |                          $sth->execute(array(':source' => $database_file)); | 
| 255 | -                } catch(PDOException $e) { | |
| 255 | +                } catch (PDOException $e) { | |
| 256 | 256 | return "error : ".$e->getMessage(); | 
| 257 | 257 | } | 
| 258 | 258 | return ''; | 
| @@ -267,11 +267,11 @@ discard block | ||
| 267 | 267 | $Connection = new Connection(); | 
| 268 | 268 | $sth = $Connection->db->prepare($query); | 
| 269 | 269 |                          $sth->execute(array(':source' => $database_file)); | 
| 270 | -                } catch(PDOException $e) { | |
| 270 | +                } catch (PDOException $e) { | |
| 271 | 271 | return "error : ".$e->getMessage(); | 
| 272 | 272 | } | 
| 273 | 273 | |
| 274 | -		if ($fh = fopen($database_file,"r")) { | |
| 274 | +		if ($fh = fopen($database_file, "r")) { | |
| 275 | 275 | //$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)'; | 
| 276 | 276 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; | 
| 277 | 277 | |
| @@ -281,13 +281,13 @@ discard block | ||
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 282 | 282 |              			while (!feof($fh)) { | 
| 283 | 283 | $values = array(); | 
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); | |
| 284 | + $line = $Common->hex2str(fgets($fh, 9999)); | |
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 | 
| 286 | - $values['ModeS'] = substr($line,0,6); | |
| 287 | - $values['Registration'] = trim(substr($line,69,6)); | |
| 288 | - $aircraft_name = trim(substr($line,48,6)); | |
| 286 | + $values['ModeS'] = substr($line, 0, 6); | |
| 287 | + $values['Registration'] = trim(substr($line, 69, 6)); | |
| 288 | + $aircraft_name = trim(substr($line, 48, 6)); | |
| 289 | 289 | // Check if we can find ICAO, else set it to GLID | 
| 290 | -            				$aircraft_name_split = explode(' ',$aircraft_name); | |
| 290 | +            				$aircraft_name_split = explode(' ', $aircraft_name); | |
| 291 | 291 | $search_more = ''; | 
| 292 | 292 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | 
| 293 | 293 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | 
| @@ -299,20 +299,20 @@ discard block | ||
| 299 | 299 |  	            				if (isset($result['icao']) && $result['icao'] != '') { | 
| 300 | 300 | $values['ICAOTypeCode'] = $result['icao']; | 
| 301 | 301 | } | 
| 302 | -					} catch(PDOException $e) { | |
| 302 | +					} catch (PDOException $e) { | |
| 303 | 303 | return "error : ".$e->getMessage(); | 
| 304 | 304 | } | 
| 305 | 305 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; | 
| 306 | 306 | // Add data to db | 
| 307 | 307 |  					if ($values['Registration'] != '' && $values['Registration'] != '0000') { | 
| 308 | 308 |  						//$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']); | 
| 309 | -						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); | |
| 309 | +						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); | |
| 310 | 310 | //print_r($query_dest_values); | 
| 311 | 311 | $sth_dest->execute($query_dest_values); | 
| 312 | 312 | } | 
| 313 | 313 | } | 
| 314 | 314 | if ($globalTransaction) $Connection->db->commit(); | 
| 315 | -			} catch(PDOException $e) { | |
| 315 | +			} catch (PDOException $e) { | |
| 316 | 316 | return "error : ".$e->getMessage(); | 
| 317 | 317 | } | 
| 318 | 318 | } | 
| @@ -322,7 +322,7 @@ discard block | ||
| 322 | 322 | $Connection = new Connection(); | 
| 323 | 323 | $sth = $Connection->db->prepare($query); | 
| 324 | 324 |                          $sth->execute(array(':source' => $database_file)); | 
| 325 | -                } catch(PDOException $e) { | |
| 325 | +                } catch (PDOException $e) { | |
| 326 | 326 | return "error : ".$e->getMessage(); | 
| 327 | 327 | } | 
| 328 | 328 | return ''; | 
| @@ -336,11 +336,11 @@ discard block | ||
| 336 | 336 | $Connection = new Connection(); | 
| 337 | 337 | $sth = $Connection->db->prepare($query); | 
| 338 | 338 |                          $sth->execute(array(':source' => $database_file)); | 
| 339 | -                } catch(PDOException $e) { | |
| 339 | +                } catch (PDOException $e) { | |
| 340 | 340 | return "error : ".$e->getMessage(); | 
| 341 | 341 | } | 
| 342 | 342 | |
| 343 | -		if ($fh = fopen($database_file,"r")) { | |
| 343 | +		if ($fh = fopen($database_file, "r")) { | |
| 344 | 344 | //$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)'; | 
| 345 | 345 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; | 
| 346 | 346 | |
| @@ -348,9 +348,9 @@ discard block | ||
| 348 | 348 | $sth_dest = $Connection->db->prepare($query_dest); | 
| 349 | 349 |  			try { | 
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 351 | - $tmp = fgetcsv($fh,9999,',',"'"); | |
| 351 | + $tmp = fgetcsv($fh, 9999, ',', "'"); | |
| 352 | 352 |              			while (!feof($fh)) { | 
| 353 | - $line = fgetcsv($fh,9999,',',"'"); | |
| 353 | + $line = fgetcsv($fh, 9999, ',', "'"); | |
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 | 
| 356 | 356 | //print_r($line); | 
| @@ -359,7 +359,7 @@ discard block | ||
| 359 | 359 | $values['ICAOTypeCode'] = ''; | 
| 360 | 360 | $aircraft_name = $line[2]; | 
| 361 | 361 | // Check if we can find ICAO, else set it to GLID | 
| 362 | -            				$aircraft_name_split = explode(' ',$aircraft_name); | |
| 362 | +            				$aircraft_name_split = explode(' ', $aircraft_name); | |
| 363 | 363 | $search_more = ''; | 
| 364 | 364 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; | 
| 365 | 365 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; | 
| @@ -368,20 +368,20 @@ discard block | ||
| 368 | 368 | $sth_search->execute(); | 
| 369 | 369 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); | 
| 370 | 370 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; | 
| 371 | -					} catch(PDOException $e) { | |
| 371 | +					} catch (PDOException $e) { | |
| 372 | 372 | return "error : ".$e->getMessage(); | 
| 373 | 373 | } | 
| 374 | 374 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; | 
| 375 | 375 | // Add data to db | 
| 376 | 376 |  					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { | 
| 377 | 377 |  						//$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']); | 
| 378 | -						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); | |
| 378 | +						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); | |
| 379 | 379 | //print_r($query_dest_values); | 
| 380 | 380 | $sth_dest->execute($query_dest_values); | 
| 381 | 381 | } | 
| 382 | 382 | } | 
| 383 | 383 | if ($globalTransaction) $Connection->db->commit(); | 
| 384 | -			} catch(PDOException $e) { | |
| 384 | +			} catch (PDOException $e) { | |
| 385 | 385 | return "error : ".$e->getMessage(); | 
| 386 | 386 | } | 
| 387 | 387 | } | 
| @@ -391,13 +391,13 @@ discard block | ||
| 391 | 391 | $Connection = new Connection(); | 
| 392 | 392 | $sth = $Connection->db->prepare($query); | 
| 393 | 393 |                          $sth->execute(array(':source' => $database_file)); | 
| 394 | -                } catch(PDOException $e) { | |
| 394 | +                } catch (PDOException $e) { | |
| 395 | 395 | return "error : ".$e->getMessage(); | 
| 396 | 396 | } | 
| 397 | 397 | return ''; | 
| 398 | 398 | } | 
| 399 | 399 | |
| 400 | -	public static function retrieve_owner($database_file,$country = 'F') { | |
| 400 | +	public static function retrieve_owner($database_file, $country = 'F') { | |
| 401 | 401 | global $globalTransaction, $globalMasterSource; | 
| 402 | 402 | //$query = 'TRUNCATE TABLE aircraft_modes'; | 
| 403 | 403 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; | 
| @@ -405,12 +405,12 @@ discard block | ||
| 405 | 405 | $Connection = new Connection(); | 
| 406 | 406 | $sth = $Connection->db->prepare($query); | 
| 407 | 407 |                          $sth->execute(array(':source' => $database_file)); | 
| 408 | -                } catch(PDOException $e) { | |
| 408 | +                } catch (PDOException $e) { | |
| 409 | 409 | return "error : ".$e->getMessage(); | 
| 410 | 410 | } | 
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 412 | 412 | $Spotter = new Spotter(); | 
| 413 | -		if ($fh = fopen($database_file,"r")) { | |
| 413 | +		if ($fh = fopen($database_file, "r")) { | |
| 414 | 414 | //$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)'; | 
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; | 
| 416 | 416 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; | 
| @@ -420,9 +420,9 @@ discard block | ||
| 420 | 420 | $sth_modes = $Connection->db->prepare($query_modes); | 
| 421 | 421 |  			try { | 
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 423 | - $tmp = fgetcsv($fh,9999,',','"'); | |
| 423 | + $tmp = fgetcsv($fh, 9999, ',', '"'); | |
| 424 | 424 |              			while (!feof($fh)) { | 
| 425 | - $line = fgetcsv($fh,9999,',','"'); | |
| 425 | + $line = fgetcsv($fh, 9999, ',', '"'); | |
| 426 | 426 | $values = array(); | 
| 427 | 427 | //print_r($line); | 
| 428 | 428 |              				if ($country == 'F') { | 
| @@ -430,7 +430,7 @@ discard block | ||
| 430 | 430 | $values['base'] = $line[4]; | 
| 431 | 431 | $values['owner'] = $line[5]; | 
| 432 | 432 | if ($line[6] == '') $values['date_first_reg'] = null; | 
| 433 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 433 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); | |
| 434 | 434 | $values['cancel'] = $line[7]; | 
| 435 | 435 |  					} elseif ($country == 'EI') { | 
| 436 | 436 | // TODO : add modeS & reg to aircraft_modes | 
| @@ -438,7 +438,7 @@ discard block | ||
| 438 | 438 | $values['base'] = $line[3]; | 
| 439 | 439 | $values['owner'] = $line[2]; | 
| 440 | 440 | if ($line[1] == '') $values['date_first_reg'] = null; | 
| 441 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); | |
| 441 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); | |
| 442 | 442 | $values['cancel'] = ''; | 
| 443 | 443 | $values['modes'] = $line[7]; | 
| 444 | 444 | $values['icao'] = $line[8]; | 
| @@ -458,7 +458,7 @@ discard block | ||
| 458 | 458 | $values['base'] = null; | 
| 459 | 459 | $values['owner'] = $line[5]; | 
| 460 | 460 | if ($line[18] == '') $values['date_first_reg'] = null; | 
| 461 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); | |
| 461 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); | |
| 462 | 462 | $values['cancel'] = ''; | 
| 463 | 463 |  					} elseif ($country == 'VH') { | 
| 464 | 464 | // TODO : add modeS & reg to aircraft_modes | 
| @@ -466,7 +466,7 @@ discard block | ||
| 466 | 466 | $values['base'] = null; | 
| 467 | 467 | $values['owner'] = $line[12]; | 
| 468 | 468 | if ($line[28] == '') $values['date_first_reg'] = null; | 
| 469 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); | |
| 469 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); | |
| 470 | 470 | |
| 471 | 471 | $values['cancel'] = $line[39]; | 
| 472 | 472 |  					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { | 
| @@ -486,28 +486,28 @@ discard block | ||
| 486 | 486 | $values['base'] = null; | 
| 487 | 487 | $values['owner'] = $line[8]; | 
| 488 | 488 | if ($line[7] == '') $values['date_first_reg'] = null; | 
| 489 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 489 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); | |
| 490 | 490 | $values['cancel'] = ''; | 
| 491 | 491 |  					} elseif ($country == 'PP') { | 
| 492 | 492 | $values['registration'] = $line[0]; | 
| 493 | 493 | $values['base'] = null; | 
| 494 | 494 | $values['owner'] = $line[4]; | 
| 495 | 495 | if ($line[6] == '') $values['date_first_reg'] = null; | 
| 496 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | |
| 496 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); | |
| 497 | 497 | $values['cancel'] = $line[7]; | 
| 498 | 498 |  					} elseif ($country == 'E7') { | 
| 499 | 499 | $values['registration'] = $line[0]; | 
| 500 | 500 | $values['base'] = null; | 
| 501 | 501 | $values['owner'] = $line[4]; | 
| 502 | 502 | if ($line[5] == '') $values['date_first_reg'] = null; | 
| 503 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 503 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); | |
| 504 | 504 | $values['cancel'] = ''; | 
| 505 | 505 |  					} elseif ($country == '8Q') { | 
| 506 | 506 | $values['registration'] = $line[0]; | 
| 507 | 507 | $values['base'] = null; | 
| 508 | 508 | $values['owner'] = $line[3]; | 
| 509 | 509 | if ($line[7] == '') $values['date_first_reg'] = null; | 
| 510 | -					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | |
| 510 | +					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); | |
| 511 | 511 | $values['cancel'] = ''; | 
| 512 | 512 |  					} elseif ($country == 'ZK') { | 
| 513 | 513 | $values['registration'] = $line[0]; | 
| @@ -521,18 +521,18 @@ discard block | ||
| 521 | 521 | $values['registration'] = $line[0]; | 
| 522 | 522 | $values['base'] = null; | 
| 523 | 523 | $values['owner'] = $line[6]; | 
| 524 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | |
| 525 | -					    $values['cancel'] = date("Y-m-d",strtotime($line[8])); | |
| 524 | +            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); | |
| 525 | +					    $values['cancel'] = date("Y-m-d", strtotime($line[8])); | |
| 526 | 526 | $values['modes'] = $line[4]; | 
| 527 | 527 | $values['icao'] = $line[10]; | 
| 528 | 528 |  					} elseif ($country == 'OY') { | 
| 529 | 529 | $values['registration'] = $line[0]; | 
| 530 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); | |
| 530 | +            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); | |
| 531 | 531 | $values['modes'] = $line[5]; | 
| 532 | 532 | $values['icao'] = $line[6]; | 
| 533 | 533 |  					} elseif ($country == 'PH') { | 
| 534 | 534 | $values['registration'] = $line[0]; | 
| 535 | -            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); | |
| 535 | +            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); | |
| 536 | 536 | $values['modes'] = $line[4]; | 
| 537 | 537 | $values['icao'] = $line[5]; | 
| 538 | 538 |  					} elseif ($country == 'OM' || $country == 'TF') { | 
| @@ -543,17 +543,17 @@ discard block | ||
| 543 | 543 | $values['cancel'] = ''; | 
| 544 | 544 | } | 
| 545 | 545 |  					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { | 
| 546 | -						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); | |
| 546 | +						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); | |
| 547 | 547 | $sth_dest->execute($query_dest_values); | 
| 548 | 548 | } | 
| 549 | 549 |  					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { | 
| 550 | 550 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); | 
| 551 | -						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); | |
| 551 | +						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); | |
| 552 | 552 | $sth_modes->execute($query_modes_values); | 
| 553 | 553 | } | 
| 554 | 554 | } | 
| 555 | 555 | if ($globalTransaction) $Connection->db->commit(); | 
| 556 | -			} catch(PDOException $e) { | |
| 556 | +			} catch (PDOException $e) { | |
| 557 | 557 | return "error : ".$e->getMessage(); | 
| 558 | 558 | } | 
| 559 | 559 | } | 
| @@ -668,7 +668,7 @@ discard block | ||
| 668 | 668 | $Connection = new Connection(); | 
| 669 | 669 | $sth = $Connection->db->prepare($query); | 
| 670 | 670 | $sth->execute(); | 
| 671 | -                } catch(PDOException $e) { | |
| 671 | +                } catch (PDOException $e) { | |
| 672 | 672 | return "error : ".$e->getMessage(); | 
| 673 | 673 | } | 
| 674 | 674 | |
| @@ -678,7 +678,7 @@ discard block | ||
| 678 | 678 | $Connection = new Connection(); | 
| 679 | 679 | $sth = $Connection->db->prepare($query); | 
| 680 | 680 | $sth->execute(); | 
| 681 | -                } catch(PDOException $e) { | |
| 681 | +                } catch (PDOException $e) { | |
| 682 | 682 | return "error : ".$e->getMessage(); | 
| 683 | 683 | } | 
| 684 | 684 | |
| @@ -689,7 +689,7 @@ discard block | ||
| 689 | 689 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 690 | 690 | |
| 691 | 691 | $i = 0; | 
| 692 | - while($row = sparql_fetch_array($result)) | |
| 692 | + while ($row = sparql_fetch_array($result)) | |
| 693 | 693 |  		{ | 
| 694 | 694 |  			if ($i >= 1) { | 
| 695 | 695 | //print_r($row); | 
| @@ -709,31 +709,31 @@ discard block | ||
| 709 | 709 | $row['image'] = ''; | 
| 710 | 710 | $row['image_thumb'] = ''; | 
| 711 | 711 |  			} else { | 
| 712 | -				$image = str_replace(' ','_',$row['image']); | |
| 712 | +				$image = str_replace(' ', '_', $row['image']); | |
| 713 | 713 | $digest = md5($image); | 
| 714 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; | |
| 715 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; | |
| 716 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; | |
| 717 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; | |
| 714 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; | |
| 715 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; | |
| 716 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; | |
| 717 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; | |
| 718 | 718 | } | 
| 719 | 719 | |
| 720 | -			$country = explode('-',$row['country']); | |
| 720 | +			$country = explode('-', $row['country']); | |
| 721 | 721 | $row['country'] = $country[0]; | 
| 722 | 722 | |
| 723 | 723 | $row['type'] = trim($row['type']); | 
| 724 | -			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { | |
| 724 | +			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { | |
| 725 | 725 | $row['type'] = 'Military'; | 
| 726 | 726 |  			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { | 
| 727 | 727 | $row['type'] = 'small_airport'; | 
| 728 | 728 | } | 
| 729 | 729 | |
| 730 | -			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); | |
| 731 | -			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); | |
| 730 | +			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); | |
| 731 | +			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); | |
| 732 | 732 | //print_r($query_dest_values); | 
| 733 | 733 | |
| 734 | 734 |  			try { | 
| 735 | 735 | $sth_dest->execute($query_dest_values); | 
| 736 | -			} catch(PDOException $e) { | |
| 736 | +			} catch (PDOException $e) { | |
| 737 | 737 | return "error : ".$e->getMessage(); | 
| 738 | 738 | } | 
| 739 | 739 | } | 
| @@ -747,7 +747,7 @@ discard block | ||
| 747 | 747 | $Connection = new Connection(); | 
| 748 | 748 | $sth = $Connection->db->prepare($query); | 
| 749 | 749 | $sth->execute(); | 
| 750 | -                } catch(PDOException $e) { | |
| 750 | +                } catch (PDOException $e) { | |
| 751 | 751 | return "error : ".$e->getMessage(); | 
| 752 | 752 | } | 
| 753 | 753 | |
| @@ -755,12 +755,12 @@ discard block | ||
| 755 | 755 | if ($globalDebug) echo "Insert Not available Airport...\n"; | 
| 756 | 756 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) | 
| 757 | 757 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; | 
| 758 | -		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); | |
| 758 | +		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); | |
| 759 | 759 |  		try { | 
| 760 | 760 | $Connection = new Connection(); | 
| 761 | 761 | $sth = $Connection->db->prepare($query); | 
| 762 | 762 | $sth->execute($query_values); | 
| 763 | -                } catch(PDOException $e) { | |
| 763 | +                } catch (PDOException $e) { | |
| 764 | 764 | return "error : ".$e->getMessage(); | 
| 765 | 765 | } | 
| 766 | 766 | $i++; | 
| @@ -778,7 +778,7 @@ discard block | ||
| 778 | 778 | echo "Download data from ourairports.com...\n"; | 
| 779 | 779 | $delimiter = ','; | 
| 780 | 780 | $out_file = $tmp_dir.'airports.csv'; | 
| 781 | -		update_db::download('http://ourairports.com/data/airports.csv',$out_file); | |
| 781 | +		update_db::download('http://ourairports.com/data/airports.csv', $out_file); | |
| 782 | 782 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
| 783 | 783 | echo "Add data from ourairports.com...\n"; | 
| 784 | 784 | |
| @@ -789,32 +789,32 @@ discard block | ||
| 789 | 789 | //$Connection->db->beginTransaction(); | 
| 790 | 790 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
| 791 | 791 |  			{ | 
| 792 | - if(!$header) $header = $row; | |
| 792 | + if (!$header) $header = $row; | |
| 793 | 793 |  				else { | 
| 794 | 794 | $data = array(); | 
| 795 | 795 | $data = array_combine($header, $row); | 
| 796 | 796 |  					try { | 
| 797 | 797 |  						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); | 
| 798 | 798 |  						$sth->execute(array(':icao' => $data['gps_code'])); | 
| 799 | -					} catch(PDOException $e) { | |
| 799 | +					} catch (PDOException $e) { | |
| 800 | 800 | return "error : ".$e->getMessage(); | 
| 801 | 801 | } | 
| 802 | 802 |  					if ($sth->fetchColumn() > 0) { | 
| 803 | 803 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; | 
| 804 | 804 |  						try { | 
| 805 | 805 | $sth = $Connection->db->prepare($query); | 
| 806 | -							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); | |
| 807 | -						} catch(PDOException $e) { | |
| 806 | +							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); | |
| 807 | +						} catch (PDOException $e) { | |
| 808 | 808 | return "error : ".$e->getMessage(); | 
| 809 | 809 | } | 
| 810 | 810 |  					} else { | 
| 811 | 811 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) | 
| 812 | 812 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; | 
| 813 | -						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); | |
| 813 | +						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); | |
| 814 | 814 |  						try { | 
| 815 | 815 | $sth = $Connection->db->prepare($query); | 
| 816 | 816 | $sth->execute($query_values); | 
| 817 | -						} catch(PDOException $e) { | |
| 817 | +						} catch (PDOException $e) { | |
| 818 | 818 | return "error : ".$e->getMessage(); | 
| 819 | 819 | } | 
| 820 | 820 | $i++; | 
| @@ -827,7 +827,7 @@ discard block | ||
| 827 | 827 | |
| 828 | 828 | echo "Download data from another free database...\n"; | 
| 829 | 829 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; | 
| 830 | -		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); | |
| 830 | +		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); | |
| 831 | 831 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
| 832 | 832 | update_db::unzip($out_file); | 
| 833 | 833 | $header = NULL; | 
| @@ -839,15 +839,15 @@ discard block | ||
| 839 | 839 | //$Connection->db->beginTransaction(); | 
| 840 | 840 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
| 841 | 841 |  			{ | 
| 842 | - if(!$header) $header = $row; | |
| 842 | + if (!$header) $header = $row; | |
| 843 | 843 |  				else { | 
| 844 | 844 | $data = $row; | 
| 845 | 845 | |
| 846 | 846 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; | 
| 847 | 847 |  					try { | 
| 848 | 848 | $sth = $Connection->db->prepare($query); | 
| 849 | -						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); | |
| 850 | -					} catch(PDOException $e) { | |
| 849 | +						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); | |
| 850 | +					} catch (PDOException $e) { | |
| 851 | 851 | return "error : ".$e->getMessage(); | 
| 852 | 852 | } | 
| 853 | 853 | } | 
| @@ -861,15 +861,15 @@ discard block | ||
| 861 | 861 |  		try { | 
| 862 | 862 |  			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); | 
| 863 | 863 | $sth->execute(); | 
| 864 | -		} catch(PDOException $e) { | |
| 864 | +		} catch (PDOException $e) { | |
| 865 | 865 | return "error : ".$e->getMessage(); | 
| 866 | 866 | } | 
| 867 | 867 |  		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
| 868 | 868 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; | 
| 869 | 869 |  			try { | 
| 870 | 870 | $sth2 = $Connection->db->prepare($query2); | 
| 871 | -				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); | |
| 872 | -			} catch(PDOException $e) { | |
| 871 | +				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); | |
| 872 | +			} catch (PDOException $e) { | |
| 873 | 873 | return "error : ".$e->getMessage(); | 
| 874 | 874 | } | 
| 875 | 875 | } | 
| @@ -893,7 +893,7 @@ discard block | ||
| 893 | 893 | $Connection = new Connection(); | 
| 894 | 894 | $sth = $Connection->db->prepare($query); | 
| 895 | 895 |                          $sth->execute(array(':source' => 'translation.csv')); | 
| 896 | -                } catch(PDOException $e) { | |
| 896 | +                } catch (PDOException $e) { | |
| 897 | 897 | return "error : ".$e->getMessage(); | 
| 898 | 898 | } | 
| 899 | 899 | |
| @@ -910,7 +910,7 @@ discard block | ||
| 910 | 910 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
| 911 | 911 |  			{ | 
| 912 | 912 | $i++; | 
| 913 | -				if($i > 12) { | |
| 913 | +				if ($i > 12) { | |
| 914 | 914 | $data = $row; | 
| 915 | 915 | $operator = $data[2]; | 
| 916 | 916 |  					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { | 
| @@ -918,7 +918,7 @@ discard block | ||
| 918 | 918 | //echo substr($operator, 0, 2)."\n";; | 
| 919 | 919 |                                                  if (count($airline_array) > 0) { | 
| 920 | 920 | //print_r($airline_array); | 
| 921 | - $operator = $airline_array[0]['icao'].substr($operator,2); | |
| 921 | + $operator = $airline_array[0]['icao'].substr($operator, 2); | |
| 922 | 922 | } | 
| 923 | 923 | } | 
| 924 | 924 | |
| @@ -926,14 +926,14 @@ discard block | ||
| 926 | 926 |  					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { | 
| 927 | 927 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); | 
| 928 | 928 |                                                  if (count($airline_array) > 0) { | 
| 929 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); | |
| 929 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); | |
| 930 | 930 | } | 
| 931 | 931 | } | 
| 932 | 932 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; | 
| 933 | 933 |  					try { | 
| 934 | 934 | $sth = $Connection->db->prepare($query); | 
| 935 | -						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); | |
| 936 | -					} catch(PDOException $e) { | |
| 935 | +						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); | |
| 936 | +					} catch (PDOException $e) { | |
| 937 | 937 | return "error : ".$e->getMessage(); | 
| 938 | 938 | } | 
| 939 | 939 | } | 
| @@ -953,7 +953,7 @@ discard block | ||
| 953 | 953 | $Connection = new Connection(); | 
| 954 | 954 | $sth = $Connection->db->prepare($query); | 
| 955 | 955 |                          $sth->execute(array(':source' => 'website_fam')); | 
| 956 | -                } catch(PDOException $e) { | |
| 956 | +                } catch (PDOException $e) { | |
| 957 | 957 | return "error : ".$e->getMessage(); | 
| 958 | 958 | } | 
| 959 | 959 | |
| @@ -973,8 +973,8 @@ discard block | ||
| 973 | 973 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; | 
| 974 | 974 |  					try { | 
| 975 | 975 | $sth = $Connection->db->prepare($query); | 
| 976 | -						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); | |
| 977 | -					} catch(PDOException $e) { | |
| 976 | +						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); | |
| 977 | +					} catch (PDOException $e) { | |
| 978 | 978 | return "error : ".$e->getMessage(); | 
| 979 | 979 | } | 
| 980 | 980 | } | 
| @@ -997,7 +997,7 @@ discard block | ||
| 997 | 997 | $Connection = new Connection(); | 
| 998 | 998 | $sth = $Connection->db->prepare($query); | 
| 999 | 999 |                          $sth->execute(array(':source' => 'website_faa')); | 
| 1000 | -                } catch(PDOException $e) { | |
| 1000 | +                } catch (PDOException $e) { | |
| 1001 | 1001 | return "error : ".$e->getMessage(); | 
| 1002 | 1002 | } | 
| 1003 | 1003 | |
| @@ -1006,7 +1006,7 @@ discard block | ||
| 1006 | 1006 | $Connection = new Connection(); | 
| 1007 | 1007 | $sth = $Connection->db->prepare($query); | 
| 1008 | 1008 |                          $sth->execute(array(':source' => 'website_faa')); | 
| 1009 | -                } catch(PDOException $e) { | |
| 1009 | +                } catch (PDOException $e) { | |
| 1010 | 1010 | return "error : ".$e->getMessage(); | 
| 1011 | 1011 | } | 
| 1012 | 1012 | |
| @@ -1023,8 +1023,8 @@ discard block | ||
| 1023 | 1023 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; | 
| 1024 | 1024 |  					try { | 
| 1025 | 1025 | $sths = $Connection->db->prepare($query_search); | 
| 1026 | -						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); | |
| 1027 | -					} catch(PDOException $e) { | |
| 1026 | +						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); | |
| 1027 | +					} catch (PDOException $e) { | |
| 1028 | 1028 | return "error s : ".$e->getMessage(); | 
| 1029 | 1029 | } | 
| 1030 | 1030 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1037,8 +1037,8 @@ discard block | ||
| 1037 | 1037 | //} | 
| 1038 | 1038 |  						try { | 
| 1039 | 1039 | $sthi = $Connection->db->prepare($queryi); | 
| 1040 | -							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); | |
| 1041 | -						} catch(PDOException $e) { | |
| 1040 | +							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); | |
| 1041 | +						} catch (PDOException $e) { | |
| 1042 | 1042 | return "error u : ".$e->getMessage(); | 
| 1043 | 1043 | } | 
| 1044 | 1044 |  					} else { | 
| @@ -1046,7 +1046,7 @@ discard block | ||
| 1046 | 1046 |  						try { | 
| 1047 | 1047 | $sthsm = $Connection->db->prepare($query_search_mfr); | 
| 1048 | 1048 |  							$sthsm->execute(array(':mfr' => $data[2])); | 
| 1049 | -						} catch(PDOException $e) { | |
| 1049 | +						} catch (PDOException $e) { | |
| 1050 | 1050 | return "error mfr : ".$e->getMessage(); | 
| 1051 | 1051 | } | 
| 1052 | 1052 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1056,8 +1056,8 @@ discard block | ||
| 1056 | 1056 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; | 
| 1057 | 1057 |  							try { | 
| 1058 | 1058 | $sthf = $Connection->db->prepare($queryf); | 
| 1059 | -								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); | |
| 1060 | -							} catch(PDOException $e) { | |
| 1059 | +								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); | |
| 1060 | +							} catch (PDOException $e) { | |
| 1061 | 1061 | return "error f : ".$e->getMessage(); | 
| 1062 | 1062 | } | 
| 1063 | 1063 | } | 
| @@ -1067,13 +1067,13 @@ discard block | ||
| 1067 | 1067 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; | 
| 1068 | 1068 |  						try { | 
| 1069 | 1069 | $sth = $Connection->db->prepare($query); | 
| 1070 | -							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); | |
| 1071 | -						} catch(PDOException $e) { | |
| 1070 | +							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); | |
| 1071 | +						} catch (PDOException $e) { | |
| 1072 | 1072 | return "error i : ".$e->getMessage(); | 
| 1073 | 1073 | } | 
| 1074 | 1074 | } | 
| 1075 | 1075 | } | 
| 1076 | -				if ($i % 90 == 0) { | |
| 1076 | +				if ($i%90 == 0) { | |
| 1077 | 1077 | if ($globalTransaction) $Connection->db->commit(); | 
| 1078 | 1078 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 1079 | 1079 | } | 
| @@ -1092,7 +1092,7 @@ discard block | ||
| 1092 | 1092 | $Connection = new Connection(); | 
| 1093 | 1093 | $sth = $Connection->db->prepare($query); | 
| 1094 | 1094 |                          $sth->execute(array(':source' => 'website_fam')); | 
| 1095 | -                } catch(PDOException $e) { | |
| 1095 | +                } catch (PDOException $e) { | |
| 1096 | 1096 | return "error : ".$e->getMessage(); | 
| 1097 | 1097 | } | 
| 1098 | 1098 | |
| @@ -1113,8 +1113,8 @@ discard block | ||
| 1113 | 1113 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; | 
| 1114 | 1114 |  					try { | 
| 1115 | 1115 | $sth = $Connection->db->prepare($query); | 
| 1116 | -						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); | |
| 1117 | -					} catch(PDOException $e) { | |
| 1116 | +						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); | |
| 1117 | +					} catch (PDOException $e) { | |
| 1118 | 1118 | return "error : ".$e->getMessage(); | 
| 1119 | 1119 | } | 
| 1120 | 1120 | } | 
| @@ -1133,7 +1133,7 @@ discard block | ||
| 1133 | 1133 | $Connection = new Connection(); | 
| 1134 | 1134 | $sth = $Connection->db->prepare($query); | 
| 1135 | 1135 |                          $sth->execute(array(':source' => 'website_fam')); | 
| 1136 | -                } catch(PDOException $e) { | |
| 1136 | +                } catch (PDOException $e) { | |
| 1137 | 1137 | return "error : ".$e->getMessage(); | 
| 1138 | 1138 | } | 
| 1139 | 1139 | |
| @@ -1149,8 +1149,8 @@ discard block | ||
| 1149 | 1149 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; | 
| 1150 | 1150 |  					try { | 
| 1151 | 1151 | $sth = $Connection->db->prepare($query); | 
| 1152 | -						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); | |
| 1153 | -					} catch(PDOException $e) { | |
| 1152 | +						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); | |
| 1153 | +					} catch (PDOException $e) { | |
| 1154 | 1154 | print_r($data); | 
| 1155 | 1155 | return "error : ".$e->getMessage(); | 
| 1156 | 1156 | } | 
| @@ -1170,7 +1170,7 @@ discard block | ||
| 1170 | 1170 | $Connection = new Connection(); | 
| 1171 | 1171 | $sth = $Connection->db->prepare($query); | 
| 1172 | 1172 |                          $sth->execute(array(':source' => 'website_fam')); | 
| 1173 | -                } catch(PDOException $e) { | |
| 1173 | +                } catch (PDOException $e) { | |
| 1174 | 1174 | return "error : ".$e->getMessage(); | 
| 1175 | 1175 | } | 
| 1176 | 1176 | |
| @@ -1190,8 +1190,8 @@ discard block | ||
| 1190 | 1190 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; | 
| 1191 | 1191 |  					try { | 
| 1192 | 1192 | $sth = $Connection->db->prepare($query); | 
| 1193 | -						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); | |
| 1194 | -					} catch(PDOException $e) { | |
| 1193 | +						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); | |
| 1194 | +					} catch (PDOException $e) { | |
| 1195 | 1195 | return "error : ".$e->getMessage(); | 
| 1196 | 1196 | } | 
| 1197 | 1197 | } | 
| @@ -1210,7 +1210,7 @@ discard block | ||
| 1210 | 1210 | $Connection = new Connection(); | 
| 1211 | 1211 | $sth = $Connection->db->prepare($query); | 
| 1212 | 1212 | $sth->execute(); | 
| 1213 | -                } catch(PDOException $e) { | |
| 1213 | +                } catch (PDOException $e) { | |
| 1214 | 1214 | return "error : ".$e->getMessage(); | 
| 1215 | 1215 | } | 
| 1216 | 1216 | |
| @@ -1231,8 +1231,8 @@ discard block | ||
| 1231 | 1231 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; | 
| 1232 | 1232 |  					try { | 
| 1233 | 1233 | $sth = $Connection->db->prepare($query); | 
| 1234 | -						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); | |
| 1235 | -					} catch(PDOException $e) { | |
| 1234 | +						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); | |
| 1235 | +					} catch (PDOException $e) { | |
| 1236 | 1236 | return "error : ".$e->getMessage(); | 
| 1237 | 1237 | } | 
| 1238 | 1238 | } | 
| @@ -1251,7 +1251,7 @@ discard block | ||
| 1251 | 1251 | $Connection = new Connection(); | 
| 1252 | 1252 | $sth = $Connection->db->prepare($query); | 
| 1253 | 1253 | $sth->execute(); | 
| 1254 | -		} catch(PDOException $e) { | |
| 1254 | +		} catch (PDOException $e) { | |
| 1255 | 1255 | return "error : ".$e->getMessage(); | 
| 1256 | 1256 | } | 
| 1257 | 1257 | |
| @@ -1267,7 +1267,7 @@ discard block | ||
| 1267 | 1267 |  					try { | 
| 1268 | 1268 | $sth = $Connection->db->prepare($query); | 
| 1269 | 1269 |  						$sth->execute(array(':icao' => $icao)); | 
| 1270 | -					} catch(PDOException $e) { | |
| 1270 | +					} catch (PDOException $e) { | |
| 1271 | 1271 | return "error : ".$e->getMessage(); | 
| 1272 | 1272 | } | 
| 1273 | 1273 | } | 
| @@ -1278,7 +1278,7 @@ discard block | ||
| 1278 | 1278 | return ''; | 
| 1279 | 1279 | } | 
| 1280 | 1280 | |
| 1281 | -	public static function tle($filename,$tletype) { | |
| 1281 | +	public static function tle($filename, $tletype) { | |
| 1282 | 1282 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
| 1283 | 1283 | global $tmp_dir, $globalTransaction; | 
| 1284 | 1284 | //$Spotter = new Spotter(); | 
| @@ -1288,7 +1288,7 @@ discard block | ||
| 1288 | 1288 | $Connection = new Connection(); | 
| 1289 | 1289 | $sth = $Connection->db->prepare($query); | 
| 1290 | 1290 |                          $sth->execute(array(':source' => $filename)); | 
| 1291 | -                } catch(PDOException $e) { | |
| 1291 | +                } catch (PDOException $e) { | |
| 1292 | 1292 | return "error : ".$e->getMessage(); | 
| 1293 | 1293 | } | 
| 1294 | 1294 | |
| @@ -1313,8 +1313,8 @@ discard block | ||
| 1313 | 1313 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; | 
| 1314 | 1314 |  					try { | 
| 1315 | 1315 | $sth = $Connection->db->prepare($query); | 
| 1316 | -						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); | |
| 1317 | -					} catch(PDOException $e) { | |
| 1316 | +						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); | |
| 1317 | +					} catch (PDOException $e) { | |
| 1318 | 1318 | return "error : ".$e->getMessage(); | 
| 1319 | 1319 | } | 
| 1320 | 1320 | |
| @@ -1334,28 +1334,28 @@ discard block | ||
| 1334 | 1334 | */ | 
| 1335 | 1335 |          private static function table2array($data) { | 
| 1336 | 1336 | $html = str_get_html($data); | 
| 1337 | - $tabledata=array(); | |
| 1338 | -                foreach($html->find('tr') as $element) | |
| 1337 | + $tabledata = array(); | |
| 1338 | +                foreach ($html->find('tr') as $element) | |
| 1339 | 1339 |                  { | 
| 1340 | 1340 | $td = array(); | 
| 1341 | -                        foreach( $element->find('th') as $row) | |
| 1341 | +                        foreach ($element->find('th') as $row) | |
| 1342 | 1342 |                          { | 
| 1343 | 1343 | $td [] = trim($row->plaintext); | 
| 1344 | 1344 | } | 
| 1345 | - $td=array_filter($td); | |
| 1345 | + $td = array_filter($td); | |
| 1346 | 1346 | $tabledata[] = $td; | 
| 1347 | 1347 | |
| 1348 | 1348 | $td = array(); | 
| 1349 | 1349 | $tdi = array(); | 
| 1350 | -                        foreach( $element->find('td') as $row) | |
| 1350 | +                        foreach ($element->find('td') as $row) | |
| 1351 | 1351 |                          { | 
| 1352 | 1352 | $td [] = trim($row->plaintext); | 
| 1353 | 1353 | $tdi [] = trim($row->innertext); | 
| 1354 | 1354 | } | 
| 1355 | - $td=array_filter($td); | |
| 1356 | - $tdi=array_filter($tdi); | |
| 1355 | + $td = array_filter($td); | |
| 1356 | + $tdi = array_filter($tdi); | |
| 1357 | 1357 | // $tabledata[]=array_merge($td,$tdi); | 
| 1358 | - $tabledata[]=$td; | |
| 1358 | + $tabledata[] = $td; | |
| 1359 | 1359 | } | 
| 1360 | 1360 | return(array_filter($tabledata)); | 
| 1361 | 1361 | } | 
| @@ -1428,13 +1428,13 @@ discard block | ||
| 1428 | 1428 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
| 1429 | 1429 |  			{ | 
| 1430 | 1430 | $i++; | 
| 1431 | -				if($i > 3 && count($row) > 2) { | |
| 1431 | +				if ($i > 3 && count($row) > 2) { | |
| 1432 | 1432 | $data = array_values(array_filter($row)); | 
| 1433 | 1433 | $cntdata = count($data); | 
| 1434 | 1434 |  					if ($cntdata > 10) { | 
| 1435 | 1435 | $value = $data[9]; | 
| 1436 | 1436 | |
| 1437 | -						for ($i =10;$i < $cntdata;$i++) { | |
| 1437 | +						for ($i = 10; $i < $cntdata; $i++) { | |
| 1438 | 1438 | $value .= ' '.$data[$i]; | 
| 1439 | 1439 | } | 
| 1440 | 1440 | $data[9] = $value; | 
| @@ -1444,8 +1444,8 @@ discard block | ||
| 1444 | 1444 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; | 
| 1445 | 1445 |  						try { | 
| 1446 | 1446 | $sth = $Connection->db->prepare($query); | 
| 1447 | -							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); | |
| 1448 | -						} catch(PDOException $e) { | |
| 1447 | +							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); | |
| 1448 | +						} catch (PDOException $e) { | |
| 1449 | 1449 | return "error : ".$e->getMessage(); | 
| 1450 | 1450 | } | 
| 1451 | 1451 | } | 
| @@ -1466,7 +1466,7 @@ discard block | ||
| 1466 | 1466 | $Connection = new Connection(); | 
| 1467 | 1467 | $sth = $Connection->db->prepare($query); | 
| 1468 | 1468 | $sth->execute(); | 
| 1469 | -                } catch(PDOException $e) { | |
| 1469 | +                } catch (PDOException $e) { | |
| 1470 | 1470 | return "error : ".$e->getMessage(); | 
| 1471 | 1471 | } | 
| 1472 | 1472 | |
| @@ -1478,12 +1478,12 @@ discard block | ||
| 1478 | 1478 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 1479 | 1479 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
| 1480 | 1480 |  			{ | 
| 1481 | -				if(count($row) > 1) { | |
| 1481 | +				if (count($row) > 1) { | |
| 1482 | 1482 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; | 
| 1483 | 1483 |  					try { | 
| 1484 | 1484 | $sth = $Connection->db->prepare($query); | 
| 1485 | -						$sth->execute(array(':name' => $row[1],':icao' => $row[0])); | |
| 1486 | -					} catch(PDOException $e) { | |
| 1485 | +						$sth->execute(array(':name' => $row[1], ':icao' => $row[0])); | |
| 1486 | +					} catch (PDOException $e) { | |
| 1487 | 1487 | return "error : ".$e->getMessage(); | 
| 1488 | 1488 | } | 
| 1489 | 1489 | } | 
| @@ -1503,21 +1503,21 @@ discard block | ||
| 1503 | 1503 |  			try { | 
| 1504 | 1504 | $sth = $Connection->db->prepare($query); | 
| 1505 | 1505 | $sth->execute(); | 
| 1506 | -	                } catch(PDOException $e) { | |
| 1506 | +	                } catch (PDOException $e) { | |
| 1507 | 1507 | return "error : ".$e->getMessage(); | 
| 1508 | 1508 | } | 
| 1509 | 1509 | } | 
| 1510 | 1510 | |
| 1511 | 1511 | |
| 1512 | -		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); | |
| 1512 | +		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); | |
| 1513 | 1513 |  		else { | 
| 1514 | -			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); | |
| 1514 | +			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); | |
| 1515 | 1515 | $query = "CREATE EXTENSION postgis"; | 
| 1516 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); | |
| 1516 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); | |
| 1517 | 1517 |  			try { | 
| 1518 | 1518 | $sth = $Connection->db->prepare($query); | 
| 1519 | 1519 | $sth->execute(); | 
| 1520 | -			} catch(PDOException $e) { | |
| 1520 | +			} catch (PDOException $e) { | |
| 1521 | 1521 | return "error : ".$e->getMessage(); | 
| 1522 | 1522 | } | 
| 1523 | 1523 | } | 
| @@ -1530,7 +1530,7 @@ discard block | ||
| 1530 | 1530 |  		include_once('class.create_db.php'); | 
| 1531 | 1531 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); | 
| 1532 | 1532 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; | 
| 1533 | -		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); | |
| 1533 | +		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); | |
| 1534 | 1534 | $error = ''; | 
| 1535 | 1535 |  		if (file_exists($tmp_dir.'notam.txt.gz')) { | 
| 1536 | 1536 | if ($globalDebug) echo "Gunzip..."; | 
| @@ -1562,14 +1562,14 @@ discard block | ||
| 1562 | 1562 |  			try { | 
| 1563 | 1563 | $sth = $Connection->db->prepare($query); | 
| 1564 | 1564 | $sth->execute(); | 
| 1565 | -	                } catch(PDOException $e) { | |
| 1565 | +	                } catch (PDOException $e) { | |
| 1566 | 1566 | echo "error : ".$e->getMessage(); | 
| 1567 | 1567 | } | 
| 1568 | 1568 | } | 
| 1569 | 1569 |  		if ($globalDBdriver == 'mysql') { | 
| 1570 | -			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); | |
| 1570 | +			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); | |
| 1571 | 1571 |  		} else { | 
| 1572 | -			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); | |
| 1572 | +			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); | |
| 1573 | 1573 | } | 
| 1574 | 1574 | $error = create_db::import_file($tmp_dir.'countries.sql'); | 
| 1575 | 1575 | return $error; | 
| @@ -1582,7 +1582,7 @@ discard block | ||
| 1582 | 1582 | // update_db::unzip($tmp_dir.'AptNav.zip'); | 
| 1583 | 1583 |  //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); | 
| 1584 | 1584 |  //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); | 
| 1585 | -		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); | |
| 1585 | +		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); | |
| 1586 | 1586 | update_db::gunzip($tmp_dir.'awy.dat.gz'); | 
| 1587 | 1587 | $error = update_db::waypoints($tmp_dir.'awy.dat'); | 
| 1588 | 1588 | return $error; | 
| @@ -1602,7 +1602,7 @@ discard block | ||
| 1602 | 1602 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); | 
| 1603 | 1603 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; | 
| 1604 | 1604 |  			if (is_writable(dirname(__FILE__).'/../images/airlines')) { | 
| 1605 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; | |
| 1605 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; | |
| 1606 | 1606 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; | 
| 1607 | 1607 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; | 
| 1608 | 1608 |  		if ($error != '') { | 
| @@ -1615,7 +1615,7 @@ discard block | ||
| 1615 | 1615 | global $tmp_dir, $globalDebug; | 
| 1616 | 1616 | $error = ''; | 
| 1617 | 1617 | if ($globalDebug) echo "Routes : Download..."; | 
| 1618 | -		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); | |
| 1618 | +		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); | |
| 1619 | 1619 |  		if (file_exists($tmp_dir.'StandingData.sqb.gz')) { | 
| 1620 | 1620 | if ($globalDebug) echo "Gunzip..."; | 
| 1621 | 1621 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); | 
| @@ -1631,7 +1631,7 @@ discard block | ||
| 1631 | 1631 | global $tmp_dir, $globalDebug; | 
| 1632 | 1632 | $error = ''; | 
| 1633 | 1633 | if ($globalDebug) echo "Schedules Oneworld : Download..."; | 
| 1634 | -		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); | |
| 1634 | +		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); | |
| 1635 | 1635 |  		if (file_exists($tmp_dir.'oneworld.csv.gz')) { | 
| 1636 | 1636 | if ($globalDebug) echo "Gunzip..."; | 
| 1637 | 1637 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); | 
| @@ -1647,7 +1647,7 @@ discard block | ||
| 1647 | 1647 | global $tmp_dir, $globalDebug; | 
| 1648 | 1648 | $error = ''; | 
| 1649 | 1649 | if ($globalDebug) echo "Schedules Skyteam : Download..."; | 
| 1650 | -		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); | |
| 1650 | +		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); | |
| 1651 | 1651 |  		if (file_exists($tmp_dir.'skyteam.csv.gz')) { | 
| 1652 | 1652 | if ($globalDebug) echo "Gunzip..."; | 
| 1653 | 1653 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); | 
| @@ -1675,7 +1675,7 @@ discard block | ||
| 1675 | 1675 | */ | 
| 1676 | 1676 | if ($globalDebug) echo "Modes : Download..."; | 
| 1677 | 1677 |  //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); | 
| 1678 | -		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); | |
| 1678 | +		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); | |
| 1679 | 1679 | |
| 1680 | 1680 |  //		if (file_exists($tmp_dir.'basestation_latest.zip')) { | 
| 1681 | 1681 |  		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { | 
| @@ -1695,7 +1695,7 @@ discard block | ||
| 1695 | 1695 |  	public static function update_ModeS_faa() { | 
| 1696 | 1696 | global $tmp_dir, $globalDebug; | 
| 1697 | 1697 | if ($globalDebug) echo "Modes FAA: Download..."; | 
| 1698 | -		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); | |
| 1698 | +		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); | |
| 1699 | 1699 |  		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { | 
| 1700 | 1700 | if ($globalDebug) echo "Unzip..."; | 
| 1701 | 1701 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); | 
| @@ -1711,7 +1711,7 @@ discard block | ||
| 1711 | 1711 |  	public static function update_ModeS_flarm() { | 
| 1712 | 1712 | global $tmp_dir, $globalDebug; | 
| 1713 | 1713 | if ($globalDebug) echo "Modes Flarmnet: Download..."; | 
| 1714 | -		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); | |
| 1714 | +		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); | |
| 1715 | 1715 |  		if (file_exists($tmp_dir.'data.fln')) { | 
| 1716 | 1716 | if ($globalDebug) echo "Add to DB..."; | 
| 1717 | 1717 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); | 
| @@ -1725,7 +1725,7 @@ discard block | ||
| 1725 | 1725 |  	public static function update_ModeS_ogn() { | 
| 1726 | 1726 | global $tmp_dir, $globalDebug; | 
| 1727 | 1727 | if ($globalDebug) echo "Modes OGN: Download..."; | 
| 1728 | -		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); | |
| 1728 | +		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); | |
| 1729 | 1729 |  		if (file_exists($tmp_dir.'ogn.csv')) { | 
| 1730 | 1730 | if ($globalDebug) echo "Add to DB..."; | 
| 1731 | 1731 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); | 
| @@ -1740,201 +1740,201 @@ discard block | ||
| 1740 | 1740 | global $tmp_dir, $globalDebug, $globalMasterSource; | 
| 1741 | 1741 | |
| 1742 | 1742 | if ($globalDebug) echo "Owner France: Download..."; | 
| 1743 | -		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); | |
| 1743 | +		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); | |
| 1744 | 1744 |  		if (file_exists($tmp_dir.'owner_f.csv')) { | 
| 1745 | 1745 | if ($globalDebug) echo "Add to DB..."; | 
| 1746 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); | |
| 1746 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); | |
| 1747 | 1747 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; | 
| 1748 | 1748 |  		if ($error != '') { | 
| 1749 | 1749 | return $error; | 
| 1750 | 1750 | } elseif ($globalDebug) echo "Done\n"; | 
| 1751 | 1751 | |
| 1752 | 1752 | if ($globalDebug) echo "Owner Ireland: Download..."; | 
| 1753 | -		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); | |
| 1753 | +		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); | |
| 1754 | 1754 |  		if (file_exists($tmp_dir.'owner_ei.csv')) { | 
| 1755 | 1755 | if ($globalDebug) echo "Add to DB..."; | 
| 1756 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); | |
| 1756 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); | |
| 1757 | 1757 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; | 
| 1758 | 1758 |  		if ($error != '') { | 
| 1759 | 1759 | return $error; | 
| 1760 | 1760 | } elseif ($globalDebug) echo "Done\n"; | 
| 1761 | 1761 | if ($globalDebug) echo "Owner Switzerland: Download..."; | 
| 1762 | -		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); | |
| 1762 | +		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); | |
| 1763 | 1763 |  		if (file_exists($tmp_dir.'owner_hb.csv')) { | 
| 1764 | 1764 | if ($globalDebug) echo "Add to DB..."; | 
| 1765 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); | |
| 1765 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); | |
| 1766 | 1766 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; | 
| 1767 | 1767 |  		if ($error != '') { | 
| 1768 | 1768 | return $error; | 
| 1769 | 1769 | } elseif ($globalDebug) echo "Done\n"; | 
| 1770 | 1770 | if ($globalDebug) echo "Owner Czech Republic: Download..."; | 
| 1771 | -		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); | |
| 1771 | +		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); | |
| 1772 | 1772 |  		if (file_exists($tmp_dir.'owner_ok.csv')) { | 
| 1773 | 1773 | if ($globalDebug) echo "Add to DB..."; | 
| 1774 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); | |
| 1774 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); | |
| 1775 | 1775 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; | 
| 1776 | 1776 |  		if ($error != '') { | 
| 1777 | 1777 | return $error; | 
| 1778 | 1778 | } elseif ($globalDebug) echo "Done\n"; | 
| 1779 | 1779 | if ($globalDebug) echo "Owner Australia: Download..."; | 
| 1780 | -		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); | |
| 1780 | +		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); | |
| 1781 | 1781 |  		if (file_exists($tmp_dir.'owner_vh.csv')) { | 
| 1782 | 1782 | if ($globalDebug) echo "Add to DB..."; | 
| 1783 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); | |
| 1783 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); | |
| 1784 | 1784 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; | 
| 1785 | 1785 |  		if ($error != '') { | 
| 1786 | 1786 | return $error; | 
| 1787 | 1787 | } elseif ($globalDebug) echo "Done\n"; | 
| 1788 | 1788 | if ($globalDebug) echo "Owner Austria: Download..."; | 
| 1789 | -		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); | |
| 1789 | +		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); | |
| 1790 | 1790 |  		if (file_exists($tmp_dir.'owner_oe.csv')) { | 
| 1791 | 1791 | if ($globalDebug) echo "Add to DB..."; | 
| 1792 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); | |
| 1792 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); | |
| 1793 | 1793 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; | 
| 1794 | 1794 |  		if ($error != '') { | 
| 1795 | 1795 | return $error; | 
| 1796 | 1796 | } elseif ($globalDebug) echo "Done\n"; | 
| 1797 | 1797 | if ($globalDebug) echo "Owner Chile: Download..."; | 
| 1798 | -		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); | |
| 1798 | +		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); | |
| 1799 | 1799 |  		if (file_exists($tmp_dir.'owner_cc.csv')) { | 
| 1800 | 1800 | if ($globalDebug) echo "Add to DB..."; | 
| 1801 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); | |
| 1801 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); | |
| 1802 | 1802 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; | 
| 1803 | 1803 |  		if ($error != '') { | 
| 1804 | 1804 | return $error; | 
| 1805 | 1805 | } elseif ($globalDebug) echo "Done\n"; | 
| 1806 | 1806 | if ($globalDebug) echo "Owner Colombia: Download..."; | 
| 1807 | -		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); | |
| 1807 | +		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); | |
| 1808 | 1808 |  		if (file_exists($tmp_dir.'owner_hj.csv')) { | 
| 1809 | 1809 | if ($globalDebug) echo "Add to DB..."; | 
| 1810 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); | |
| 1810 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); | |
| 1811 | 1811 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; | 
| 1812 | 1812 |  		if ($error != '') { | 
| 1813 | 1813 | return $error; | 
| 1814 | 1814 | } elseif ($globalDebug) echo "Done\n"; | 
| 1815 | 1815 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; | 
| 1816 | -		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); | |
| 1816 | +		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); | |
| 1817 | 1817 |  		if (file_exists($tmp_dir.'owner_e7.csv')) { | 
| 1818 | 1818 | if ($globalDebug) echo "Add to DB..."; | 
| 1819 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); | |
| 1819 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); | |
| 1820 | 1820 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; | 
| 1821 | 1821 |  		if ($error != '') { | 
| 1822 | 1822 | return $error; | 
| 1823 | 1823 | } elseif ($globalDebug) echo "Done\n"; | 
| 1824 | 1824 | if ($globalDebug) echo "Owner Brazil: Download..."; | 
| 1825 | -		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); | |
| 1825 | +		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); | |
| 1826 | 1826 |  		if (file_exists($tmp_dir.'owner_pp.csv')) { | 
| 1827 | 1827 | if ($globalDebug) echo "Add to DB..."; | 
| 1828 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); | |
| 1828 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); | |
| 1829 | 1829 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; | 
| 1830 | 1830 |  		if ($error != '') { | 
| 1831 | 1831 | return $error; | 
| 1832 | 1832 | } elseif ($globalDebug) echo "Done\n"; | 
| 1833 | 1833 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; | 
| 1834 | -		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); | |
| 1834 | +		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); | |
| 1835 | 1835 |  		if (file_exists($tmp_dir.'owner_vp.csv')) { | 
| 1836 | 1836 | if ($globalDebug) echo "Add to DB..."; | 
| 1837 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); | |
| 1837 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); | |
| 1838 | 1838 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; | 
| 1839 | 1839 |  		if ($error != '') { | 
| 1840 | 1840 | return $error; | 
| 1841 | 1841 | } elseif ($globalDebug) echo "Done\n"; | 
| 1842 | 1842 | if ($globalDebug) echo "Owner Croatia: Download..."; | 
| 1843 | -		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); | |
| 1843 | +		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); | |
| 1844 | 1844 |  		if (file_exists($tmp_dir.'owner_9a.csv')) { | 
| 1845 | 1845 | if ($globalDebug) echo "Add to DB..."; | 
| 1846 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); | |
| 1846 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); | |
| 1847 | 1847 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; | 
| 1848 | 1848 |  		if ($error != '') { | 
| 1849 | 1849 | return $error; | 
| 1850 | 1850 | } elseif ($globalDebug) echo "Done\n"; | 
| 1851 | 1851 | if ($globalDebug) echo "Owner Luxembourg: Download..."; | 
| 1852 | -		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); | |
| 1852 | +		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); | |
| 1853 | 1853 |  		if (file_exists($tmp_dir.'owner_lx.csv')) { | 
| 1854 | 1854 | if ($globalDebug) echo "Add to DB..."; | 
| 1855 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); | |
| 1855 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); | |
| 1856 | 1856 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; | 
| 1857 | 1857 |  		if ($error != '') { | 
| 1858 | 1858 | return $error; | 
| 1859 | 1859 | } elseif ($globalDebug) echo "Done\n"; | 
| 1860 | 1860 | if ($globalDebug) echo "Owner Maldives: Download..."; | 
| 1861 | -		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); | |
| 1861 | +		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); | |
| 1862 | 1862 |  		if (file_exists($tmp_dir.'owner_8q.csv')) { | 
| 1863 | 1863 | if ($globalDebug) echo "Add to DB..."; | 
| 1864 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); | |
| 1864 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); | |
| 1865 | 1865 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; | 
| 1866 | 1866 |  		if ($error != '') { | 
| 1867 | 1867 | return $error; | 
| 1868 | 1868 | } elseif ($globalDebug) echo "Done\n"; | 
| 1869 | 1869 | if ($globalDebug) echo "Owner New Zealand: Download..."; | 
| 1870 | -		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); | |
| 1870 | +		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); | |
| 1871 | 1871 |  		if (file_exists($tmp_dir.'owner_zk.csv')) { | 
| 1872 | 1872 | if ($globalDebug) echo "Add to DB..."; | 
| 1873 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); | |
| 1873 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); | |
| 1874 | 1874 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; | 
| 1875 | 1875 |  		if ($error != '') { | 
| 1876 | 1876 | return $error; | 
| 1877 | 1877 | } elseif ($globalDebug) echo "Done\n"; | 
| 1878 | 1878 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; | 
| 1879 | -		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); | |
| 1879 | +		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); | |
| 1880 | 1880 |  		if (file_exists($tmp_dir.'owner_p2.csv')) { | 
| 1881 | 1881 | if ($globalDebug) echo "Add to DB..."; | 
| 1882 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); | |
| 1882 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); | |
| 1883 | 1883 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; | 
| 1884 | 1884 |  		if ($error != '') { | 
| 1885 | 1885 | return $error; | 
| 1886 | 1886 | } elseif ($globalDebug) echo "Done\n"; | 
| 1887 | 1887 | if ($globalDebug) echo "Owner Slovakia: Download..."; | 
| 1888 | -		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); | |
| 1888 | +		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); | |
| 1889 | 1889 |  		if (file_exists($tmp_dir.'owner_om.csv')) { | 
| 1890 | 1890 | if ($globalDebug) echo "Add to DB..."; | 
| 1891 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); | |
| 1891 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); | |
| 1892 | 1892 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; | 
| 1893 | 1893 |  		if ($error != '') { | 
| 1894 | 1894 | return $error; | 
| 1895 | 1895 | } elseif ($globalDebug) echo "Done\n"; | 
| 1896 | 1896 | if ($globalDebug) echo "Owner Ecuador: Download..."; | 
| 1897 | -		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); | |
| 1897 | +		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); | |
| 1898 | 1898 |  		if (file_exists($tmp_dir.'owner_hc.csv')) { | 
| 1899 | 1899 | if ($globalDebug) echo "Add to DB..."; | 
| 1900 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); | |
| 1900 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); | |
| 1901 | 1901 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; | 
| 1902 | 1902 |  		if ($error != '') { | 
| 1903 | 1903 | return $error; | 
| 1904 | 1904 | } elseif ($globalDebug) echo "Done\n"; | 
| 1905 | 1905 | if ($globalDebug) echo "Owner Iceland: Download..."; | 
| 1906 | -		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); | |
| 1906 | +		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); | |
| 1907 | 1907 |  		if (file_exists($tmp_dir.'owner_tf.csv')) { | 
| 1908 | 1908 | if ($globalDebug) echo "Add to DB..."; | 
| 1909 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); | |
| 1909 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); | |
| 1910 | 1910 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; | 
| 1911 | 1911 |  		if ($error != '') { | 
| 1912 | 1912 | return $error; | 
| 1913 | 1913 | } elseif ($globalDebug) echo "Done\n"; | 
| 1914 | 1914 | if ($globalDebug) echo "Owner Isle of Man: Download..."; | 
| 1915 | -		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); | |
| 1915 | +		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); | |
| 1916 | 1916 |  		if (file_exists($tmp_dir.'owner_m.csv')) { | 
| 1917 | 1917 | if ($globalDebug) echo "Add to DB..."; | 
| 1918 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); | |
| 1918 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); | |
| 1919 | 1919 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; | 
| 1920 | 1920 |  		if ($error != '') { | 
| 1921 | 1921 | return $error; | 
| 1922 | 1922 | } elseif ($globalDebug) echo "Done\n"; | 
| 1923 | 1923 |  		if ($globalMasterSource) { | 
| 1924 | 1924 | if ($globalDebug) echo "ModeS Netherlands: Download..."; | 
| 1925 | -			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); | |
| 1925 | +			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); | |
| 1926 | 1926 |  			if (file_exists($tmp_dir.'owner_ph.csv')) { | 
| 1927 | 1927 | if ($globalDebug) echo "Add to DB..."; | 
| 1928 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); | |
| 1928 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); | |
| 1929 | 1929 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; | 
| 1930 | 1930 |  			if ($error != '') { | 
| 1931 | 1931 | return $error; | 
| 1932 | 1932 | } elseif ($globalDebug) echo "Done\n"; | 
| 1933 | 1933 | if ($globalDebug) echo "ModeS Denmark: Download..."; | 
| 1934 | -			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); | |
| 1934 | +			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); | |
| 1935 | 1935 |  			if (file_exists($tmp_dir.'owner_oy.csv')) { | 
| 1936 | 1936 | if ($globalDebug) echo "Add to DB..."; | 
| 1937 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); | |
| 1937 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); | |
| 1938 | 1938 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; | 
| 1939 | 1939 |  			if ($error != '') { | 
| 1940 | 1940 | return $error; | 
| @@ -1947,7 +1947,7 @@ discard block | ||
| 1947 | 1947 | global $tmp_dir, $globalDebug; | 
| 1948 | 1948 | $error = ''; | 
| 1949 | 1949 | if ($globalDebug) echo "Translation : Download..."; | 
| 1950 | -		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); | |
| 1950 | +		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); | |
| 1951 | 1951 |  		if (file_exists($tmp_dir.'translation.zip')) { | 
| 1952 | 1952 | if ($globalDebug) echo "Unzip..."; | 
| 1953 | 1953 | update_db::unzip($tmp_dir.'translation.zip'); | 
| @@ -1963,7 +1963,7 @@ discard block | ||
| 1963 | 1963 |  	public static function update_translation_fam() { | 
| 1964 | 1964 | global $tmp_dir, $globalDebug; | 
| 1965 | 1965 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; | 
| 1966 | -		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); | |
| 1966 | +		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); | |
| 1967 | 1967 |  		if (file_exists($tmp_dir.'translation.tsv.gz')) { | 
| 1968 | 1968 | if ($globalDebug) echo "Gunzip..."; | 
| 1969 | 1969 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); | 
| @@ -1978,7 +1978,7 @@ discard block | ||
| 1978 | 1978 |  	public static function update_ModeS_fam() { | 
| 1979 | 1979 | global $tmp_dir, $globalDebug; | 
| 1980 | 1980 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; | 
| 1981 | -		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); | |
| 1981 | +		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); | |
| 1982 | 1982 |  		if (file_exists($tmp_dir.'modes.tsv.gz')) { | 
| 1983 | 1983 | if ($globalDebug) echo "Gunzip..."; | 
| 1984 | 1984 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); | 
| @@ -1994,9 +1994,9 @@ discard block | ||
| 1994 | 1994 | global $tmp_dir, $globalDebug, $globalOwner; | 
| 1995 | 1995 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; | 
| 1996 | 1996 |  		if ($globalOwner === TRUE) { | 
| 1997 | -			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); | |
| 1997 | +			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); | |
| 1998 | 1998 |  		} else { | 
| 1999 | -			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); | |
| 1999 | +			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); | |
| 2000 | 2000 | } | 
| 2001 | 2001 |  		if (file_exists($tmp_dir.'owners.tsv.gz')) { | 
| 2002 | 2002 | if ($globalDebug) echo "Gunzip..."; | 
| @@ -2012,7 +2012,7 @@ discard block | ||
| 2012 | 2012 |  	public static function update_routes_fam() { | 
| 2013 | 2013 | global $tmp_dir, $globalDebug; | 
| 2014 | 2014 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; | 
| 2015 | -		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); | |
| 2015 | +		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); | |
| 2016 | 2016 |  		if (file_exists($tmp_dir.'routes.tsv.gz')) { | 
| 2017 | 2017 | if ($globalDebug) echo "Gunzip..."; | 
| 2018 | 2018 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); | 
| @@ -2026,13 +2026,13 @@ discard block | ||
| 2026 | 2026 | } | 
| 2027 | 2027 |  	public static function update_marine_identity_fam() { | 
| 2028 | 2028 | global $tmp_dir, $globalDebug; | 
| 2029 | -		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); | |
| 2029 | +		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); | |
| 2030 | 2030 |  		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { | 
| 2031 | -			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); | |
| 2031 | +			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); | |
| 2032 | 2032 | $marine_identity_md5 = $marine_identity_md5_file[0]; | 
| 2033 | 2033 |  			if (!update_db::check_marine_identity_version($marine_identity_md5)) { | 
| 2034 | 2034 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; | 
| 2035 | -				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); | |
| 2035 | +				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); | |
| 2036 | 2036 |  				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { | 
| 2037 | 2037 | if ($globalDebug) echo "Gunzip..."; | 
| 2038 | 2038 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); | 
| @@ -2052,7 +2052,7 @@ discard block | ||
| 2052 | 2052 |  	public static function update_banned_fam() { | 
| 2053 | 2053 | global $tmp_dir, $globalDebug; | 
| 2054 | 2054 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; | 
| 2055 | -		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); | |
| 2055 | +		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); | |
| 2056 | 2056 |  		if (file_exists($tmp_dir.'ban_eu.csv')) { | 
| 2057 | 2057 | //if ($globalDebug) echo "Gunzip..."; | 
| 2058 | 2058 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); | 
| @@ -2071,18 +2071,18 @@ discard block | ||
| 2071 | 2071 | $error = ''; | 
| 2072 | 2072 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; | 
| 2073 | 2073 |  		if ($globalDBdriver == 'mysql') { | 
| 2074 | -			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | |
| 2074 | +			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); | |
| 2075 | 2075 |  		} else { | 
| 2076 | -			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | |
| 2076 | +			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); | |
| 2077 | 2077 | } | 
| 2078 | 2078 |  		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { | 
| 2079 | -			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); | |
| 2079 | +			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); | |
| 2080 | 2080 | $airspace_md5 = $airspace_md5_file[0]; | 
| 2081 | 2081 |  			if (!update_db::check_airspace_version($airspace_md5)) { | 
| 2082 | 2082 |  				if ($globalDBdriver == 'mysql') { | 
| 2083 | -					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); | |
| 2083 | +					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); | |
| 2084 | 2084 |  				} else { | 
| 2085 | -					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); | |
| 2085 | +					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); | |
| 2086 | 2086 | } | 
| 2087 | 2087 |  				if (file_exists($tmp_dir.'airspace.sql.gz')) { | 
| 2088 | 2088 | if ($globalDebug) echo "Gunzip..."; | 
| @@ -2094,7 +2094,7 @@ discard block | ||
| 2094 | 2094 |  						try { | 
| 2095 | 2095 | $sth = $Connection->db->prepare($query); | 
| 2096 | 2096 | $sth->execute(); | 
| 2097 | -			            		} catch(PDOException $e) { | |
| 2097 | +			            		} catch (PDOException $e) { | |
| 2098 | 2098 | return "error : ".$e->getMessage(); | 
| 2099 | 2099 | } | 
| 2100 | 2100 | } | 
| @@ -2112,15 +2112,15 @@ discard block | ||
| 2112 | 2112 |  	public static function update_tle() { | 
| 2113 | 2113 | global $tmp_dir, $globalDebug; | 
| 2114 | 2114 | if ($globalDebug) echo "Download TLE : Download..."; | 
| 2115 | -		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', | |
| 2116 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', | |
| 2117 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); | |
| 2115 | +		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', | |
| 2116 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', | |
| 2117 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); | |
| 2118 | 2118 |  		foreach ($alltle as $filename) { | 
| 2119 | 2119 | if ($globalDebug) echo "downloading ".$filename.'...'; | 
| 2120 | -			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); | |
| 2120 | +			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); | |
| 2121 | 2121 |  			if (file_exists($tmp_dir.$filename)) { | 
| 2122 | 2122 | if ($globalDebug) echo "Add to DB ".$filename."..."; | 
| 2123 | -				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); | |
| 2123 | +				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); | |
| 2124 | 2124 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; | 
| 2125 | 2125 |  			if ($error != '') { | 
| 2126 | 2126 | echo $error."\n"; | 
| @@ -2133,32 +2133,32 @@ discard block | ||
| 2133 | 2133 | global $tmp_dir, $globalDebug; | 
| 2134 | 2134 | $error = ''; | 
| 2135 | 2135 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; | 
| 2136 | -		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); | |
| 2136 | +		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); | |
| 2137 | 2137 |  		if (file_exists($tmp_dir.'models.md5sum')) { | 
| 2138 | 2138 | if ($globalDebug) echo "Check files...\n"; | 
| 2139 | 2139 | $newmodelsdb = array(); | 
| 2140 | -			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { | |
| 2141 | -				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2140 | +			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { | |
| 2141 | +				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2142 | 2142 | $model = trim($row[2]); | 
| 2143 | 2143 | $newmodelsdb[$model] = trim($row[0]); | 
| 2144 | 2144 | } | 
| 2145 | 2145 | } | 
| 2146 | 2146 | $modelsdb = array(); | 
| 2147 | 2147 |  			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { | 
| 2148 | -				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { | |
| 2149 | -					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2148 | +				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { | |
| 2149 | +					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2150 | 2150 | $model = trim($row[2]); | 
| 2151 | 2151 | $modelsdb[$model] = trim($row[0]); | 
| 2152 | 2152 | } | 
| 2153 | 2153 | } | 
| 2154 | 2154 | } | 
| 2155 | - $diff = array_diff($newmodelsdb,$modelsdb); | |
| 2155 | + $diff = array_diff($newmodelsdb, $modelsdb); | |
| 2156 | 2156 |  			foreach ($diff as $key => $value) { | 
| 2157 | 2157 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; | 
| 2158 | -				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); | |
| 2158 | +				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); | |
| 2159 | 2159 | |
| 2160 | 2160 | } | 
| 2161 | -			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); | |
| 2161 | +			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); | |
| 2162 | 2162 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; | 
| 2163 | 2163 |  		if ($error != '') { | 
| 2164 | 2164 | return $error; | 
| @@ -2170,32 +2170,32 @@ discard block | ||
| 2170 | 2170 | global $tmp_dir, $globalDebug; | 
| 2171 | 2171 | $error = ''; | 
| 2172 | 2172 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; | 
| 2173 | -		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); | |
| 2173 | +		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); | |
| 2174 | 2174 |  		if (file_exists($tmp_dir.'space_models.md5sum')) { | 
| 2175 | 2175 | if ($globalDebug) echo "Check files...\n"; | 
| 2176 | 2176 | $newmodelsdb = array(); | 
| 2177 | -			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { | |
| 2178 | -				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2177 | +			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { | |
| 2178 | +				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2179 | 2179 | $model = trim($row[2]); | 
| 2180 | 2180 | $newmodelsdb[$model] = trim($row[0]); | 
| 2181 | 2181 | } | 
| 2182 | 2182 | } | 
| 2183 | 2183 | $modelsdb = array(); | 
| 2184 | 2184 |  			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { | 
| 2185 | -				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { | |
| 2186 | -					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2185 | +				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { | |
| 2186 | +					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2187 | 2187 | $model = trim($row[2]); | 
| 2188 | 2188 | $modelsdb[$model] = trim($row[0]); | 
| 2189 | 2189 | } | 
| 2190 | 2190 | } | 
| 2191 | 2191 | } | 
| 2192 | - $diff = array_diff($newmodelsdb,$modelsdb); | |
| 2192 | + $diff = array_diff($newmodelsdb, $modelsdb); | |
| 2193 | 2193 |  			foreach ($diff as $key => $value) { | 
| 2194 | 2194 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; | 
| 2195 | -				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); | |
| 2195 | +				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); | |
| 2196 | 2196 | |
| 2197 | 2197 | } | 
| 2198 | -			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); | |
| 2198 | +			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); | |
| 2199 | 2199 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; | 
| 2200 | 2200 |  		if ($error != '') { | 
| 2201 | 2201 | return $error; | 
| @@ -2207,32 +2207,32 @@ discard block | ||
| 2207 | 2207 | global $tmp_dir, $globalDebug; | 
| 2208 | 2208 | $error = ''; | 
| 2209 | 2209 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; | 
| 2210 | -		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); | |
| 2210 | +		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); | |
| 2211 | 2211 |  		if (file_exists($tmp_dir.'vehicules_models.md5sum')) { | 
| 2212 | 2212 | if ($globalDebug) echo "Check files...\n"; | 
| 2213 | 2213 | $newmodelsdb = array(); | 
| 2214 | -			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { | |
| 2215 | -				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2214 | +			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { | |
| 2215 | +				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2216 | 2216 | $model = trim($row[2]); | 
| 2217 | 2217 | $newmodelsdb[$model] = trim($row[0]); | 
| 2218 | 2218 | } | 
| 2219 | 2219 | } | 
| 2220 | 2220 | $modelsdb = array(); | 
| 2221 | 2221 |  			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { | 
| 2222 | -				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { | |
| 2223 | -					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | |
| 2222 | +				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { | |
| 2223 | +					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { | |
| 2224 | 2224 | $model = trim($row[2]); | 
| 2225 | 2225 | $modelsdb[$model] = trim($row[0]); | 
| 2226 | 2226 | } | 
| 2227 | 2227 | } | 
| 2228 | 2228 | } | 
| 2229 | - $diff = array_diff($newmodelsdb,$modelsdb); | |
| 2229 | + $diff = array_diff($newmodelsdb, $modelsdb); | |
| 2230 | 2230 |  			foreach ($diff as $key => $value) { | 
| 2231 | 2231 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; | 
| 2232 | -				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); | |
| 2232 | +				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); | |
| 2233 | 2233 | |
| 2234 | 2234 | } | 
| 2235 | -			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); | |
| 2235 | +			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); | |
| 2236 | 2236 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; | 
| 2237 | 2237 |  		if ($error != '') { | 
| 2238 | 2238 | return $error; | 
| @@ -2255,8 +2255,8 @@ discard block | ||
| 2255 | 2255 | */ | 
| 2256 | 2256 |  		if (file_exists($tmp_dir.'aircrafts.html')) { | 
| 2257 | 2257 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); | 
| 2258 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); | |
| 2259 | - $result = fread($fh,100000000); | |
| 2258 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); | |
| 2259 | + $result = fread($fh, 100000000); | |
| 2260 | 2260 | //echo $result; | 
| 2261 | 2261 | //var_dump(str_get_html($result)); | 
| 2262 | 2262 | //print_r(self::table2array($result)); | 
| @@ -2274,23 +2274,23 @@ discard block | ||
| 2274 | 2274 | $Connection = new Connection(); | 
| 2275 | 2275 | $sth = $Connection->db->prepare($query); | 
| 2276 | 2276 | $sth->execute(); | 
| 2277 | -                } catch(PDOException $e) { | |
| 2277 | +                } catch (PDOException $e) { | |
| 2278 | 2278 | return "error : ".$e->getMessage(); | 
| 2279 | 2279 | } | 
| 2280 | 2280 | |
| 2281 | 2281 | $error = ''; | 
| 2282 | 2282 | if ($globalDebug) echo "Notam : Download..."; | 
| 2283 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); | |
| 2283 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); | |
| 2284 | 2284 |  		if (file_exists($tmp_dir.'notam.rss')) { | 
| 2285 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); | |
| 2285 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); | |
| 2286 | 2286 |  			foreach ($notams['channel']['item'] as $notam) { | 
| 2287 | -				$title = explode(':',$notam['title']); | |
| 2287 | +				$title = explode(':', $notam['title']); | |
| 2288 | 2288 | $data['ref'] = trim($title[0]); | 
| 2289 | 2289 | unset($title[0]); | 
| 2290 | -				$data['title'] = trim(implode(':',$title)); | |
| 2291 | - $description = strip_tags($notam['description'],'<pre>'); | |
| 2292 | -				preg_match(':^(.*?)<pre>:',$description,$match); | |
| 2293 | -				$q = explode('/',$match[1]); | |
| 2290 | +				$data['title'] = trim(implode(':', $title)); | |
| 2291 | + $description = strip_tags($notam['description'], '<pre>'); | |
| 2292 | +				preg_match(':^(.*?)<pre>:', $description, $match); | |
| 2293 | +				$q = explode('/', $match[1]); | |
| 2294 | 2294 | $data['fir'] = $q[0]; | 
| 2295 | 2295 | $data['code'] = $q[1]; | 
| 2296 | 2296 | $ifrvfr = $q[2]; | 
| @@ -2306,30 +2306,30 @@ discard block | ||
| 2306 | 2306 | $data['lower_limit'] = $q[5]; | 
| 2307 | 2307 | $data['upper_limit'] = $q[6]; | 
| 2308 | 2308 | $latlonrad = $q[7]; | 
| 2309 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); | |
| 2310 | - $latitude = $Common->convertDec($las,'latitude'); | |
| 2311 | - $longitude = $Common->convertDec($lns,'longitude'); | |
| 2309 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); | |
| 2310 | + $latitude = $Common->convertDec($las, 'latitude'); | |
| 2311 | + $longitude = $Common->convertDec($lns, 'longitude'); | |
| 2312 | 2312 | if ($lac == 'S') $latitude = '-'.$latitude; | 
| 2313 | 2313 | if ($lnc == 'W') $longitude = '-'.$longitude; | 
| 2314 | 2314 | $data['center_latitude'] = $latitude; | 
| 2315 | 2315 | $data['center_longitude'] = $longitude; | 
| 2316 | 2316 | $data['radius'] = intval($radius); | 
| 2317 | 2317 | |
| 2318 | -				preg_match(':<pre>(.*?)</pre>:',$description,$match); | |
| 2318 | +				preg_match(':<pre>(.*?)</pre>:', $description, $match); | |
| 2319 | 2319 | $data['text'] = $match[1]; | 
| 2320 | -				preg_match(':</pre>(.*?)$:',$description,$match); | |
| 2320 | +				preg_match(':</pre>(.*?)$:', $description, $match); | |
| 2321 | 2321 | $fromto = $match[1]; | 
| 2322 | -				preg_match('#FROM:(.*?)TO:#',$fromto,$match); | |
| 2322 | +				preg_match('#FROM:(.*?)TO:#', $fromto, $match); | |
| 2323 | 2323 | $fromall = trim($match[1]); | 
| 2324 | -				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); | |
| 2324 | +				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); | |
| 2325 | 2325 | $from = trim($match[1]); | 
| 2326 | -				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); | |
| 2327 | -				preg_match('#TO:(.*?)$#',$fromto,$match); | |
| 2326 | +				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); | |
| 2327 | +				preg_match('#TO:(.*?)$#', $fromto, $match); | |
| 2328 | 2328 | $toall = trim($match[1]); | 
| 2329 | -				if (!preg_match(':Permanent:',$toall)) { | |
| 2330 | -					preg_match('#^(.*?) \((.*?)\)#',$toall,$match); | |
| 2329 | +				if (!preg_match(':Permanent:', $toall)) { | |
| 2330 | +					preg_match('#^(.*?) \((.*?)\)#', $toall, $match); | |
| 2331 | 2331 | $to = trim($match[1]); | 
| 2332 | -					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); | |
| 2332 | +					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); | |
| 2333 | 2333 | $data['permanent'] = 0; | 
| 2334 | 2334 |  				} else { | 
| 2335 | 2335 | $data['date_end'] = NULL; | 
| @@ -2337,7 +2337,7 @@ discard block | ||
| 2337 | 2337 | } | 
| 2338 | 2338 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; | 
| 2339 | 2339 | $NOTAM = new NOTAM(); | 
| 2340 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 2340 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); | |
| 2341 | 2341 | unset($data); | 
| 2342 | 2342 | } | 
| 2343 | 2343 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; | 
| @@ -2360,16 +2360,16 @@ discard block | ||
| 2360 | 2360 | $Connection = new Connection(); | 
| 2361 | 2361 | $sth = $Connection->db->prepare($query); | 
| 2362 | 2362 | $sth->execute(); | 
| 2363 | -			} catch(PDOException $e) { | |
| 2363 | +			} catch (PDOException $e) { | |
| 2364 | 2364 | return "error : ".$e->getMessage(); | 
| 2365 | 2365 | } | 
| 2366 | 2366 | } | 
| 2367 | 2367 | $Common = new Common(); | 
| 2368 | 2368 |  		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); | 
| 2369 | - $airspace_json = json_decode($airspace_lst,true); | |
| 2369 | + $airspace_json = json_decode($airspace_lst, true); | |
| 2370 | 2370 |  		foreach ($airspace_json['records'] as $airspace) { | 
| 2371 | 2371 | if ($globalDebug) echo $airspace['name']."...\n"; | 
| 2372 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); | |
| 2372 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); | |
| 2373 | 2373 |  			if (file_exists($tmp_dir.$airspace['name'])) { | 
| 2374 | 2374 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); | 
| 2375 | 2375 |  				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']); | 
| @@ -2391,7 +2391,7 @@ discard block | ||
| 2391 | 2391 | $Connection = new Connection(); | 
| 2392 | 2392 | $sth = $Connection->db->prepare($query); | 
| 2393 | 2393 |  				$sth->execute(array(':new' => $new, ':old' => $old)); | 
| 2394 | -			} catch(PDOException $e) { | |
| 2394 | +			} catch (PDOException $e) { | |
| 2395 | 2395 | return "error : ".$e->getMessage(); | 
| 2396 | 2396 | } | 
| 2397 | 2397 | } | 
| @@ -2408,7 +2408,7 @@ discard block | ||
| 2408 | 2408 | $Connection = new Connection(); | 
| 2409 | 2409 | $sth = $Connection->db->prepare($query); | 
| 2410 | 2410 | $sth->execute(); | 
| 2411 | -                } catch(PDOException $e) { | |
| 2411 | +                } catch (PDOException $e) { | |
| 2412 | 2412 | return "error : ".$e->getMessage(); | 
| 2413 | 2413 | } | 
| 2414 | 2414 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2423,7 +2423,7 @@ discard block | ||
| 2423 | 2423 | $Connection = new Connection(); | 
| 2424 | 2424 | $sth = $Connection->db->prepare($query); | 
| 2425 | 2425 | $sth->execute(); | 
| 2426 | -                } catch(PDOException $e) { | |
| 2426 | +                } catch (PDOException $e) { | |
| 2427 | 2427 | return "error : ".$e->getMessage(); | 
| 2428 | 2428 | } | 
| 2429 | 2429 | } | 
| @@ -2434,7 +2434,7 @@ discard block | ||
| 2434 | 2434 | $Connection = new Connection(); | 
| 2435 | 2435 | $sth = $Connection->db->prepare($query); | 
| 2436 | 2436 |                          $sth->execute(array(':version' => $version)); | 
| 2437 | -                } catch(PDOException $e) { | |
| 2437 | +                } catch (PDOException $e) { | |
| 2438 | 2438 | return "error : ".$e->getMessage(); | 
| 2439 | 2439 | } | 
| 2440 | 2440 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2448,7 +2448,7 @@ discard block | ||
| 2448 | 2448 | $Connection = new Connection(); | 
| 2449 | 2449 | $sth = $Connection->db->prepare($query); | 
| 2450 | 2450 |                          $sth->execute(array(':version' => $version)); | 
| 2451 | -                } catch(PDOException $e) { | |
| 2451 | +                } catch (PDOException $e) { | |
| 2452 | 2452 | return "error : ".$e->getMessage(); | 
| 2453 | 2453 | } | 
| 2454 | 2454 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2464,7 +2464,7 @@ discard block | ||
| 2464 | 2464 | $Connection = new Connection(); | 
| 2465 | 2465 | $sth = $Connection->db->prepare($query); | 
| 2466 | 2466 |                          $sth->execute(array(':version' => $version)); | 
| 2467 | -                } catch(PDOException $e) { | |
| 2467 | +                } catch (PDOException $e) { | |
| 2468 | 2468 | return "error : ".$e->getMessage(); | 
| 2469 | 2469 | } | 
| 2470 | 2470 | } | 
| @@ -2476,7 +2476,7 @@ discard block | ||
| 2476 | 2476 | $Connection = new Connection(); | 
| 2477 | 2477 | $sth = $Connection->db->prepare($query); | 
| 2478 | 2478 |                          $sth->execute(array(':version' => $version)); | 
| 2479 | -                } catch(PDOException $e) { | |
| 2479 | +                } catch (PDOException $e) { | |
| 2480 | 2480 | return "error : ".$e->getMessage(); | 
| 2481 | 2481 | } | 
| 2482 | 2482 | } | 
| @@ -2492,7 +2492,7 @@ discard block | ||
| 2492 | 2492 | $Connection = new Connection(); | 
| 2493 | 2493 | $sth = $Connection->db->prepare($query); | 
| 2494 | 2494 | $sth->execute(); | 
| 2495 | -                } catch(PDOException $e) { | |
| 2495 | +                } catch (PDOException $e) { | |
| 2496 | 2496 | return "error : ".$e->getMessage(); | 
| 2497 | 2497 | } | 
| 2498 | 2498 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2507,7 +2507,7 @@ discard block | ||
| 2507 | 2507 | $Connection = new Connection(); | 
| 2508 | 2508 | $sth = $Connection->db->prepare($query); | 
| 2509 | 2509 | $sth->execute(); | 
| 2510 | -                } catch(PDOException $e) { | |
| 2510 | +                } catch (PDOException $e) { | |
| 2511 | 2511 | return "error : ".$e->getMessage(); | 
| 2512 | 2512 | } | 
| 2513 | 2513 | } | 
| @@ -2522,7 +2522,7 @@ discard block | ||
| 2522 | 2522 | $Connection = new Connection(); | 
| 2523 | 2523 | $sth = $Connection->db->prepare($query); | 
| 2524 | 2524 | $sth->execute(); | 
| 2525 | -                } catch(PDOException $e) { | |
| 2525 | +                } catch (PDOException $e) { | |
| 2526 | 2526 | return "error : ".$e->getMessage(); | 
| 2527 | 2527 | } | 
| 2528 | 2528 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2537,7 +2537,7 @@ discard block | ||
| 2537 | 2537 | $Connection = new Connection(); | 
| 2538 | 2538 | $sth = $Connection->db->prepare($query); | 
| 2539 | 2539 | $sth->execute(); | 
| 2540 | -                } catch(PDOException $e) { | |
| 2540 | +                } catch (PDOException $e) { | |
| 2541 | 2541 | return "error : ".$e->getMessage(); | 
| 2542 | 2542 | } | 
| 2543 | 2543 | } | 
| @@ -2553,7 +2553,7 @@ discard block | ||
| 2553 | 2553 | $Connection = new Connection(); | 
| 2554 | 2554 | $sth = $Connection->db->prepare($query); | 
| 2555 | 2555 | $sth->execute(); | 
| 2556 | -                } catch(PDOException $e) { | |
| 2556 | +                } catch (PDOException $e) { | |
| 2557 | 2557 | return "error : ".$e->getMessage(); | 
| 2558 | 2558 | } | 
| 2559 | 2559 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2568,7 +2568,7 @@ discard block | ||
| 2568 | 2568 | $Connection = new Connection(); | 
| 2569 | 2569 | $sth = $Connection->db->prepare($query); | 
| 2570 | 2570 | $sth->execute(); | 
| 2571 | -                } catch(PDOException $e) { | |
| 2571 | +                } catch (PDOException $e) { | |
| 2572 | 2572 | return "error : ".$e->getMessage(); | 
| 2573 | 2573 | } | 
| 2574 | 2574 | } | 
| @@ -2583,7 +2583,7 @@ discard block | ||
| 2583 | 2583 | $Connection = new Connection(); | 
| 2584 | 2584 | $sth = $Connection->db->prepare($query); | 
| 2585 | 2585 | $sth->execute(); | 
| 2586 | -                } catch(PDOException $e) { | |
| 2586 | +                } catch (PDOException $e) { | |
| 2587 | 2587 | return "error : ".$e->getMessage(); | 
| 2588 | 2588 | } | 
| 2589 | 2589 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2598,7 +2598,7 @@ discard block | ||
| 2598 | 2598 | $Connection = new Connection(); | 
| 2599 | 2599 | $sth = $Connection->db->prepare($query); | 
| 2600 | 2600 | $sth->execute(); | 
| 2601 | -                } catch(PDOException $e) { | |
| 2601 | +                } catch (PDOException $e) { | |
| 2602 | 2602 | return "error : ".$e->getMessage(); | 
| 2603 | 2603 | } | 
| 2604 | 2604 | } | 
| @@ -2613,7 +2613,7 @@ discard block | ||
| 2613 | 2613 | $Connection = new Connection(); | 
| 2614 | 2614 | $sth = $Connection->db->prepare($query); | 
| 2615 | 2615 | $sth->execute(); | 
| 2616 | -                } catch(PDOException $e) { | |
| 2616 | +                } catch (PDOException $e) { | |
| 2617 | 2617 | return "error : ".$e->getMessage(); | 
| 2618 | 2618 | } | 
| 2619 | 2619 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2628,7 +2628,7 @@ discard block | ||
| 2628 | 2628 | $Connection = new Connection(); | 
| 2629 | 2629 | $sth = $Connection->db->prepare($query); | 
| 2630 | 2630 | $sth->execute(); | 
| 2631 | -                } catch(PDOException $e) { | |
| 2631 | +                } catch (PDOException $e) { | |
| 2632 | 2632 | return "error : ".$e->getMessage(); | 
| 2633 | 2633 | } | 
| 2634 | 2634 | } | 
| @@ -2643,7 +2643,7 @@ discard block | ||
| 2643 | 2643 | $Connection = new Connection(); | 
| 2644 | 2644 | $sth = $Connection->db->prepare($query); | 
| 2645 | 2645 | $sth->execute(); | 
| 2646 | -                } catch(PDOException $e) { | |
| 2646 | +                } catch (PDOException $e) { | |
| 2647 | 2647 | return "error : ".$e->getMessage(); | 
| 2648 | 2648 | } | 
| 2649 | 2649 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -2658,7 +2658,7 @@ discard block | ||
| 2658 | 2658 | $Connection = new Connection(); | 
| 2659 | 2659 | $sth = $Connection->db->prepare($query); | 
| 2660 | 2660 | $sth->execute(); | 
| 2661 | -                } catch(PDOException $e) { | |
| 2661 | +                } catch (PDOException $e) { | |
| 2662 | 2662 | return "error : ".$e->getMessage(); | 
| 2663 | 2663 | } | 
| 2664 | 2664 | } | 
| @@ -2673,7 +2673,7 @@ discard block | ||
| 2673 | 2673 | $Connection = new Connection(); | 
| 2674 | 2674 | $sth = $Connection->db->prepare($query); | 
| 2675 | 2675 | $sth->execute(); | 
| 2676 | -                } catch(PDOException $e) { | |
| 2676 | +                } catch (PDOException $e) { | |
| 2677 | 2677 | return "error : ".$e->getMessage(); | 
| 2678 | 2678 | } | 
| 2679 | 2679 | } | 
| @@ -2688,7 +2688,7 @@ discard block | ||
| 2688 | 2688 | $Connection = new Connection(); | 
| 2689 | 2689 | $sth = $Connection->db->prepare($query); | 
| 2690 | 2690 | $sth->execute(); | 
| 2691 | -                } catch(PDOException $e) { | |
| 2691 | +                } catch (PDOException $e) { | |
| 2692 | 2692 | return "error : ".$e->getMessage(); | 
| 2693 | 2693 | } | 
| 2694 | 2694 | } | 
| @@ -982,7 +982,7 @@ discard block | ||
| 982 | 982 |  		try { | 
| 983 | 983 | $sth = $this->db->prepare($query); | 
| 984 | 984 | $sth->execute($query_values); | 
| 985 | -		} catch(PDOException $e) { | |
| 985 | +		} catch (PDOException $e) { | |
| 986 | 986 | echo "error : ".$e->getMessage(); | 
| 987 | 987 | } | 
| 988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1000,19 +1000,19 @@ discard block | ||
| 1000 | 1000 |  		try { | 
| 1001 | 1001 | $sth = $this->db->prepare($query); | 
| 1002 | 1002 | $sth->execute($query_values); | 
| 1003 | -		} catch(PDOException $e) { | |
| 1003 | +		} catch (PDOException $e) { | |
| 1004 | 1004 | echo "error : ".$e->getMessage(); | 
| 1005 | 1005 | } | 
| 1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| 1007 | 1007 | return $all; | 
| 1008 | 1008 | } | 
| 1009 | 1009 |  	public function getAllNOTAMtext() { | 
| 1010 | - $query = 'SELECT full_notam FROM notam'; | |
| 1010 | + $query = 'SELECT full_notam FROM notam'; | |
| 1011 | 1011 | $query_values = array(); | 
| 1012 | 1012 |  		try { | 
| 1013 | 1013 | $sth = $this->db->prepare($query); | 
| 1014 | 1014 | $sth->execute($query_values); | 
| 1015 | -		} catch(PDOException $e) { | |
| 1015 | +		} catch (PDOException $e) { | |
| 1016 | 1016 | echo "error : ".$e->getMessage(); | 
| 1017 | 1017 | } | 
| 1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1021,13 +1021,13 @@ discard block | ||
| 1021 | 1021 |  	public function createNOTAMtextFile($filename) { | 
| 1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); | 
| 1023 | 1023 | $notamtext = ''; | 
| 1024 | -		foreach($allnotam_result as $notam) { | |
| 1024 | +		foreach ($allnotam_result as $notam) { | |
| 1025 | 1025 | $notamtext .= '%%'."\n"; | 
| 1026 | 1026 | $notamtext .= $notam['full_notam']; | 
| 1027 | 1027 | $notamtext .= "\n".'%%'."\n"; | 
| 1028 | 1028 | } | 
| 1029 | 1029 |  		//$allnotam = implode('\n%%%%\n',$allnotam_result); | 
| 1030 | - file_put_contents($filename,$notamtext); | |
| 1030 | + file_put_contents($filename, $notamtext); | |
| 1031 | 1031 | } | 
| 1032 | 1032 |  	public function parseNOTAMtextFile($filename) { | 
| 1033 | 1033 | $data = file_get_contents($filename); | 
| @@ -1048,7 +1048,7 @@ discard block | ||
| 1048 | 1048 |  		try { | 
| 1049 | 1049 | $sth = $this->db->prepare($query); | 
| 1050 | 1050 | $sth->execute($query_values); | 
| 1051 | -		} catch(PDOException $e) { | |
| 1051 | +		} catch (PDOException $e) { | |
| 1052 | 1052 | echo "error : ".$e->getMessage(); | 
| 1053 | 1053 | } | 
| 1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1057,10 +1057,10 @@ discard block | ||
| 1057 | 1057 |  	public function getAllNOTAMbyCoord($coord) { | 
| 1058 | 1058 | global $globalDBdriver; | 
| 1059 | 1059 |  		if (is_array($coord)) { | 
| 1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1064 | 1064 |  			if ($minlat > $maxlat) { | 
| 1065 | 1065 | $tmplat = $minlat; | 
| 1066 | 1066 | $minlat = $maxlat; | 
| @@ -1082,19 +1082,19 @@ discard block | ||
| 1082 | 1082 |  		try { | 
| 1083 | 1083 | $sth = $this->db->prepare($query); | 
| 1084 | 1084 | $sth->execute($query_values); | 
| 1085 | -		} catch(PDOException $e) { | |
| 1085 | +		} catch (PDOException $e) { | |
| 1086 | 1086 | echo "error : ".$e->getMessage(); | 
| 1087 | 1087 | } | 
| 1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| 1089 | 1089 | return $all; | 
| 1090 | 1090 | } | 
| 1091 | -	public function getAllNOTAMbyCoordScope($coord,$scope) { | |
| 1091 | +	public function getAllNOTAMbyCoordScope($coord, $scope) { | |
| 1092 | 1092 | global $globalDBdriver; | 
| 1093 | 1093 |  		if (is_array($coord)) { | 
| 1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
| 1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | |
| 1098 | 1098 | } else return array(); | 
| 1099 | 1099 |  		if ($globalDBdriver == 'mysql') { | 
| 1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; | 
| @@ -1106,7 +1106,7 @@ discard block | ||
| 1106 | 1106 |  		try { | 
| 1107 | 1107 | $sth = $this->db->prepare($query); | 
| 1108 | 1108 | $sth->execute($query_values); | 
| 1109 | -		} catch(PDOException $e) { | |
| 1109 | +		} catch (PDOException $e) { | |
| 1110 | 1110 | echo "error : ".$e->getMessage(); | 
| 1111 | 1111 | } | 
| 1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1118,7 +1118,7 @@ discard block | ||
| 1118 | 1118 |  		try { | 
| 1119 | 1119 | $sth = $this->db->prepare($query); | 
| 1120 | 1120 | $sth->execute($query_values); | 
| 1121 | -		} catch(PDOException $e) { | |
| 1121 | +		} catch (PDOException $e) { | |
| 1122 | 1122 | return "error : ".$e->getMessage(); | 
| 1123 | 1123 | } | 
| 1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -1126,13 +1126,13 @@ discard block | ||
| 1126 | 1126 | else return array(); | 
| 1127 | 1127 | } | 
| 1128 | 1128 | |
| 1129 | -	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { | |
| 1129 | +	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { | |
| 1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; | 
| 1131 | -		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); | |
| 1131 | +		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); | |
| 1132 | 1132 |  		try { | 
| 1133 | 1133 | $sth = $this->db->prepare($query); | 
| 1134 | 1134 | $sth->execute($query_values); | 
| 1135 | -		} catch(PDOException $e) { | |
| 1135 | +		} catch (PDOException $e) { | |
| 1136 | 1136 | return "error : ".$e->getMessage(); | 
| 1137 | 1137 | } | 
| 1138 | 1138 | } | 
| @@ -1143,7 +1143,7 @@ discard block | ||
| 1143 | 1143 |  		try { | 
| 1144 | 1144 | $sth = $this->db->prepare($query); | 
| 1145 | 1145 | $sth->execute($query_values); | 
| 1146 | -		} catch(PDOException $e) { | |
| 1146 | +		} catch (PDOException $e) { | |
| 1147 | 1147 | return "error : ".$e->getMessage(); | 
| 1148 | 1148 | } | 
| 1149 | 1149 | } | 
| @@ -1158,7 +1158,7 @@ discard block | ||
| 1158 | 1158 |  		try { | 
| 1159 | 1159 | $sth = $this->db->prepare($query); | 
| 1160 | 1160 | $sth->execute($query_values); | 
| 1161 | -		} catch(PDOException $e) { | |
| 1161 | +		} catch (PDOException $e) { | |
| 1162 | 1162 | return "error : ".$e->getMessage(); | 
| 1163 | 1163 | } | 
| 1164 | 1164 | } | 
| @@ -1168,7 +1168,7 @@ discard block | ||
| 1168 | 1168 |  		try { | 
| 1169 | 1169 | $sth = $this->db->prepare($query); | 
| 1170 | 1170 | $sth->execute($query_values); | 
| 1171 | -		} catch(PDOException $e) { | |
| 1171 | +		} catch (PDOException $e) { | |
| 1172 | 1172 | return "error : ".$e->getMessage(); | 
| 1173 | 1173 | } | 
| 1174 | 1174 | } | 
| @@ -1177,7 +1177,7 @@ discard block | ||
| 1177 | 1177 |  		try { | 
| 1178 | 1178 | $sth = $this->db->prepare($query); | 
| 1179 | 1179 | $sth->execute(); | 
| 1180 | -		} catch(PDOException $e) { | |
| 1180 | +		} catch (PDOException $e) { | |
| 1181 | 1181 | return "error : ".$e->getMessage(); | 
| 1182 | 1182 | } | 
| 1183 | 1183 | } | 
| @@ -1186,7 +1186,7 @@ discard block | ||
| 1186 | 1186 |  		try { | 
| 1187 | 1187 | $sth = $this->db->prepare($query); | 
| 1188 | 1188 | $sth->execute(); | 
| 1189 | -		} catch(PDOException $e) { | |
| 1189 | +		} catch (PDOException $e) { | |
| 1190 | 1190 | return "error : ".$e->getMessage(); | 
| 1191 | 1191 | } | 
| 1192 | 1192 | } | 
| @@ -1194,14 +1194,14 @@ discard block | ||
| 1194 | 1194 |  	public function updateNOTAM() { | 
| 1195 | 1195 | global $globalNOTAMAirports; | 
| 1196 | 1196 |  		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { | 
| 1197 | -			foreach (array_chunk($globalNOTAMAirports,10) as $airport) { | |
| 1198 | -				$airport_icao = implode(',',$airport); | |
| 1197 | +			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { | |
| 1198 | +				$airport_icao = implode(',', $airport); | |
| 1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); | 
| 1200 | 1200 |  				if (count($alldata) > 0) { | 
| 1201 | 1201 |  					foreach ($alldata as $initial_data) { | 
| 1202 | 1202 | $data = $this->parse($initial_data); | 
| 1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); | 
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); | |
| 1205 | 1205 | } | 
| 1206 | 1206 | } | 
| 1207 | 1207 | } | 
| @@ -1214,7 +1214,7 @@ discard block | ||
| 1214 | 1214 |  			foreach ($alldata as $initial_data) { | 
| 1215 | 1215 | $data = $this->parse($initial_data); | 
| 1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); | 
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); | |
| 1218 | 1218 | } | 
| 1219 | 1219 | } | 
| 1220 | 1220 | } | 
| @@ -1223,12 +1223,12 @@ discard block | ||
| 1223 | 1223 | global $globalTransaction; | 
| 1224 | 1224 | $Spotter = new Spotter(); | 
| 1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); | 
| 1226 | -		foreach (array_chunk($allairports,20) as $airport) { | |
| 1226 | +		foreach (array_chunk($allairports, 20) as $airport) { | |
| 1227 | 1227 | $airports_icao = array(); | 
| 1228 | -			foreach($airport as $icao) { | |
| 1228 | +			foreach ($airport as $icao) { | |
| 1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; | 
| 1230 | 1230 | } | 
| 1231 | -			$airport_icao = implode(',',$airports_icao); | |
| 1231 | +			$airport_icao = implode(',', $airports_icao); | |
| 1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); | 
| 1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); | 
| 1234 | 1234 |  			if (count($alldata) > 0) { | 
| @@ -1241,7 +1241,7 @@ discard block | ||
| 1241 | 1241 |  						if (count($notamref) == 0) { | 
| 1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); | 
| 1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); | 
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); | |
| 1245 | 1245 | } | 
| 1246 | 1246 | } | 
| 1247 | 1247 | } | 
| @@ -1255,7 +1255,7 @@ discard block | ||
| 1255 | 1255 |  		date_default_timezone_set("UTC"); | 
| 1256 | 1256 | $Common = new Common(); | 
| 1257 | 1257 |  		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); | 
| 1258 | -		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); | |
| 1258 | +		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); | |
| 1259 | 1259 | $data = $Common->getData($url); | 
| 1260 | 1260 |  		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); | 
| 1261 | 1261 | //print_r($matches); | 
| @@ -1272,15 +1272,15 @@ discard block | ||
| 1272 | 1272 | $result['permanent'] = ''; | 
| 1273 | 1273 | $result['date_begin'] = NULL; | 
| 1274 | 1274 | $result['date_end'] = NULL; | 
| 1275 | -		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); | |
| 1275 | +		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); | |
| 1276 | 1276 | //echo $data."\n"; | 
| 1277 | -		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data); | |
| 1277 | +		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data); | |
| 1278 | 1278 | //print_r($data); | 
| 1279 | 1279 |  		foreach ($data as $line) { | 
| 1280 | 1280 | $line = trim($line); | 
| 1281 | -			if (preg_match('#Q\) (.*)#',$line,$matches)) { | |
| 1282 | -				$line = str_replace(' ','',$line); | |
| 1283 | -				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { | |
| 1281 | +			if (preg_match('#Q\) (.*)#', $line, $matches)) { | |
| 1282 | +				$line = str_replace(' ', '', $line); | |
| 1283 | +				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { | |
| 1284 | 1284 |  				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { | 
| 1285 | 1285 | //print_r($matches); | 
| 1286 | 1286 | $result['fir'] = $matches[1]; | 
| @@ -1326,9 +1326,9 @@ discard block | ||
| 1326 | 1326 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; | 
| 1327 | 1327 | $result['lower_limit'] = $matches[6]; | 
| 1328 | 1328 | $result['upper_limit'] = $matches[7]; | 
| 1329 | - $latitude = $Common->convertDec($matches[8],'latitude'); | |
| 1329 | + $latitude = $Common->convertDec($matches[8], 'latitude'); | |
| 1330 | 1330 | if ($matches[9] == 'S') $latitude = -$latitude; | 
| 1331 | - $longitude = $Common->convertDec($matches[10],'longitude'); | |
| 1331 | + $longitude = $Common->convertDec($matches[10], 'longitude'); | |
| 1332 | 1332 | if ($matches[11] == 'W') $longitude = -$longitude; | 
| 1333 | 1333 | $result['latitude'] = $latitude; | 
| 1334 | 1334 | $result['longitude'] = $longitude; | 
| @@ -1339,21 +1339,21 @@ discard block | ||
| 1339 | 1339 | echo "Can't parse : ".$line."\n"; | 
| 1340 | 1340 | } | 
| 1341 | 1341 | } | 
| 1342 | -			elseif (preg_match('#A\) (.*)#',$line,$matches)) { | |
| 1342 | +			elseif (preg_match('#A\) (.*)#', $line, $matches)) { | |
| 1343 | 1343 | $result['icao'] = $matches[1]; | 
| 1344 | 1344 | } | 
| 1345 | -			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { | |
| 1345 | +			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches)) { | |
| 1346 | 1346 | if ($matches[1] > 50) $year = '19'.$matches[1]; | 
| 1347 | 1347 | else $year = '20'.$matches[1]; | 
| 1348 | 1348 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| 1349 | 1349 | } | 
| 1350 | -			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { | |
| 1350 | +			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches)) { | |
| 1351 | 1351 | if ($matches[1] > 50) $year = '19'.$matches[1]; | 
| 1352 | 1352 | else $year = '20'.$matches[1]; | 
| 1353 | 1353 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| 1354 | 1354 | $result['permanent'] = 0; | 
| 1355 | 1355 | } | 
| 1356 | -			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { | |
| 1356 | +			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches)) { | |
| 1357 | 1357 | if ($matches[1] > 50) $year = '19'.$matches[1]; | 
| 1358 | 1358 | else $year = '20'.$matches[1]; | 
| 1359 | 1359 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| @@ -1362,26 +1362,26 @@ discard block | ||
| 1362 | 1362 | if ($matches[6] == 'PERM') $result['permanent'] = 1; | 
| 1363 | 1363 | else $result['permanent'] = 0; | 
| 1364 | 1364 | } | 
| 1365 | -			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { | |
| 1365 | +			elseif (preg_match('#C\) (EST|PERM)$#', $line, $matches)) { | |
| 1366 | 1366 | $result['date_end'] = '2030/12/20 12:00'; | 
| 1367 | 1367 | if ($matches[1] == 'EST') $result['estimated'] = 1; | 
| 1368 | 1368 | else $result['estimated'] = 0; | 
| 1369 | 1369 | if ($matches[1] == 'PERM') $result['permanent'] = 1; | 
| 1370 | 1370 | else $result['permanent'] = 0; | 
| 1371 | 1371 | } | 
| 1372 | -			elseif (preg_match('#E\) (.*)#',$line,$matches)) { | |
| 1372 | +			elseif (preg_match('#E\) (.*)#', $line, $matches)) { | |
| 1373 | 1373 | $rtext = array(); | 
| 1374 | -				$text = explode(' ',$matches[1]); | |
| 1374 | +				$text = explode(' ', $matches[1]); | |
| 1375 | 1375 |  				foreach ($text as $word) { | 
| 1376 | 1376 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); | 
| 1377 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); | |
| 1377 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); | |
| 1378 | 1378 | else $rtext[] = $word; | 
| 1379 | 1379 | } | 
| 1380 | -				$result['text'] = implode(' ',$rtext); | |
| 1380 | +				$result['text'] = implode(' ', $rtext); | |
| 1381 | 1381 |  			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) { | 
| 1382 | 1382 |  			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) { | 
| 1383 | -			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { | |
| 1384 | -				$text = explode(' ',$line); | |
| 1383 | +			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { | |
| 1384 | +				$text = explode(' ', $line); | |
| 1385 | 1385 | $result['ref'] = $text[0]; | 
| 1386 | 1386 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; | 
| 1387 | 1387 |  				if ($matches[1] == 'NOTAMC') { | 
| @@ -1033,8 +1033,11 @@ discard block | ||
| 1033 | 1033 | $data = file_get_contents($filename); | 
| 1034 | 1034 |  		preg_match_all("/%%(.+?)%%/is", $data, $matches); | 
| 1035 | 1035 | //print_r($matches); | 
| 1036 | - if (isset($matches[1])) return $matches[1]; | |
| 1037 | - else return array(); | |
| 1036 | +		if (isset($matches[1])) { | |
| 1037 | + return $matches[1]; | |
| 1038 | +		} else { | |
| 1039 | + return array(); | |
| 1040 | + } | |
| 1038 | 1041 | } | 
| 1039 | 1042 |  	public function getAllNOTAMbyScope($scope) { | 
| 1040 | 1043 | global $globalDBdriver; | 
| @@ -1071,7 +1074,9 @@ discard block | ||
| 1071 | 1074 | $minlong = $maxlong; | 
| 1072 | 1075 | $maxlong = $tmplong; | 
| 1073 | 1076 | } | 
| 1074 | - } else return array(); | |
| 1077 | +		} else { | |
| 1078 | + return array(); | |
| 1079 | + } | |
| 1075 | 1080 |  		if ($globalDBdriver == 'mysql') { | 
| 1076 | 1081 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; | 
| 1077 | 1082 |  		} else { | 
| @@ -1095,7 +1100,9 @@ discard block | ||
| 1095 | 1100 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
| 1096 | 1101 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
| 1097 | 1102 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
| 1098 | - } else return array(); | |
| 1103 | +		} else { | |
| 1104 | + return array(); | |
| 1105 | + } | |
| 1099 | 1106 |  		if ($globalDBdriver == 'mysql') { | 
| 1100 | 1107 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; | 
| 1101 | 1108 |  		} else { | 
| @@ -1122,8 +1129,11 @@ discard block | ||
| 1122 | 1129 | return "error : ".$e->getMessage(); | 
| 1123 | 1130 | } | 
| 1124 | 1131 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| 1125 | - if (isset($all[0])) return $all[0]; | |
| 1126 | - else return array(); | |
| 1132 | +		if (isset($all[0])) { | |
| 1133 | + return $all[0]; | |
| 1134 | +		} else { | |
| 1135 | + return array(); | |
| 1136 | + } | |
| 1127 | 1137 | } | 
| 1128 | 1138 | |
| 1129 | 1139 |  	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { | 
| @@ -1201,7 +1211,9 @@ discard block | ||
| 1201 | 1211 |  					foreach ($alldata as $initial_data) { | 
| 1202 | 1212 | $data = $this->parse($initial_data); | 
| 1203 | 1213 | $notamref = $this->getNOTAMbyRef($data['ref']); | 
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1214 | +						if (count($notamref) == 0) { | |
| 1215 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1216 | + } | |
| 1205 | 1217 | } | 
| 1206 | 1218 | } | 
| 1207 | 1219 | } | 
| @@ -1214,7 +1226,9 @@ discard block | ||
| 1214 | 1226 |  			foreach ($alldata as $initial_data) { | 
| 1215 | 1227 | $data = $this->parse($initial_data); | 
| 1216 | 1228 | $notamref = $this->getNOTAMbyRef($data['ref']); | 
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1229 | +				if (!isset($notamref['notam_id'])) { | |
| 1230 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1231 | + } | |
| 1218 | 1232 | } | 
| 1219 | 1233 | } | 
| 1220 | 1234 | } | 
| @@ -1226,11 +1240,15 @@ discard block | ||
| 1226 | 1240 |  		foreach (array_chunk($allairports,20) as $airport) { | 
| 1227 | 1241 | $airports_icao = array(); | 
| 1228 | 1242 |  			foreach($airport as $icao) { | 
| 1229 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; | |
| 1243 | +				if (isset($icao['icao'])) { | |
| 1244 | + $airports_icao[] = $icao['icao']; | |
| 1245 | + } | |
| 1230 | 1246 | } | 
| 1231 | 1247 |  			$airport_icao = implode(',',$airports_icao); | 
| 1232 | 1248 | $alldata = $this->downloadNOTAM($airport_icao); | 
| 1233 | - if ($globalTransaction) $this->db->beginTransaction(); | |
| 1249 | +			if ($globalTransaction) { | |
| 1250 | + $this->db->beginTransaction(); | |
| 1251 | + } | |
| 1234 | 1252 |  			if (count($alldata) > 0) { | 
| 1235 | 1253 |  				foreach ($alldata as $initial_data) { | 
| 1236 | 1254 | //print_r($initial_data); | 
| @@ -1239,14 +1257,23 @@ discard block | ||
| 1239 | 1257 |  					if (isset($data['ref'])) { | 
| 1240 | 1258 | $notamref = $this->getNOTAMbyRef($data['ref']); | 
| 1241 | 1259 |  						if (count($notamref) == 0) { | 
| 1242 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); | |
| 1243 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); | |
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1260 | +							if (isset($data['ref_replaced'])) { | |
| 1261 | + $this->deleteNOTAMbyRef($data['ref_replaced']); | |
| 1262 | + } | |
| 1263 | +							if (isset($data['ref_cancelled'])) { | |
| 1264 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); | |
| 1265 | +							} elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { | |
| 1266 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | |
| 1267 | + } | |
| 1245 | 1268 | } | 
| 1246 | 1269 | } | 
| 1247 | 1270 | } | 
| 1248 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; | |
| 1249 | - if ($globalTransaction) $this->db->commit(); | |
| 1271 | +			} else { | |
| 1272 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; | |
| 1273 | + } | |
| 1274 | +			if ($globalTransaction) { | |
| 1275 | + $this->db->commit(); | |
| 1276 | + } | |
| 1250 | 1277 | sleep(5); | 
| 1251 | 1278 | } | 
| 1252 | 1279 | } | 
| @@ -1259,8 +1286,11 @@ discard block | ||
| 1259 | 1286 | $data = $Common->getData($url); | 
| 1260 | 1287 |  		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); | 
| 1261 | 1288 | //print_r($matches); | 
| 1262 | - if (isset($matches[1])) return $matches[1]; | |
| 1263 | - else return array(); | |
| 1289 | +		if (isset($matches[1])) { | |
| 1290 | + return $matches[1]; | |
| 1291 | +		} else { | |
| 1292 | + return array(); | |
| 1293 | + } | |
| 1264 | 1294 | } | 
| 1265 | 1295 | |
| 1266 | 1296 |  	public function parse($data) { | 
| @@ -1289,93 +1319,150 @@ discard block | ||
| 1289 | 1319 | $rules = str_split($matches[3]); | 
| 1290 | 1320 |  					foreach ($rules as $rule) { | 
| 1291 | 1321 |  						if ($rule == 'I') { | 
| 1292 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; | |
| 1293 | - else $result['rules'] = 'IFR'; | |
| 1322 | +							if (isset($result['rules'])) { | |
| 1323 | + $result['rules'] = $result['rules'].'/IFR'; | |
| 1324 | +							} else { | |
| 1325 | + $result['rules'] = 'IFR'; | |
| 1326 | + } | |
| 1294 | 1327 |  						} elseif ($rule == 'V') { | 
| 1295 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; | |
| 1296 | - else $result['rules'] = 'VFR'; | |
| 1328 | +							if (isset($result['rules'])) { | |
| 1329 | + $result['rules'] = $result['rules'].'/VFR'; | |
| 1330 | +							} else { | |
| 1331 | + $result['rules'] = 'VFR'; | |
| 1332 | + } | |
| 1297 | 1333 |  						} elseif ($rule == 'K') { | 
| 1298 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; | |
| 1299 | - else $result['rules'] = 'Checklist'; | |
| 1334 | +							if (isset($result['rules'])) { | |
| 1335 | + $result['rules'] = $result['rules'].'/Checklist'; | |
| 1336 | +							} else { | |
| 1337 | + $result['rules'] = 'Checklist'; | |
| 1338 | + } | |
| 1300 | 1339 | } | 
| 1301 | 1340 | } | 
| 1302 | 1341 | $attentions = str_split($matches[4]); | 
| 1303 | 1342 |  					foreach ($attentions as $attention) { | 
| 1304 | 1343 |  						if ($attention == 'N') { | 
| 1305 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; | |
| 1306 | - else $result['rules'] = 'Immediate attention'; | |
| 1344 | +							if (isset($result['attention'])) { | |
| 1345 | + $result['attention'] = $result['attention'].' / Immediate attention'; | |
| 1346 | +							} else { | |
| 1347 | + $result['rules'] = 'Immediate attention'; | |
| 1348 | + } | |
| 1307 | 1349 |  						} elseif ($attention == 'B') { | 
| 1308 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; | |
| 1309 | - else $result['rules'] = 'Operational significance'; | |
| 1350 | +							if (isset($result['attention'])) { | |
| 1351 | + $result['attention'] = $result['attention'].' / Operational significance'; | |
| 1352 | +							} else { | |
| 1353 | + $result['rules'] = 'Operational significance'; | |
| 1354 | + } | |
| 1310 | 1355 |  						} elseif ($attention == 'O') { | 
| 1311 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; | |
| 1312 | - else $result['rules'] = 'Flight operations'; | |
| 1356 | +							if (isset($result['attention'])) { | |
| 1357 | + $result['attention'] = $result['attention'].' / Flight operations'; | |
| 1358 | +							} else { | |
| 1359 | + $result['rules'] = 'Flight operations'; | |
| 1360 | + } | |
| 1313 | 1361 |  						} elseif ($attention == 'M') { | 
| 1314 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; | |
| 1315 | - else $result['rules'] = 'Misc'; | |
| 1362 | +							if (isset($result['attention'])) { | |
| 1363 | + $result['attention'] = $result['attention'].' / Misc'; | |
| 1364 | +							} else { | |
| 1365 | + $result['rules'] = 'Misc'; | |
| 1366 | + } | |
| 1316 | 1367 |  						} elseif ($attention == 'K') { | 
| 1317 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; | |
| 1318 | - else $result['rules'] = 'Checklist'; | |
| 1368 | +							if (isset($result['attention'])) { | |
| 1369 | + $result['attention'] = $result['attention'].' / Checklist'; | |
| 1370 | +							} else { | |
| 1371 | + $result['rules'] = 'Checklist'; | |
| 1372 | + } | |
| 1319 | 1373 | } | 
| 1320 | 1374 | } | 
| 1321 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; | |
| 1322 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; | |
| 1323 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; | |
| 1324 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; | |
| 1325 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; | |
| 1326 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; | |
| 1375 | +					if ($matches[5] == 'A') { | |
| 1376 | + $result['scope'] = 'Airport warning'; | |
| 1377 | +					} elseif ($matches[5] == 'E') { | |
| 1378 | + $result['scope'] = 'Enroute warning'; | |
| 1379 | +					} elseif ($matches[5] == 'W') { | |
| 1380 | + $result['scope'] = 'Navigation warning'; | |
| 1381 | +					} elseif ($matches[5] == 'K') { | |
| 1382 | + $result['scope'] = 'Checklist'; | |
| 1383 | +					} elseif ($matches[5] == 'AE') { | |
| 1384 | + $result['scope'] = 'Airport/Enroute warning'; | |
| 1385 | +					} elseif ($matches[5] == 'AW') { | |
| 1386 | + $result['scope'] = 'Airport/Navigation warning'; | |
| 1387 | + } | |
| 1327 | 1388 | $result['lower_limit'] = $matches[6]; | 
| 1328 | 1389 | $result['upper_limit'] = $matches[7]; | 
| 1329 | 1390 | $latitude = $Common->convertDec($matches[8],'latitude'); | 
| 1330 | - if ($matches[9] == 'S') $latitude = -$latitude; | |
| 1391 | +					if ($matches[9] == 'S') { | |
| 1392 | + $latitude = -$latitude; | |
| 1393 | + } | |
| 1331 | 1394 | $longitude = $Common->convertDec($matches[10],'longitude'); | 
| 1332 | - if ($matches[11] == 'W') $longitude = -$longitude; | |
| 1395 | +					if ($matches[11] == 'W') { | |
| 1396 | + $longitude = -$longitude; | |
| 1397 | + } | |
| 1333 | 1398 | $result['latitude'] = $latitude; | 
| 1334 | 1399 | $result['longitude'] = $longitude; | 
| 1335 | - if ($matches[12] != '') $result['radius'] = intval($matches[12]); | |
| 1336 | - else $result['radius'] = 0; | |
| 1400 | +					if ($matches[12] != '') { | |
| 1401 | + $result['radius'] = intval($matches[12]); | |
| 1402 | +					} else { | |
| 1403 | + $result['radius'] = 0; | |
| 1404 | + } | |
| 1337 | 1405 |  				} elseif ($globalDebug) { | 
| 1338 | 1406 | echo 'ERROR NOTAM : '.$notam."\n"; | 
| 1339 | 1407 | echo "Can't parse : ".$line."\n"; | 
| 1340 | 1408 | } | 
| 1341 | - } | |
| 1342 | -			elseif (preg_match('#A\) (.*)#',$line,$matches)) { | |
| 1409 | +			} elseif (preg_match('#A\) (.*)#',$line,$matches)) { | |
| 1343 | 1410 | $result['icao'] = $matches[1]; | 
| 1344 | - } | |
| 1345 | -			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { | |
| 1346 | - if ($matches[1] > 50) $year = '19'.$matches[1]; | |
| 1347 | - else $year = '20'.$matches[1]; | |
| 1411 | +			} elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { | |
| 1412 | +				if ($matches[1] > 50) { | |
| 1413 | + $year = '19'.$matches[1]; | |
| 1414 | +				} else { | |
| 1415 | + $year = '20'.$matches[1]; | |
| 1416 | + } | |
| 1348 | 1417 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| 1349 | - } | |
| 1350 | -			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { | |
| 1351 | - if ($matches[1] > 50) $year = '19'.$matches[1]; | |
| 1352 | - else $year = '20'.$matches[1]; | |
| 1418 | +			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { | |
| 1419 | +				if ($matches[1] > 50) { | |
| 1420 | + $year = '19'.$matches[1]; | |
| 1421 | +				} else { | |
| 1422 | + $year = '20'.$matches[1]; | |
| 1423 | + } | |
| 1353 | 1424 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| 1354 | 1425 | $result['permanent'] = 0; | 
| 1355 | - } | |
| 1356 | -			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { | |
| 1357 | - if ($matches[1] > 50) $year = '19'.$matches[1]; | |
| 1358 | - else $year = '20'.$matches[1]; | |
| 1426 | +			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { | |
| 1427 | +				if ($matches[1] > 50) { | |
| 1428 | + $year = '19'.$matches[1]; | |
| 1429 | +				} else { | |
| 1430 | + $year = '20'.$matches[1]; | |
| 1431 | + } | |
| 1359 | 1432 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; | 
| 1360 | - if ($matches[6] == 'EST') $result['estimated'] = 1; | |
| 1361 | - else $result['estimated'] = 0; | |
| 1362 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; | |
| 1363 | - else $result['permanent'] = 0; | |
| 1364 | - } | |
| 1365 | -			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { | |
| 1433 | +				if ($matches[6] == 'EST') { | |
| 1434 | + $result['estimated'] = 1; | |
| 1435 | +				} else { | |
| 1436 | + $result['estimated'] = 0; | |
| 1437 | + } | |
| 1438 | +				if ($matches[6] == 'PERM') { | |
| 1439 | + $result['permanent'] = 1; | |
| 1440 | +				} else { | |
| 1441 | + $result['permanent'] = 0; | |
| 1442 | + } | |
| 1443 | +			} elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { | |
| 1366 | 1444 | $result['date_end'] = '2030/12/20 12:00'; | 
| 1367 | - if ($matches[1] == 'EST') $result['estimated'] = 1; | |
| 1368 | - else $result['estimated'] = 0; | |
| 1369 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; | |
| 1370 | - else $result['permanent'] = 0; | |
| 1371 | - } | |
| 1372 | -			elseif (preg_match('#E\) (.*)#',$line,$matches)) { | |
| 1445 | +				if ($matches[1] == 'EST') { | |
| 1446 | + $result['estimated'] = 1; | |
| 1447 | +				} else { | |
| 1448 | + $result['estimated'] = 0; | |
| 1449 | + } | |
| 1450 | +				if ($matches[1] == 'PERM') { | |
| 1451 | + $result['permanent'] = 1; | |
| 1452 | +				} else { | |
| 1453 | + $result['permanent'] = 0; | |
| 1454 | + } | |
| 1455 | +			} elseif (preg_match('#E\) (.*)#',$line,$matches)) { | |
| 1373 | 1456 | $rtext = array(); | 
| 1374 | 1457 |  				$text = explode(' ',$matches[1]); | 
| 1375 | 1458 |  				foreach ($text as $word) { | 
| 1376 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); | |
| 1377 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); | |
| 1378 | - else $rtext[] = $word; | |
| 1459 | +					if (isset($this->abbr[$word])) { | |
| 1460 | + $rtext[] = strtoupper($this->abbr[$word]); | |
| 1461 | +					} elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { | |
| 1462 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); | |
| 1463 | +					} else { | |
| 1464 | + $rtext[] = $word; | |
| 1465 | + } | |
| 1379 | 1466 | } | 
| 1380 | 1467 |  				$result['text'] = implode(' ',$rtext); | 
| 1381 | 1468 |  			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) { | 
| @@ -1383,7 +1470,9 @@ discard block | ||
| 1383 | 1470 |  			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { | 
| 1384 | 1471 |  				$text = explode(' ',$line); | 
| 1385 | 1472 | $result['ref'] = $text[0]; | 
| 1386 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; | |
| 1473 | +				if ($matches[1] == 'NOTAMN') { | |
| 1474 | + $result['type'] = 'new'; | |
| 1475 | + } | |
| 1387 | 1476 |  				if ($matches[1] == 'NOTAMC') { | 
| 1388 | 1477 | $result['type'] = 'cancel'; | 
| 1389 | 1478 | $result['ref_cancelled'] = $text[2]; | 
| @@ -1405,69 +1494,101 @@ discard block | ||
| 1405 | 1494 |  		switch ($code[1]) { | 
| 1406 | 1495 | case 'A': | 
| 1407 | 1496 | $result = 'Airspace organization '; | 
| 1408 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; | |
| 1497 | +				if (isset($this->code_airspace[$code_fp])) { | |
| 1498 | + $result .= $this->code_airspace[$code_fp]; | |
| 1499 | + } | |
| 1409 | 1500 | break; | 
| 1410 | 1501 | case 'C': | 
| 1411 | 1502 | $result = 'Communications and radar facilities '; | 
| 1412 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; | |
| 1503 | +				if (isset($this->code_comradar[$code_fp])) { | |
| 1504 | + $result .= $this->code_comradar[$code_fp]; | |
| 1505 | + } | |
| 1413 | 1506 | break; | 
| 1414 | 1507 | case 'F': | 
| 1415 | 1508 | $result = 'Facilities and services '; | 
| 1416 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; | |
| 1509 | +				if (isset($this->code_facilities[$code_fp])) { | |
| 1510 | + $result .= $this->code_facilities[$code_fp]; | |
| 1511 | + } | |
| 1417 | 1512 | break; | 
| 1418 | 1513 | case 'I': | 
| 1419 | 1514 | $result = 'Instrument and Microwave Landing System '; | 
| 1420 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; | |
| 1515 | +				if (isset($this->code_instrumentlanding[$code_fp])) { | |
| 1516 | + $result .= $this->code_instrumentlanding[$code_fp]; | |
| 1517 | + } | |
| 1421 | 1518 | break; | 
| 1422 | 1519 | case 'L': | 
| 1423 | 1520 | $result = 'Lighting facilities '; | 
| 1424 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; | |
| 1521 | +				if (isset($this->code_lightingfacilities[$code_fp])) { | |
| 1522 | + $result .= $this->code_lightingfacilities[$code_fp]; | |
| 1523 | + } | |
| 1425 | 1524 | break; | 
| 1426 | 1525 | case 'M': | 
| 1427 | 1526 | $result = 'Movement and landing areas '; | 
| 1428 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; | |
| 1527 | +				if (isset($this->code_movementareas[$code_fp])) { | |
| 1528 | + $result .= $this->code_movementareas[$code_fp]; | |
| 1529 | + } | |
| 1429 | 1530 | break; | 
| 1430 | 1531 | case 'N': | 
| 1431 | 1532 | $result = 'Terminal and En Route Navigation Facilities '; | 
| 1432 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; | |
| 1533 | +				if (isset($this->code_terminalfacilities[$code_fp])) { | |
| 1534 | + $result .= $this->code_terminalfacilities[$code_fp]; | |
| 1535 | + } | |
| 1433 | 1536 | break; | 
| 1434 | 1537 | case 'O': | 
| 1435 | 1538 | $result = 'Other information '; | 
| 1436 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; | |
| 1539 | +				if (isset($this->code_information[$code_fp])) { | |
| 1540 | + $result .= $this->code_information[$code_fp]; | |
| 1541 | + } | |
| 1437 | 1542 | break; | 
| 1438 | 1543 | case 'P': | 
| 1439 | 1544 | $result = 'Air Traffic procedures '; | 
| 1440 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; | |
| 1545 | +				if (isset($this->code_airtraffic[$code_fp])) { | |
| 1546 | + $result .= $this->code_airtraffic[$code_fp]; | |
| 1547 | + } | |
| 1441 | 1548 | break; | 
| 1442 | 1549 | case 'R': | 
| 1443 | 1550 | $result = 'Navigation Warnings: Airspace Restrictions '; | 
| 1444 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; | |
| 1551 | +				if (isset($this->code_navigationw[$code_fp])) { | |
| 1552 | + $result .= $this->code_navigationw[$code_fp]; | |
| 1553 | + } | |
| 1445 | 1554 | break; | 
| 1446 | 1555 | case 'S': | 
| 1447 | 1556 | $result = 'Air Traffic and VOLMET Services '; | 
| 1448 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; | |
| 1557 | +				if (isset($this->code_volmet[$code_fp])) { | |
| 1558 | + $result .= $this->code_volmet[$code_fp]; | |
| 1559 | + } | |
| 1449 | 1560 | break; | 
| 1450 | 1561 | case 'W': | 
| 1451 | 1562 | $result = 'Navigation Warnings: Warnings '; | 
| 1452 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; | |
| 1563 | +				if (isset($this->code_warnings[$code_fp])) { | |
| 1564 | + $result .= $this->code_warnings[$code_fp]; | |
| 1565 | + } | |
| 1453 | 1566 | break; | 
| 1454 | 1567 | } | 
| 1455 | 1568 |  		switch ($code[3]) { | 
| 1456 | 1569 | case 'A': | 
| 1457 | 1570 | // Availability | 
| 1458 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; | |
| 1571 | +				if (isset($this->code_sp_availabity[$code_sp])) { | |
| 1572 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; | |
| 1573 | + } | |
| 1459 | 1574 | break; | 
| 1460 | 1575 | case 'C': | 
| 1461 | 1576 | // Changes | 
| 1462 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; | |
| 1577 | +				if (isset($this->code_sp_changes[$code_sp])) { | |
| 1578 | + $result .= ' '.$this->code_sp_changes[$code_sp]; | |
| 1579 | + } | |
| 1463 | 1580 | break; | 
| 1464 | 1581 | case 'H': | 
| 1465 | 1582 | // Hazardous conditions | 
| 1466 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; | |
| 1583 | +				if (isset($this->code_sp_hazardous[$code_sp])) { | |
| 1584 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; | |
| 1585 | + } | |
| 1467 | 1586 | break; | 
| 1468 | 1587 | case 'L': | 
| 1469 | 1588 | // Limitations | 
| 1470 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; | |
| 1589 | +				if (isset($this->code_sp_limitations[$code_sp])) { | |
| 1590 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; | |
| 1591 | + } | |
| 1471 | 1592 | break; | 
| 1472 | 1593 | case 'X': | 
| 1473 | 1594 | // Other Information | 
| @@ -29,20 +29,20 @@ discard block | ||
| 29 | 29 | * @param String $date get data for a date | 
| 30 | 30 | * @return Array Return Accidents data in array | 
| 31 | 31 | */ | 
| 32 | -	public function getAccidentData($limit = '',$type = '',$date = '') { | |
| 32 | +	public function getAccidentData($limit = '', $type = '', $date = '') { | |
| 33 | 33 | global $globalURL, $globalDBdriver; | 
| 34 | 34 | $Image = new Image($this->db); | 
| 35 | 35 | $Spotter = new Spotter($this->db); | 
| 36 | 36 | $Translation = new Translation($this->db); | 
| 37 | - $date = filter_var($date,FILTER_SANITIZE_STRING); | |
| 37 | + $date = filter_var($date, FILTER_SANITIZE_STRING); | |
| 38 | 38 |  		date_default_timezone_set('UTC'); | 
| 39 | 39 | $result = array(); | 
| 40 | 40 | $limit_query = ''; | 
| 41 | 41 | if ($limit != "") | 
| 42 | 42 |  		{ | 
| 43 | 43 |  			$limit_array = explode(",", $limit); | 
| 44 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | |
| 45 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | |
| 44 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); | |
| 45 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); | |
| 46 | 46 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
| 47 | 47 |  			{ | 
| 48 | 48 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
| @@ -51,29 +51,29 @@ discard block | ||
| 51 | 51 | |
| 52 | 52 |  		if ($type != '') { | 
| 53 | 53 |  			if ($date != '') { | 
| 54 | -				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { | |
| 54 | +				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { | |
| 55 | 55 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 56 | 56 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 57 | -					$query_values = array(':type' => $type,':date' => $date); | |
| 58 | -				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { | |
| 57 | +					$query_values = array(':type' => $type, ':date' => $date); | |
| 58 | +				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { | |
| 59 | 59 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 60 | -					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); | |
| 61 | -				} elseif (preg_match("/^[0-9]{4}$/",$date)) { | |
| 60 | +					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); | |
| 61 | +				} elseif (preg_match("/^[0-9]{4}$/", $date)) { | |
| 62 | 62 |  					if ($globalDBdriver == 'mysql') { | 
| 63 | 63 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 64 | 64 |  					} else { | 
| 65 | 65 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 66 | 66 | } | 
| 67 | -					$query_values = array(':type' => $type,':date' => $date); | |
| 67 | +					$query_values = array(':type' => $type, ':date' => $date); | |
| 68 | 68 |  				} else { | 
| 69 | 69 | $date = $date.'%'; | 
| 70 | 70 |  					if ($globalDBdriver == 'mysql') { | 
| 71 | 71 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 72 | -						$query_values = array(':type' => $type,':date' => $date); | |
| 72 | +						$query_values = array(':type' => $type, ':date' => $date); | |
| 73 | 73 |  					} else { | 
| 74 | 74 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 75 | 75 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 76 | -						$query_values = array(':type' => $type,':date' => $date); | |
| 76 | +						$query_values = array(':type' => $type, ':date' => $date); | |
| 77 | 77 | } | 
| 78 | 78 | } | 
| 79 | 79 |  			} else { | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | } | 
| 84 | 84 |  		} else { | 
| 85 | 85 |  			if ($date != '') { | 
| 86 | -				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { | |
| 86 | +				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { | |
| 87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; | 
| 89 | 89 |  				} else { | 
| @@ -102,19 +102,19 @@ discard block | ||
| 102 | 102 |  		try { | 
| 103 | 103 | $sth = $this->db->prepare($query); | 
| 104 | 104 | $sth->execute($query_values); | 
| 105 | -		} catch(PDOException $e) { | |
| 105 | +		} catch (PDOException $e) { | |
| 106 | 106 | echo "error : ".$e->getMessage(); | 
| 107 | 107 | } | 
| 108 | 108 | $i = 0; | 
| 109 | 109 |  		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
| 110 | 110 | //print_r($row); | 
| 111 | 111 | //echo $row['flightaware_id']; | 
| 112 | -			if (preg_match('/^[\w\-]+$/',$row['registration'])) { | |
| 112 | +			if (preg_match('/^[\w\-]+$/', $row['registration'])) { | |
| 113 | 113 | $data = array(); | 
| 114 | 114 |  				if ($row['registration'] != '') { | 
| 115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); | 
| 116 | -					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); | |
| 117 | -					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 116 | +					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); | |
| 117 | +					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); | |
| 118 | 118 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); | 
| 119 | 119 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); | 
| 120 | 120 |  					if (!empty($aircraft_info)) { | 
| @@ -122,7 +122,7 @@ discard block | ||
| 122 | 122 | $data['aircraft_name'] = $aircraft_info[0]['type']; | 
| 123 | 123 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; | 
| 124 | 124 |  					} else { | 
| 125 | -						$data = array_merge($data,array('aircraft_type' => 'NA')); | |
| 125 | +						$data = array_merge($data, array('aircraft_type' => 'NA')); | |
| 126 | 126 | } | 
| 127 | 127 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); | 
| 128 | 128 |  					if (!empty($owner_data)) { | 
| @@ -130,18 +130,18 @@ discard block | ||
| 130 | 130 | $data['aircraft_base'] = $owner_data['base']; | 
| 131 | 131 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; | 
| 132 | 132 | } | 
| 133 | -				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 133 | +				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); | |
| 134 | 134 | if ($row['registration'] == '') $row['registration'] = 'NA'; | 
| 135 | 135 | if ($row['ident'] == '') $row['ident'] = 'NA'; | 
| 136 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); | |
| 136 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); | |
| 137 | 137 |  				if (isset($identicao[0])) { | 
| 138 | -					if (substr($row['ident'],0,2) == 'AF') { | |
| 139 | -						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; | |
| 140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); | |
| 141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); | |
| 142 | -					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); | |
| 138 | +					if (substr($row['ident'], 0, 2) == 'AF') { | |
| 139 | +						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; | |
| 140 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); | |
| 141 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); | |
| 142 | +					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); | |
| 143 | 143 | } else $icao = $row['ident']; | 
| 144 | - $icao = $Translation->checkTranslation($icao,false); | |
| 144 | + $icao = $Translation->checkTranslation($icao, false); | |
| 145 | 145 |  				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); | 
| 146 | 146 |  				if ($row['airline_name'] != '' && !isset($data['airline_name'])) { | 
| 147 | 147 | //echo 'Check airline info... for '.$row['airline_name'].' '; | 
| @@ -150,11 +150,11 @@ discard block | ||
| 150 | 150 |  					if (!empty($airline_info)) { | 
| 151 | 151 | //echo 'data found !'."\n"; | 
| 152 | 152 | //print_r($airline_info); | 
| 153 | - $data = array_merge($data,$airline_info); | |
| 153 | + $data = array_merge($data, $airline_info); | |
| 154 | 154 | } | 
| 155 | 155 | //else echo 'No data...'."\n"; | 
| 156 | 156 | } | 
| 157 | - $data = array_merge($row,$data); | |
| 157 | + $data = array_merge($row, $data); | |
| 158 | 158 | if ($data['ident'] == null) $data['ident'] = $icao; | 
| 159 | 159 |  				if ($data['title'] == null) { | 
| 160 | 160 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; | 
| @@ -190,7 +190,7 @@ discard block | ||
| 190 | 190 |  		try { | 
| 191 | 191 | $sth = $this->db->prepare($query); | 
| 192 | 192 | $sth->execute(); | 
| 193 | -		} catch(PDOException $e) { | |
| 193 | +		} catch (PDOException $e) { | |
| 194 | 194 | echo "Error : ".$e->getMessage(); | 
| 195 | 195 | } | 
| 196 | 196 | return $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -210,7 +210,7 @@ discard block | ||
| 210 | 210 |  		try { | 
| 211 | 211 | $sth = $this->db->prepare($query); | 
| 212 | 212 | $sth->execute(); | 
| 213 | -		} catch(PDOException $e) { | |
| 213 | +		} catch (PDOException $e) { | |
| 214 | 214 | echo "Error : ".$e->getMessage(); | 
| 215 | 215 | } | 
| 216 | 216 | return $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -225,15 +225,15 @@ discard block | ||
| 225 | 225 | if ($globalDebug) echo 'Import '.$file."\n"; | 
| 226 | 226 | $result = array(); | 
| 227 | 227 |  		if (file_exists($file)) { | 
| 228 | -			if (($handle = fopen($file,'r')) !== FALSE) { | |
| 229 | -				while (($data = fgetcsv($handle,2000,",")) !== FALSE) { | |
| 228 | +			if (($handle = fopen($file, 'r')) !== FALSE) { | |
| 229 | +				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { | |
| 230 | 230 |  					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { | 
| 231 | -						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); | |
| 231 | +						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); | |
| 232 | 232 | } | 
| 233 | 233 | } | 
| 234 | 234 | fclose($handle); | 
| 235 | 235 | } | 
| 236 | - if (!empty($result)) $this->add($result,true); | |
| 236 | + if (!empty($result)) $this->add($result, true); | |
| 237 | 237 | elseif ($globalDebug) echo 'Nothing to import'; | 
| 238 | 238 | } | 
| 239 | 239 | } | 
| @@ -249,8 +249,8 @@ discard block | ||
| 249 | 249 | $all_md5_new = array(); | 
| 250 | 250 |  		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { | 
| 251 | 251 |  			if ($this->check_accidents_nb() > 0) { | 
| 252 | -				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { | |
| 253 | -					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { | |
| 252 | +				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { | |
| 253 | +					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { | |
| 254 | 254 |  						if (isset($data[1])) { | 
| 255 | 255 | $year = $data[0]; | 
| 256 | 256 | $all_md5[$year] = $data[1]; | 
| @@ -260,10 +260,10 @@ discard block | ||
| 260 | 260 | } | 
| 261 | 261 | } | 
| 262 | 262 | } | 
| 263 | -		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); | |
| 263 | +		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); | |
| 264 | 264 |  		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { | 
| 265 | -			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { | |
| 266 | -				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { | |
| 265 | +			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { | |
| 266 | +				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { | |
| 267 | 267 |  					if (isset($data[1])) { | 
| 268 | 268 | $year = $data[0]; | 
| 269 | 269 | $all_md5_new[$year] = $data[1]; | 
| @@ -272,10 +272,10 @@ discard block | ||
| 272 | 272 | fclose($handle); | 
| 273 | 273 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; | 
| 274 | 274 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; | 
| 275 | - $result = $Common->arr_diff($all_md5_new,$all_md5); | |
| 275 | + $result = $Common->arr_diff($all_md5_new, $all_md5); | |
| 276 | 276 | if (empty($result) && $globalDebug) echo 'Nothing to update'; | 
| 277 | 277 |  		foreach ($result as $file => $md5) { | 
| 278 | -			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); | |
| 278 | +			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); | |
| 279 | 279 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); | 
| 280 | 280 | elseif ($globalDebug) echo 'Download '.$file.' failed'; | 
| 281 | 281 | } | 
| @@ -285,7 +285,7 @@ discard block | ||
| 285 | 285 | * Add data to DB | 
| 286 | 286 | * @param Array $crash An array with accidents/incidents data | 
| 287 | 287 | */ | 
| 288 | -	public function add($crash,$new = false) { | |
| 288 | +	public function add($crash, $new = false) { | |
| 289 | 289 | global $globalTransaction, $globalDebug; | 
| 290 | 290 |  		require_once('class.Connection.php'); | 
| 291 | 291 |  		require_once('class.Image.php'); | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 |  			$sthd->execute(array(':source' => $crash[0]['source'])); | 
| 302 | 302 | } | 
| 303 | 303 | if ($globalTransaction) $Connection->db->beginTransaction(); | 
| 304 | -		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); | |
| 304 | +		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); | |
| 305 | 305 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; | 
| 306 | 306 | $sth_check = $Connection->db->prepare($query_check); | 
| 307 | 307 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; | 
| @@ -314,15 +314,15 @@ discard block | ||
| 314 | 314 |  				$cr = array_map(function($value) { | 
| 315 | 315 | return $value === "" ? NULL : $value; | 
| 316 | 316 | }, $cr); | 
| 317 | -				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { | |
| 318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); | |
| 319 | -					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); | |
| 317 | +				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { | |
| 318 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); | |
| 319 | +					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); | |
| 320 | 320 | $sth_check->execute($query_check_values); | 
| 321 | 321 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); | 
| 322 | 322 |  					if ($result_check['nb'] == 0) { | 
| 323 | -						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); | |
| 323 | +						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); | |
| 324 | 324 | $sth->execute($query_values); | 
| 325 | -						if ($cr['date'] > time()-(30*86400)) { | |
| 325 | +						if ($cr['date'] > time() - (30*86400)) { | |
| 326 | 326 |  							if (empty($Image->getSpotterImage($cr['registration']))) { | 
| 327 | 327 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; | 
| 328 | 328 | $Image->addSpotterImage($cr['registration']); | 
| @@ -331,16 +331,16 @@ discard block | ||
| 331 | 331 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; | 
| 332 | 332 | } | 
| 333 | 333 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; | 
| 334 | -						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); | |
| 334 | +						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); | |
| 335 | 335 | } | 
| 336 | 336 | } | 
| 337 | -				if ($globalTransaction && $j % 1000 == 0) { | |
| 337 | +				if ($globalTransaction && $j%1000 == 0) { | |
| 338 | 338 | $Connection->db->commit(); | 
| 339 | 339 | $Connection->db->beginTransaction(); | 
| 340 | 340 | } | 
| 341 | 341 | } | 
| 342 | 342 | if ($globalTransaction) $Connection->db->commit(); | 
| 343 | -		} catch(PDOException $e) { | |
| 343 | +		} catch (PDOException $e) { | |
| 344 | 344 | if ($globalTransaction) $Connection->db->rollBack(); | 
| 345 | 345 | echo $e->getMessage(); | 
| 346 | 346 | } | 
| @@ -358,7 +358,7 @@ discard block | ||
| 358 | 358 | $Connection = new Connection(); | 
| 359 | 359 | $sth = $Connection->db->prepare($query); | 
| 360 | 360 | $sth->execute(); | 
| 361 | -		} catch(PDOException $e) { | |
| 361 | +		} catch (PDOException $e) { | |
| 362 | 362 | return "error : ".$e->getMessage(); | 
| 363 | 363 | } | 
| 364 | 364 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -376,7 +376,7 @@ discard block | ||
| 376 | 376 | $Connection = new Connection(); | 
| 377 | 377 | $sth = $Connection->db->prepare($query); | 
| 378 | 378 | $sth->execute(); | 
| 379 | -		} catch(PDOException $e) { | |
| 379 | +		} catch (PDOException $e) { | |
| 380 | 380 | return "error : ".$e->getMessage(); | 
| 381 | 381 | } | 
| 382 | 382 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -391,7 +391,7 @@ discard block | ||
| 391 | 391 | $Connection = new Connection(); | 
| 392 | 392 | $sth = $Connection->db->prepare($query); | 
| 393 | 393 | $sth->execute(); | 
| 394 | -		} catch(PDOException $e) { | |
| 394 | +		} catch (PDOException $e) { | |
| 395 | 395 | return "error : ".$e->getMessage(); | 
| 396 | 396 | } | 
| 397 | 397 | } | 
| @@ -113,8 +113,11 @@ discard block | ||
| 113 | 113 | $data = array(); | 
| 114 | 114 |  				if ($row['registration'] != '') { | 
| 115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); | 
| 116 | -					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); | |
| 117 | -					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 116 | +					if (count($image_array) > 0) { | |
| 117 | +						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); | |
| 118 | +					} else { | |
| 119 | +						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 120 | + } | |
| 118 | 121 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); | 
| 119 | 122 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); | 
| 120 | 123 |  					if (!empty($aircraft_info)) { | 
| @@ -130,17 +133,30 @@ discard block | ||
| 130 | 133 | $data['aircraft_base'] = $owner_data['base']; | 
| 131 | 134 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; | 
| 132 | 135 | } | 
| 133 | -				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 134 | - if ($row['registration'] == '') $row['registration'] = 'NA'; | |
| 135 | - if ($row['ident'] == '') $row['ident'] = 'NA'; | |
| 136 | +				} else { | |
| 137 | +					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); | |
| 138 | + } | |
| 139 | +				if ($row['registration'] == '') { | |
| 140 | + $row['registration'] = 'NA'; | |
| 141 | + } | |
| 142 | +				if ($row['ident'] == '') { | |
| 143 | + $row['ident'] = 'NA'; | |
| 144 | + } | |
| 136 | 145 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); | 
| 137 | 146 |  				if (isset($identicao[0])) { | 
| 138 | 147 |  					if (substr($row['ident'],0,2) == 'AF') { | 
| 139 | -						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; | |
| 140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); | |
| 141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); | |
| 148 | +						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { | |
| 149 | + $icao = $row['ident']; | |
| 150 | +						} else { | |
| 151 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); | |
| 152 | + } | |
| 153 | +					} else { | |
| 154 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); | |
| 155 | + } | |
| 142 | 156 |  					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); | 
| 143 | - } else $icao = $row['ident']; | |
| 157 | +				} else { | |
| 158 | + $icao = $row['ident']; | |
| 159 | + } | |
| 144 | 160 | $icao = $Translation->checkTranslation($icao,false); | 
| 145 | 161 |  				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); | 
| 146 | 162 |  				if ($row['airline_name'] != '' && !isset($data['airline_name'])) { | 
| @@ -155,10 +171,14 @@ discard block | ||
| 155 | 171 | //else echo 'No data...'."\n"; | 
| 156 | 172 | } | 
| 157 | 173 | $data = array_merge($row,$data); | 
| 158 | - if ($data['ident'] == null) $data['ident'] = $icao; | |
| 174 | +				if ($data['ident'] == null) { | |
| 175 | + $data['ident'] = $icao; | |
| 176 | + } | |
| 159 | 177 |  				if ($data['title'] == null) { | 
| 160 | 178 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; | 
| 161 | - } else $data['message'] = strtolower($data['title']); | |
| 179 | +				} else { | |
| 180 | + $data['message'] = strtolower($data['title']); | |
| 181 | + } | |
| 162 | 182 | $ids = $Spotter->getAllIDByRegistration($data['registration']); | 
| 163 | 183 | $date = $data['date']; | 
| 164 | 184 |  				if (isset($ids[$date])) { | 
| @@ -177,8 +197,9 @@ discard block | ||
| 177 | 197 |  		if (isset($result)) { | 
| 178 | 198 | $result[0]['query_number_rows'] = $i; | 
| 179 | 199 | return $result; | 
| 200 | +		} else { | |
| 201 | + return array(); | |
| 180 | 202 | } | 
| 181 | - else return array(); | |
| 182 | 203 | } | 
| 183 | 204 | |
| 184 | 205 | /* | 
| @@ -222,7 +243,9 @@ discard block | ||
| 222 | 243 | */ | 
| 223 | 244 |  	public function import($file) { | 
| 224 | 245 | global $globalTransaction, $globalDebug; | 
| 225 | - if ($globalDebug) echo 'Import '.$file."\n"; | |
| 246 | +		if ($globalDebug) { | |
| 247 | + echo 'Import '.$file."\n"; | |
| 248 | + } | |
| 226 | 249 | $result = array(); | 
| 227 | 250 |  		if (file_exists($file)) { | 
| 228 | 251 |  			if (($handle = fopen($file,'r')) !== FALSE) { | 
| @@ -233,8 +256,11 @@ discard block | ||
| 233 | 256 | } | 
| 234 | 257 | fclose($handle); | 
| 235 | 258 | } | 
| 236 | - if (!empty($result)) $this->add($result,true); | |
| 237 | - elseif ($globalDebug) echo 'Nothing to import'; | |
| 259 | +			if (!empty($result)) { | |
| 260 | + $this->add($result,true); | |
| 261 | +			} elseif ($globalDebug) { | |
| 262 | + echo 'Nothing to import'; | |
| 263 | + } | |
| 238 | 264 | } | 
| 239 | 265 | } | 
| 240 | 266 | |
| @@ -270,14 +296,23 @@ discard block | ||
| 270 | 296 | } | 
| 271 | 297 | } | 
| 272 | 298 | fclose($handle); | 
| 273 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; | |
| 274 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; | |
| 299 | +			} elseif ($globalDebug) { | |
| 300 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; | |
| 301 | + } | |
| 302 | +		} elseif ($globalDebug) { | |
| 303 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; | |
| 304 | + } | |
| 275 | 305 | $result = $Common->arr_diff($all_md5_new,$all_md5); | 
| 276 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; | |
| 306 | +		if (empty($result) && $globalDebug) { | |
| 307 | + echo 'Nothing to update'; | |
| 308 | + } | |
| 277 | 309 |  		foreach ($result as $file => $md5) { | 
| 278 | 310 |  			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); | 
| 279 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); | |
| 280 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; | |
| 311 | +			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { | |
| 312 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); | |
| 313 | +			} elseif ($globalDebug) { | |
| 314 | + echo 'Download '.$file.' failed'; | |
| 315 | + } | |
| 281 | 316 | } | 
| 282 | 317 | } | 
| 283 | 318 | |
| @@ -294,13 +329,17 @@ discard block | ||
| 294 | 329 | $Image = new Image(); | 
| 295 | 330 | $Spotter = new Spotter(); | 
| 296 | 331 | |
| 297 | - if (empty($crash)) return false; | |
| 332 | +		if (empty($crash)) { | |
| 333 | + return false; | |
| 334 | + } | |
| 298 | 335 |  		if (!$new) { | 
| 299 | 336 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; | 
| 300 | 337 | $sthd = $Connection->db->prepare($query_delete); | 
| 301 | 338 |  			$sthd->execute(array(':source' => $crash[0]['source'])); | 
| 302 | 339 | } | 
| 303 | - if ($globalTransaction) $Connection->db->beginTransaction(); | |
| 340 | +		if ($globalTransaction) { | |
| 341 | + $Connection->db->beginTransaction(); | |
| 342 | + } | |
| 304 | 343 |  		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); | 
| 305 | 344 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; | 
| 306 | 345 | $sth_check = $Connection->db->prepare($query_check); | 
| @@ -315,7 +354,9 @@ discard block | ||
| 315 | 354 | return $value === "" ? NULL : $value; | 
| 316 | 355 | }, $cr); | 
| 317 | 356 |  				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { | 
| 318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); | |
| 357 | +					if (strpos($cr['registration'],'-') === FALSE) { | |
| 358 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); | |
| 359 | + } | |
| 319 | 360 |  					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); | 
| 320 | 361 | $sth_check->execute($query_check_values); | 
| 321 | 362 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); | 
| @@ -324,13 +365,19 @@ discard block | ||
| 324 | 365 | $sth->execute($query_values); | 
| 325 | 366 |  						if ($cr['date'] > time()-(30*86400)) { | 
| 326 | 367 |  							if (empty($Image->getSpotterImage($cr['registration']))) { | 
| 327 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; | |
| 368 | +								if ($globalDebug) { | |
| 369 | + echo "\t".'Get image for '.$cr['registration'].'...'; | |
| 370 | + } | |
| 328 | 371 | $Image->addSpotterImage($cr['registration']); | 
| 329 | - if ($globalDebug) echo "\t".'Done'."\n"; | |
| 372 | +								if ($globalDebug) { | |
| 373 | + echo "\t".'Done'."\n"; | |
| 374 | + } | |
| 330 | 375 | } | 
| 331 | 376 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; | 
| 332 | 377 | } | 
| 333 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; | |
| 378 | +						if ($cr['title'] == '') { | |
| 379 | + $cr['title'] = $cr['registration'].' '.$cr['type']; | |
| 380 | + } | |
| 334 | 381 |  						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); | 
| 335 | 382 | } | 
| 336 | 383 | } | 
| @@ -339,9 +386,13 @@ discard block | ||
| 339 | 386 | $Connection->db->beginTransaction(); | 
| 340 | 387 | } | 
| 341 | 388 | } | 
| 342 | - if ($globalTransaction) $Connection->db->commit(); | |
| 389 | +			if ($globalTransaction) { | |
| 390 | + $Connection->db->commit(); | |
| 391 | + } | |
| 343 | 392 |  		} catch(PDOException $e) { | 
| 344 | - if ($globalTransaction) $Connection->db->rollBack(); | |
| 393 | +			if ($globalTransaction) { | |
| 394 | + $Connection->db->rollBack(); | |
| 395 | + } | |
| 345 | 396 | echo $e->getMessage(); | 
| 346 | 397 | } | 
| 347 | 398 | $sth_check->closeCursor(); | 
| @@ -380,8 +431,11 @@ discard block | ||
| 380 | 431 | return "error : ".$e->getMessage(); | 
| 381 | 432 | } | 
| 382 | 433 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| 383 | - if ($row['nb'] > 0) return false; | |
| 384 | - else return true; | |
| 434 | +		if ($row['nb'] > 0) { | |
| 435 | + return false; | |
| 436 | +		} else { | |
| 437 | + return true; | |
| 438 | + } | |
| 385 | 439 | } | 
| 386 | 440 | |
| 387 | 441 |  	public static function insert_last_accidents_update() { |