| 
                    1
                 | 
                                    
                                                     | 
                
                 | 
                <?php  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2
                 | 
                                    
                                                     | 
                
                 | 
                //require_once('libs/simple_html_dom.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    3
                 | 
                                    
                                                     | 
                
                 | 
                require(dirname(__FILE__).'/../require/settings.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    4
                 | 
                                    
                                                     | 
                
                 | 
                require_once(dirname(__FILE__).'/../require/class.Common.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    5
                 | 
                                    
                                                     | 
                
                 | 
                require_once(dirname(__FILE__).'/../require/class.Connection.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    6
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    7
                 | 
                                    
                                                     | 
                
                 | 
                $tmp_dir = dirname(__FILE__).'/tmp/';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    8
                 | 
                                    
                                                     | 
                
                 | 
                //$globalDebug = true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    9
                 | 
                                    
                                                     | 
                
                 | 
                //$globalTransaction = true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    10
                 | 
                                    
                                                     | 
                
                 | 
                class update_db { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    11
                 | 
                                    
                                                     | 
                
                 | 
                	public static $db_sqlite;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    12
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    13
                 | 
                                    
                                                     | 
                
                 | 
                	public static function download($url, $file, $referer = '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    14
                 | 
                                    
                                                     | 
                
                 | 
                		$fp = fopen($file, 'w+');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    15
                 | 
                                    
                                                     | 
                
                 | 
                		$ch = curl_init();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    16
                 | 
                                    
                                                     | 
                
                 | 
                		curl_setopt($ch, CURLOPT_URL, $url);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    17
                 | 
                                    
                                                     | 
                
                 | 
                		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    18
                 | 
                                    
                                                     | 
                
                 | 
                		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    19
                 | 
                                    
                                                     | 
                
                 | 
                		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    20
                 | 
                                    
                                                     | 
                
                 | 
                		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');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    21
                 | 
                                    
                                                     | 
                
                 | 
                		curl_setopt($ch, CURLOPT_FILE, $fp);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    22
                 | 
                                    
                                                     | 
                
                 | 
                		curl_exec($ch);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    23
                 | 
                                    
                                                     | 
                
                 | 
                		curl_close($ch);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    24
                 | 
                                    
                                                     | 
                
                 | 
                		fclose($fp);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    25
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    26
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    27
                 | 
                                    
                                                     | 
                
                 | 
                	public static function gunzip($in_file,$out_file_name = '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    28
                 | 
                                    
                                                     | 
                
                 | 
                		//echo $in_file.' -> '.$out_file_name."\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    29
                 | 
                                    
                                                     | 
                
                 | 
                		$buffer_size = 4096; // read 4kb at a time  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    30
                 | 
                                    
                                                     | 
                
                 | 
                		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    31
                 | 
                                    
                                                     | 
                
                 | 
                		if ($in_file != '' && file_exists($in_file)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    32
                 | 
                                    
                                                     | 
                
                 | 
                			// PHP version of Ubuntu use gzopen64 instead of gzopen  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    33
                 | 
                                    
                                                     | 
                
                 | 
                			if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    34
                 | 
                                    
                                                     | 
                
                 | 
                			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    35
                 | 
                                    
                                                     | 
                
                 | 
                			else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    36
                 | 
                                    
                                                     | 
                
                 | 
                				echo 'gzopen not available';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    37
                 | 
                                    
                                                     | 
                
                 | 
                				die;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    38
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    39
                 | 
                                    
                                                     | 
                
                 | 
                			$out_file = fopen($out_file_name, 'wb');   | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    40
                 | 
                                    
                                                     | 
                
                 | 
                			while(!gzeof($file)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    41
                 | 
                                    
                                                     | 
                
                 | 
                				fwrite($out_file, gzread($file, $buffer_size));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    42
                 | 
                                    
                                                     | 
                
                 | 
                			}    | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    43
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    44
                 | 
                                    
                                                     | 
                
                 | 
                			gzclose($file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    45
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    46
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    47
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    48
                 | 
                                    
                                                     | 
                
                 | 
                	public static function unzip($in_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    49
                 | 
                                    
                                                     | 
                
                 | 
                		if ($in_file != '' && file_exists($in_file)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    50
                 | 
                                    
                                                     | 
                
                 | 
                			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    51
                 | 
                                    
                                                     | 
                
                 | 
                			$zip = new ZipArchive;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    52
                 | 
                                    
                                                     | 
                
                 | 
                			$res = $zip->open($in_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    53
                 | 
                                    
                                                     | 
                
                 | 
                			if ($res === TRUE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    54
                 | 
                                    
                                                     | 
                
                 | 
                				$zip->extractTo($path);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    55
                 | 
                                    
                                                     | 
                
                 | 
                				$zip->close();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    56
                 | 
                                    
                                                     | 
                
                 | 
                			} else return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    57
                 | 
                                    
                                                     | 
                
                 | 
                		} else return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    58
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    59
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    60
                 | 
                                    
                                                     | 
                
                 | 
                	public static function connect_sqlite($database) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    61
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    62
                 | 
                                    
                                                     | 
                
                 | 
                			self::$db_sqlite = new PDO('sqlite:'.$database); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    63
                 | 
                                    
                                                     | 
                
                 | 
                			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    64
                 | 
                                    
                                                     | 
                
                 | 
                		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    65
                 | 
                                    
                                                     | 
                
                 | 
                			return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    66
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    67
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    68
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    69
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_route_sqlite_to_dest($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    70
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDebug, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    71
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE routes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    72
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo " - Delete previous routes from DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    73
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    74
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    75
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    76
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    77
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    78
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    79
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    80
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    81
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    82
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    83
                 | 
                                    
                                                     | 
                
                 | 
                    		if ($globalDebug) echo " - Add routes to DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    84
                 | 
                                    
                                                     | 
                
                 | 
                    		update_db::connect_sqlite($database_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    85
                 | 
                                    
                                                     | 
                
                 | 
                		//$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';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    86
                 | 
                                    
                                                     | 
                
                 | 
                		$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";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    87
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    88
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth = update_db::$db_sqlite->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    89
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    90
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    91
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    92
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    93
                 | 
                                    
                                                     | 
                
                 | 
                		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    94
                 | 
                                    
                                                     | 
                
                 | 
                		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    95
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    96
                 | 
                                    
                                                     | 
                
                 | 
                		$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    97
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    98
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    99
                 | 
                                    
                                                     | 
                
                 | 
                            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    100
                 | 
                                    
                                                     | 
                
                 | 
                				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    101
                 | 
                                    
                                                     | 
                
                 | 
                				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    102
                 | 
                                    
                                                     | 
                
                 | 
                				$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    103
                 | 
                                    
                                                     | 
                
                 | 
                            		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    104
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    105
                 | 
                                    
                                                     | 
                
                 | 
                		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    106
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->rollBack();   | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    107
                 | 
                                    
                                                     | 
                
                 | 
                			return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    108
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    109
                 | 
                                    
                                                     | 
                
                 | 
                                return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    110
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    111
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_route_oneworld($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    112
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDebug, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    113
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE routes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    114
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo " - Delete previous routes from DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    115
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    116
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    117
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    118
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    119
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    120
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'oneworld')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    121
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    122
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    123
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    124
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    125
                 | 
                                    
                                                     | 
                
                 | 
                    		if ($globalDebug) echo " - Add routes to DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    126
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    127
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    128
                 | 
                                    
                                                     | 
                
                 | 
                		if ($fh = fopen($database_file,"r")) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    129
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    130
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    131
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    132
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    133
                 | 
                                    
                                                     | 
                
                 | 
                			while (!feof($fh)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    134
                 | 
                                    
                                                     | 
                
                 | 
                				$line = fgetcsv($fh,9999,',');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    135
                 | 
                                    
                                                     | 
                
                 | 
                				if ($line[0] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    136
                 | 
                                    
                                                     | 
                
                 | 
                					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    137
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    138
                 | 
                                    
                                                     | 
                
                 | 
                							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    139
                 | 
                                    
                                                     | 
                
                 | 
                							$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    140
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    141
                 | 
                                    
                                                     | 
                
                 | 
                							if ($globalTransaction) $Connection->db->rollBack();   | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    142
                 | 
                                    
                                                     | 
                
                 | 
                							return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    143
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    144
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    145
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    146
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    147
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    148
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    149
                 | 
                                    
                                                     | 
                
                 | 
                                return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    150
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    151
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    152
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_route_skyteam($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    153
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDebug, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    154
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE routes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    155
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo " - Delete previous routes from DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    156
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    157
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    158
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    159
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    160
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    161
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'skyteam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    162
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    163
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    164
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    165
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    166
                 | 
                                    
                                                     | 
                
                 | 
                    		if ($globalDebug) echo " - Add routes to DB -";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    167
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    168
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    169
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    170
                 | 
                                    
                                                     | 
                
                 | 
                		if ($fh = fopen($database_file,"r")) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    171
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    172
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    173
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    174
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    175
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    176
                 | 
                                    
                                                     | 
                
                 | 
                				while (!feof($fh)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    177
                 | 
                                    
                                                     | 
                
                 | 
                					$line = fgetcsv($fh,9999,',');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    178
                 | 
                                    
                                                     | 
                
                 | 
                					if ($line[0] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    179
                 | 
                                    
                                                     | 
                
                 | 
                						$datebe = explode('  -  ',$line[2]); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    180
                 | 
                                    
                                                     | 
                
                 | 
                						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    181
                 | 
                                    
                                                     | 
                
                 | 
                							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    182
                 | 
                                    
                                                     | 
                
                 | 
                							$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    183
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    184
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    185
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    186
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    187
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    188
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->rollBack();   | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    189
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    190
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    191
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    192
                 | 
                                    
                                                     | 
                
                 | 
                                return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    193
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    194
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_modes_sqlite_to_dest($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    195
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    196
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE aircraft_modes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    197
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source IS NULL OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    198
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    199
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    200
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    201
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    202
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    203
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    204
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    205
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    206
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    207
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    208
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    209
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    210
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    211
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    212
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    213
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    214
                 | 
                                    
                                                     | 
                
                 | 
                    		update_db::connect_sqlite($database_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    215
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'select * from Aircraft';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    216
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    217
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth = update_db::$db_sqlite->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    218
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    219
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    220
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    221
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    222
                 | 
                                    
                                                     | 
                
                 | 
                		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    223
                 | 
                                    
                                                     | 
                
                 | 
                		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    224
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    225
                 | 
                                    
                                                     | 
                
                 | 
                		$query_dest_owner = 'INSERT INTO aircraft_owner (registration,owner,Source) VALUES (:registration,:owner,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    226
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    227
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    228
                 | 
                                    
                                                     | 
                
                 | 
                		$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    229
                 | 
                                    
                                                     | 
                
                 | 
                		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    230
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    231
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    232
                 | 
                                    
                                                     | 
                
                 | 
                            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    233
                 | 
                                    
                                                     | 
                
                 | 
                			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    234
                 | 
                                    
                                                     | 
                
                 | 
                				if ($values['UserString4'] == 'M') $type = 'military';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    235
                 | 
                                    
                                                     | 
                
                 | 
                				else $type = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    236
                 | 
                                    
                                                     | 
                
                 | 
                				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    237
                 | 
                                    
                                                     | 
                
                 | 
                				$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    238
                 | 
                                    
                                                     | 
                
                 | 
                				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    239
                 | 
                                    
                                                     | 
                
                 | 
                				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    240
                 | 
                                    
                                                     | 
                
                 | 
                				    $sth_dest_owner->execute($query_dest_owner_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    241
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    242
                 | 
                                    
                                                     | 
                
                 | 
                            		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    243
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    244
                 | 
                                    
                                                     | 
                
                 | 
                		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    245
                 | 
                                    
                                                     | 
                
                 | 
                			return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    246
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    247
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    248
                 | 
                                    
                                                     | 
                
                 | 
                		// Remove data already in DB from ACARS  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    249
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = :source AND ModeS IN (SELECT * FROM (SELECT ModeS FROM aircraft_modes WHERE Source = 'ACARS') _alias)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    250
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    251
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    252
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    253
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    254
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    255
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    256
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    257
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    258
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    259
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    260
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_modes_flarmnet($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    261
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    262
                 | 
                                    
                                                     | 
                
                 | 
                		$Common = new Common();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    263
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE aircraft_modes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    264
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source IS NULL OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    265
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    266
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    267
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    268
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    269
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    270
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    271
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    272
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    273
                 | 
                                    
                                                     | 
                
                 | 
                		if ($fh = fopen($database_file,"r")) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    274
                 | 
                                    
                                                     | 
                
                 | 
                			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    275
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    276
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    277
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    278
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    279
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    280
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    281
                 | 
                                    
                                                     | 
                
                 | 
                            			while (!feof($fh)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    282
                 | 
                                    
                                                     | 
                
                 | 
                            				$values = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    283
                 | 
                                    
                                                     | 
                
                 | 
                            				$line = $Common->hex2str(fgets($fh,9999));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    284
                 | 
                                    
                                                     | 
                
                 | 
                					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    285
                 | 
                                    
                                                     | 
                
                 | 
                            				$values['ModeS'] = substr($line,0,6);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    286
                 | 
                                    
                                                     | 
                
                 | 
                            				$values['Registration'] = trim(substr($line,69,6));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    287
                 | 
                                    
                                                     | 
                
                 | 
                            				$aircraft_name = trim(substr($line,48,6));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    288
                 | 
                                    
                                                     | 
                
                 | 
                            				// Check if we can find ICAO, else set it to GLID  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    289
                 | 
                                    
                                                     | 
                
                 | 
                            				$aircraft_name_split = explode(' ',$aircraft_name); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    290
                 | 
                                    
                                                     | 
                
                 | 
                            				$search_more = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    291
                 | 
                                    
                                                     | 
                
                 | 
                            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    292
                 | 
                                    
                                                     | 
                
                 | 
                            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    293
                 | 
                                    
                                                     | 
                
                 | 
                            				$sth_search = $Connection->db->prepare($query_search);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    294
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    295
                 | 
                                    
                                                     | 
                
                 | 
                                                    		$sth_search->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    296
                 | 
                                    
                                                     | 
                
                 | 
                	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    297
                 | 
                                    
                                                     | 
                
                 | 
                	            				//if (count($result) > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    298
                 | 
                                    
                                                     | 
                
                 | 
                	            				if (isset($result['icao']) && $result['icao'] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    299
                 | 
                                    
                                                     | 
                
                 | 
                	            				    $values['ICAOTypeCode'] = $result['icao'];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    300
                 | 
                                    
                                                     | 
                
                 | 
                	            				}   | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    301
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    302
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    303
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    304
                 | 
                                    
                                                     | 
                
                 | 
                					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    305
                 | 
                                    
                                                     | 
                
                 | 
                					// Add data to db  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    306
                 | 
                                    
                                                     | 
                
                 | 
                					if ($values['Registration'] != '' && $values['Registration'] != '0000') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    307
                 | 
                                    
                                                     | 
                
                 | 
                						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    308
                 | 
                                    
                                                     | 
                
                 | 
                						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    309
                 | 
                                    
                                                     | 
                
                 | 
                						//print_r($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    310
                 | 
                                    
                                                     | 
                
                 | 
                						$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    311
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    312
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    313
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    314
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    315
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    316
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    317
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    318
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    319
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = :source AND ModeS IN (SELECT * FROM (SELECT ModeS FROM aircraft_modes WHERE Source = 'ACARS') _alias)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    320
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    321
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    322
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    323
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    324
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    325
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    326
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    327
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    328
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    329
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    330
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_modes_ogn($database_file) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    331
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    332
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE aircraft_modes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    333
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source IS NULL OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    334
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    335
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    336
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    337
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    338
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    339
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    340
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    341
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    342
                 | 
                                    
                                                     | 
                
                 | 
                		if ($fh = fopen($database_file,"r")) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    343
                 | 
                                    
                                                     | 
                
                 | 
                			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    344
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    345
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    346
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    347
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    348
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    349
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    350
                 | 
                                    
                                                     | 
                
                 | 
                				$tmp = fgetcsv($fh,9999,',',"'");  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    351
                 | 
                                    
                                                     | 
                
                 | 
                            			while (!feof($fh)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    352
                 | 
                                    
                                                     | 
                
                 | 
                            				$line = fgetcsv($fh,9999,',',"'");  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    353
                 | 
                                    
                                                     | 
                
                 | 
                            				  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    354
                 | 
                                    
                                                     | 
                
                 | 
                					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    355
                 | 
                                    
                                                     | 
                
                 | 
                					//print_r($line);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    356
                 | 
                                    
                                                     | 
                
                 | 
                            				$values['ModeS'] = $line[1];  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    357
                 | 
                                    
                                                     | 
                
                 | 
                            				$values['Registration'] = $line[3];  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    358
                 | 
                                    
                                                     | 
                
                 | 
                            				$aircraft_name = $line[2];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    359
                 | 
                                    
                                                     | 
                
                 | 
                            				// Check if we can find ICAO, else set it to GLID  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    360
                 | 
                                    
                                                     | 
                
                 | 
                            				$aircraft_name_split = explode(' ',$aircraft_name); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    361
                 | 
                                    
                                                     | 
                
                 | 
                            				$search_more = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    362
                 | 
                                    
                                                     | 
                
                 | 
                            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    363
                 | 
                                    
                                                     | 
                
                 | 
                            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    364
                 | 
                                    
                                                     | 
                
                 | 
                            				$sth_search = $Connection->db->prepare($query_search);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    365
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    366
                 | 
                                    
                                                     | 
                
                 | 
                                                    		$sth_search->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    367
                 | 
                                    
                                                     | 
                
                 | 
                	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    368
                 | 
                                    
                                                     | 
                
                 | 
                	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    369
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    370
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    371
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    372
                 | 
                                    
                                                     | 
                
                 | 
                					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    373
                 | 
                                    
                                                     | 
                
                 | 
                					// Add data to db  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    374
                 | 
                                    
                                                     | 
                
                 | 
                					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    375
                 | 
                                    
                                                     | 
                
                 | 
                						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    376
                 | 
                                    
                                                     | 
                
                 | 
                						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    377
                 | 
                                    
                                                     | 
                
                 | 
                						//print_r($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    378
                 | 
                                    
                                                     | 
                
                 | 
                						$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    379
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    380
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    381
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    382
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    383
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    384
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    385
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    386
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    387
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = :source AND ModeS IN (SELECT * FROM (SELECT ModeS FROM aircraft_modes WHERE Source = 'ACARS') _alias)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    388
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    389
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    390
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    391
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    392
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    393
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    394
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    395
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    396
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    397
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    398
                 | 
                                    
                                                     | 
                
                 | 
                	public static function retrieve_owner($database_file,$country = 'F') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    399
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalTransaction, $globalMasterSource;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    400
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE aircraft_modes';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    401
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    402
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    403
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    404
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    405
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $database_file)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    406
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    407
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    408
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    409
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    410
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    411
                 | 
                                    
                                                     | 
                
                 | 
                		if ($fh = fopen($database_file,"r")) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    412
                 | 
                                    
                                                     | 
                
                 | 
                			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    413
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    414
                 | 
                                    
                                                     | 
                
                 | 
                		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    415
                 | 
                                    
                                                     | 
                
                 | 
                		          | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    416
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    417
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    418
                 | 
                                    
                                                     | 
                
                 | 
                			$sth_modes = $Connection->db->prepare($query_modes);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    419
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    420
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    421
                 | 
                                    
                                                     | 
                
                 | 
                				$tmp = fgetcsv($fh,9999,',','"');  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    422
                 | 
                                    
                                                     | 
                
                 | 
                            			while (!feof($fh)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    423
                 | 
                                    
                                                     | 
                
                 | 
                            				$line = fgetcsv($fh,9999,',','"');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    424
                 | 
                                    
                                                     | 
                
                 | 
                            				$values = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    425
                 | 
                                    
                                                     | 
                
                 | 
                            				//print_r($line);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    426
                 | 
                                    
                                                     | 
                
                 | 
                            				if ($country == 'F') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    427
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    428
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    429
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    430
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[6] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    431
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    432
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = $line[7];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    433
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'EI') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    434
                 | 
                                    
                                                     | 
                
                 | 
                					    // TODO : add modeS & reg to aircraft_modes  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    435
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    436
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = $line[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    437
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[2];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    438
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[1] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    439
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    440
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    441
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[7];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    442
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[8];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    443
                 | 
                                    
                                                     | 
                
                 | 
                					      | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    444
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'HB') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    445
                 | 
                                    
                                                     | 
                
                 | 
                					    // TODO : add modeS & reg to aircraft_modes  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    446
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    447
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    448
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    449
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    450
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    451
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    452
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[7];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    453
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'OK') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    454
                 | 
                                    
                                                     | 
                
                 | 
                					    // TODO : add modeS & reg to aircraft_modes  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    455
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    456
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    457
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    458
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[18] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    459
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    460
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    461
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'VH') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    462
                 | 
                                    
                                                     | 
                
                 | 
                					    // TODO : add modeS & reg to aircraft_modes  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    463
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    464
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    465
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[12];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    466
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[28] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    467
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    468
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    469
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = $line[39];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    470
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    471
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    472
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    473
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    474
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    475
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    476
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'CC') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    477
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    478
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    479
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[6];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    480
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    481
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    482
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'HJ') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    483
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    484
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    485
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[8];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    486
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[7] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    487
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    488
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    489
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'PP') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    490
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    491
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    492
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    493
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[6] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    494
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    495
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = $line[7];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    496
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'E7') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    497
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    498
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    499
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    500
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[5] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    501
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    502
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    503
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == '8Q') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    504
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    505
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    506
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    507
                 | 
                                    
                                                     | 
                
                 | 
                            				    if ($line[7] == '') $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    508
                 | 
                                    
                                                     | 
                
                 | 
                					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    509
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    510
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'ZK') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    511
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    512
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    513
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    514
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    515
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    516
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    517
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[9];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    518
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'M') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    519
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    520
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    521
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[6];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    522
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    523
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = date("Y-m-d",strtotime($line[8])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    524
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    525
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[10];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    526
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'OY') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    527
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    528
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    529
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    530
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[6];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    531
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'PH') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    532
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    533
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    534
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['modes'] = $line[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    535
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['icao'] = $line[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    536
                 | 
                                    
                                                     | 
                
                 | 
                					} elseif ($country == 'OM' || $country == 'TF') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    537
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['registration'] = $line[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    538
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['base'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    539
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['owner'] = $line[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    540
                 | 
                                    
                                                     | 
                
                 | 
                            				    $values['date_first_reg'] = null;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    541
                 | 
                                    
                                                     | 
                
                 | 
                					    $values['cancel'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    542
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    543
                 | 
                                    
                                                     | 
                
                 | 
                					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    544
                 | 
                                    
                                                     | 
                
                 | 
                						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    545
                 | 
                                    
                                                     | 
                
                 | 
                						$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    546
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    547
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    548
                 | 
                                    
                                                     | 
                
                 | 
                						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    549
                 | 
                                    
                                                     | 
                
                 | 
                						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    550
                 | 
                                    
                                                     | 
                
                 | 
                						$sth_modes->execute($query_modes_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    551
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    552
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    553
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    554
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    555
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    556
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    557
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    558
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    559
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    560
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    561
                 | 
                                    
                                                     | 
                
                 | 
                	/*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    562
                 | 
                                    
                                                     | 
                
                 | 
                	* This function is used to create a list of airports. Sources : Wikipedia, ourairports.com ans partow.net  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    563
                 | 
                                    
                                                     | 
                
                 | 
                	*/  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    564
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_airports() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    565
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    566
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    567
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/libs/sparqllib.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    568
                 | 
                                    
                                                     | 
                
                 | 
                		$db = sparql_connect('http://dbpedia.org/sparql'); | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    569
                 | 
                                    
                                                     | 
                
                 | 
                		$query = '  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    570
                 | 
                                    
                                                     | 
                
                 | 
                		    PREFIX dbo: <http://dbpedia.org/ontology/>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    571
                 | 
                                    
                                                     | 
                
                 | 
                		    PREFIX dbp: <http://dbpedia.org/property/>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    572
                 | 
                                    
                                                     | 
                
                 | 
                		    PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    573
                 | 
                                    
                                                     | 
                
                 | 
                		    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    574
                 | 
                                    
                                                     | 
                
                 | 
                		    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    575
                 | 
                                    
                                                     | 
                
                 | 
                		    SELECT ?name ?icao ?iata ?faa ?lid ?latitude ?longitude ?airport ?homepage ?type ?country ?country_bis ?altitude ?image  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    576
                 | 
                                    
                                                     | 
                
                 | 
                		    FROM <http://dbpedia.org>  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    577
                 | 
                                    
                                                     | 
                
                 | 
                		    WHERE { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    578
                 | 
                                    
                                                     | 
                
                 | 
                			?airport rdf:type <http://dbpedia.org/ontology/Airport> .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    579
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    580
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    581
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbo:icaoLocationIdentifier ?icao .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    582
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER regex(?icao, "^[A-Z0-9]{4}$") | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    583
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    584
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    585
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    586
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbo:iataLocationIdentifier ?iata .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    587
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER regex(?iata, "^[A-Z0-9]{3}$") | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    588
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    589
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    590
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    591
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbo:locationIdentifier ?lid .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    592
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER regex(?lid, "^[A-Z0-9]{4}$") | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    593
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (!bound(?icao) || (bound(?icao) && (?icao != ?lid)))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    594
                 | 
                                    
                                                     | 
                
                 | 
                			    OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    595
                 | 
                                    
                                                     | 
                
                 | 
                				?airport_y rdf:type <http://dbpedia.org/ontology/Airport> .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    596
                 | 
                                    
                                                     | 
                
                 | 
                				?airport_y dbo:icaoLocationIdentifier ?other_icao .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    597
                 | 
                                    
                                                     | 
                
                 | 
                				FILTER (bound(?lid) && (?airport_y != ?airport && ?lid = ?other_icao))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    598
                 | 
                                    
                                                     | 
                
                 | 
                			    }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    599
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (!bound(?other_icao))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    600
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    601
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    602
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    603
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbo:faaLocationIdentifier ?faa .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    604
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER regex(?faa, "^[A-Z0-9]{3}$") | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    605
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (!bound(?iata) || (bound(?iata) && (?iata != ?faa)))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    606
                 | 
                                    
                                                     | 
                
                 | 
                			    OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    607
                 | 
                                    
                                                     | 
                
                 | 
                				?airport_x rdf:type <http://dbpedia.org/ontology/Airport> .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    608
                 | 
                                    
                                                     | 
                
                 | 
                				?airport_x dbo:iataLocationIdentifier ?other_iata .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    609
                 | 
                                    
                                                     | 
                
                 | 
                				FILTER (bound(?faa) && (?airport_x != ?airport && ?faa = ?other_iata))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    610
                 | 
                                    
                                                     | 
                
                 | 
                			    }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    611
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (!bound(?other_iata))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    612
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    613
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    614
                 | 
                                    
                                                     | 
                
                 | 
                			FILTER (bound(?icao) || bound(?iata) || bound(?faa) || bound(?lid))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    615
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    616
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    617
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport rdfs:label ?name  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    618
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (lang(?name) = "en")  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    619
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    620
                 | 
                                    
                                                     | 
                
                 | 
                      | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    621
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    622
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport foaf:homepage ?homepage  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    623
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    624
                 | 
                                    
                                                     | 
                
                 | 
                		      | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    625
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    626
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbp:coordinatesRegion ?country  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    627
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    628
                 | 
                                    
                                                     | 
                
                 | 
                      | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    629
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    630
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbp:type ?type  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    631
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    632
                 | 
                                    
                                                     | 
                
                 | 
                			  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    633
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    634
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbo:elevation ?altitude  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    635
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    636
                 | 
                                    
                                                     | 
                
                 | 
                			OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    637
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport dbp:image ?image  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    638
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    639
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    640
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    641
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport geo:lat ?latitude .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    642
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport geo:long ?longitude .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    643
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (datatype(?latitude) = xsd:float)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    644
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (datatype(?longitude) = xsd:float)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    645
                 | 
                                    
                                                     | 
                
                 | 
                			} UNION { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    646
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport geo:lat ?latitude .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    647
                 | 
                                    
                                                     | 
                
                 | 
                			    ?airport geo:long ?longitude .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    648
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (datatype(?latitude) = xsd:double)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    649
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (datatype(?longitude) = xsd:double)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    650
                 | 
                                    
                                                     | 
                
                 | 
                			    OPTIONAL { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    651
                 | 
                                    
                                                     | 
                
                 | 
                				?airport geo:lat ?lat_f .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    652
                 | 
                                    
                                                     | 
                
                 | 
                				?airport geo:long ?long_f .  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    653
                 | 
                                    
                                                     | 
                
                 | 
                				FILTER (datatype(?lat_f) = xsd:float)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    654
                 | 
                                    
                                                     | 
                
                 | 
                				FILTER (datatype(?long_f) = xsd:float)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    655
                 | 
                                    
                                                     | 
                
                 | 
                			    }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    656
                 | 
                                    
                                                     | 
                
                 | 
                			    FILTER (!bound(?lat_f) && !bound(?long_f))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    657
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    658
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    659
                 | 
                                    
                                                     | 
                
                 | 
                		    }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    660
                 | 
                                    
                                                     | 
                
                 | 
                		    ORDER BY ?airport  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    661
                 | 
                                    
                                                     | 
                
                 | 
                		';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    662
                 | 
                                    
                                                     | 
                
                 | 
                		$result = sparql_query($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    663
                 | 
                                    
                                                     | 
                
                 | 
                    | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    664
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'TRUNCATE TABLE airport';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    665
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    666
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    667
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    668
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    669
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    670
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    671
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    672
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    673
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    674
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'ALTER TABLE airport DROP INDEX icaoidx';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    675
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    676
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    677
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    678
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    679
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    680
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    681
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    682
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    683
                 | 
                                    
                                                     | 
                
                 | 
                		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    684
                 | 
                                    
                                                     | 
                
                 | 
                		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    685
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    686
                 | 
                                    
                                                     | 
                
                 | 
                		$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    687
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    688
                 | 
                                    
                                                     | 
                
                 | 
                    | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    689
                 | 
                                    
                                                     | 
                
                 | 
                		$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    690
                 | 
                                    
                                                     | 
                
                 | 
                		while($row = sparql_fetch_array($result))  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    691
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    692
                 | 
                                    
                                                     | 
                
                 | 
                			if ($i >= 1) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    693
                 | 
                                    
                                                     | 
                
                 | 
                			//print_r($row);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    694
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['iata'])) $row['iata'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    695
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['icao'])) $row['icao'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    696
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['type'])) $row['type'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    697
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['altitude'])) $row['altitude'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    698
                 | 
                                    
                                                     | 
                
                 | 
                			if (isset($row['city_bis'])) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    699
                 | 
                                    
                                                     | 
                
                 | 
                				$row['city'] = $row['city_bis'];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    700
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    701
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['city'])) $row['city'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    702
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['country'])) $row['country'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    703
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['homepage'])) $row['homepage'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    704
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    705
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['name'])) continue;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    706
                 | 
                                    
                                                     | 
                
                 | 
                			if (!isset($row['image'])) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    707
                 | 
                                    
                                                     | 
                
                 | 
                				$row['image'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    708
                 | 
                                    
                                                     | 
                
                 | 
                				$row['image_thumb'] = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    709
                 | 
                                    
                                                     | 
                
                 | 
                			} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    710
                 | 
                                    
                                                     | 
                
                 | 
                				$image = str_replace(' ','_',$row['image']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    711
                 | 
                                    
                                                     | 
                
                 | 
                				$digest = md5($image);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    712
                 | 
                                    
                                                     | 
                
                 | 
                				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    713
                 | 
                                    
                                                     | 
                
                 | 
                				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    714
                 | 
                                    
                                                     | 
                
                 | 
                				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    715
                 | 
                                    
                                                     | 
                
                 | 
                				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    716
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    717
                 | 
                                    
                                                     | 
                
                 | 
                			  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    718
                 | 
                                    
                                                     | 
                
                 | 
                			$country = explode('-',$row['country']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    719
                 | 
                                    
                                                     | 
                
                 | 
                			$row['country'] = $country[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    720
                 | 
                                    
                                                     | 
                
                 | 
                			  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    721
                 | 
                                    
                                                     | 
                
                 | 
                			$row['type'] = trim($row['type']);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    722
                 | 
                                    
                                                     | 
                
                 | 
                			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    723
                 | 
                                    
                                                     | 
                
                 | 
                				$row['type'] = 'Military';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    724
                 | 
                                    
                                                     | 
                
                 | 
                			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    725
                 | 
                                    
                                                     | 
                
                 | 
                				$row['type'] = 'small_airport';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    726
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    727
                 | 
                                    
                                                     | 
                
                 | 
                			  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    728
                 | 
                                    
                                                     | 
                
                 | 
                			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    729
                 | 
                                    
                                                     | 
                
                 | 
                			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    730
                 | 
                                    
                                                     | 
                
                 | 
                			//print_r($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    731
                 | 
                                    
                                                     | 
                
                 | 
                			  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    732
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    733
                 | 
                                    
                                                     | 
                
                 | 
                				$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    734
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    735
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    736
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    737
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    738
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    739
                 | 
                                    
                                                     | 
                
                 | 
                			$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    740
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    741
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    742
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Delete duplicate rows...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    743
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    744
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    745
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    746
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    747
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    748
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    749
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    750
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    751
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    752
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    753
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Insert Not available Airport...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    754
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    755
                 | 
                                    
                                                     | 
                
                 | 
                		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    756
                 | 
                                    
                                                     | 
                
                 | 
                		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    757
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    758
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    759
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    760
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute($query_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    761
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    762
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    763
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    764
                 | 
                                    
                                                     | 
                
                 | 
                		$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    765
                 | 
                                    
                                                     | 
                
                 | 
                /*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    766
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    767
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    768
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    769
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    770
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    771
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    772
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    773
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    774
                 | 
                                    
                                                     | 
                
                 | 
                */  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    775
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    776
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Download data from ourairports.com...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    777
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ',';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    778
                 | 
                                    
                                                     | 
                
                 | 
                		$out_file = $tmp_dir.'airports.csv';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    779
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://ourairports.com/data/airports.csv',$out_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    780
                 | 
                                    
                                                     | 
                
                 | 
                		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    781
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Add data from ourairports.com...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    782
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    783
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    784
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($out_file, 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    785
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    786
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    787
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    788
                 | 
                                    
                                                     | 
                
                 | 
                			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    789
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    790
                 | 
                                    
                                                     | 
                
                 | 
                				if(!$header) $header = $row;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    791
                 | 
                                    
                                                     | 
                
                 | 
                				else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    792
                 | 
                                    
                                                     | 
                
                 | 
                					$data = array();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    793
                 | 
                                    
                                                     | 
                
                 | 
                					$data = array_combine($header, $row);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    794
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    795
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    796
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':icao' => $data['gps_code'])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    797
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    798
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    799
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    800
                 | 
                                    
                                                     | 
                
                 | 
                					if ($sth->fetchColumn() > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    801
                 | 
                                    
                                                     | 
                
                 | 
                						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    802
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    803
                 | 
                                    
                                                     | 
                
                 | 
                							$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    804
                 | 
                                    
                                                     | 
                
                 | 
                							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    805
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    806
                 | 
                                    
                                                     | 
                
                 | 
                							return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    807
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    808
                 | 
                                    
                                                     | 
                
                 | 
                					} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    809
                 | 
                                    
                                                     | 
                
                 | 
                						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    810
                 | 
                                    
                                                     | 
                
                 | 
                						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    811
                 | 
                                    
                                                     | 
                
                 | 
                						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    812
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    813
                 | 
                                    
                                                     | 
                
                 | 
                							$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    814
                 | 
                                    
                                                     | 
                
                 | 
                							$sth->execute($query_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    815
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    816
                 | 
                                    
                                                     | 
                
                 | 
                							return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    817
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    818
                 | 
                                    
                                                     | 
                
                 | 
                						$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    819
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    820
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    821
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    822
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    823
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    824
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    825
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    826
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Download data from another free database...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    827
                 | 
                                    
                                                     | 
                
                 | 
                		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    828
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    829
                 | 
                                    
                                                     | 
                
                 | 
                		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    830
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    831
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    832
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Add data from another free database...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    833
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ':';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    834
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    835
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'GlobalAirportDatabase.txt', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    836
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    837
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    838
                 | 
                                    
                                                     | 
                
                 | 
                			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    839
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    840
                 | 
                                    
                                                     | 
                
                 | 
                				if(!$header) $header = $row;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    841
                 | 
                                    
                                                     | 
                
                 | 
                				else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    842
                 | 
                                    
                                                     | 
                
                 | 
                					$data = $row;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    843
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    844
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    845
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    846
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    847
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    848
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    849
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    850
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    851
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    852
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    853
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    854
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    855
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    856
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    857
                 | 
                                    
                                                     | 
                
                 | 
                		echo "Put type military for all air base";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    858
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    859
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    860
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    861
                 | 
                                    
                                                     | 
                
                 | 
                			$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    862
                 | 
                                    
                                                     | 
                
                 | 
                		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    863
                 | 
                                    
                                                     | 
                
                 | 
                			return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    864
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    865
                 | 
                                    
                                                     | 
                
                 | 
                		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    866
                 | 
                                    
                                                     | 
                
                 | 
                			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    867
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    868
                 | 
                                    
                                                     | 
                
                 | 
                				$sth2 = $Connection->db->prepare($query2);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    869
                 | 
                                    
                                                     | 
                
                 | 
                				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    870
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    871
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    872
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    873
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    874
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    875
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    876
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    877
                 | 
                                    
                                                     | 
                
                 | 
                                return "success";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    878
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    879
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    880
                 | 
                                    
                                                     | 
                
                 | 
                	public static function translation() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    881
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    882
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    883
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    884
                 | 
                                    
                                                     | 
                
                 | 
                		//$out_file = $tmp_dir.'translation.zip';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    885
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::download('http://www.acarsd.org/download/translation.php',$out_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    886
                 | 
                                    
                                                     | 
                
                 | 
                		//if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    887
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    888
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE translation';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    889
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM translation WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    890
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    891
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    892
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    893
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'translation.csv')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    894
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    895
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    896
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    897
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    898
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    899
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    900
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    901
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ';';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    902
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    903
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'translation.csv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    904
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    905
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    906
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    907
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    908
                 | 
                                    
                                                     | 
                
                 | 
                			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    909
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    910
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    911
                 | 
                                    
                                                     | 
                
                 | 
                				if($i > 12) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    912
                 | 
                                    
                                                     | 
                
                 | 
                					$data = $row;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    913
                 | 
                                    
                                                     | 
                
                 | 
                					$operator = $data[2];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    914
                 | 
                                    
                                                     | 
                
                 | 
                					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    915
                 | 
                                    
                                                     | 
                
                 | 
                                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    916
                 | 
                                    
                                                     | 
                
                 | 
                                                                //echo substr($operator, 0, 2)."\n";;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    917
                 | 
                                    
                                                     | 
                
                 | 
                                                                if (count($airline_array) > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    918
                 | 
                                    
                                                     | 
                
                 | 
                							//print_r($airline_array);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    919
                 | 
                                    
                                                     | 
                
                 | 
                							$operator = $airline_array[0]['icao'].substr($operator,2);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    920
                 | 
                                    
                                                     | 
                
                 | 
                                                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    921
                 | 
                                    
                                                     | 
                
                 | 
                                                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    922
                 | 
                                    
                                                     | 
                
                 | 
                					  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    923
                 | 
                                    
                                                     | 
                
                 | 
                					$operator_correct = $data[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    924
                 | 
                                    
                                                     | 
                
                 | 
                					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    925
                 | 
                                    
                                                     | 
                
                 | 
                                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    926
                 | 
                                    
                                                     | 
                
                 | 
                                                                if (count($airline_array) > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    927
                 | 
                                    
                                                     | 
                
                 | 
                                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    928
                 | 
                                    
                                                     | 
                
                 | 
                                                            	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    929
                 | 
                                    
                                                     | 
                
                 | 
                                                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    930
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    931
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    932
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    933
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    934
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    935
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    936
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    937
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    938
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    939
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    940
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    941
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    942
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    943
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    944
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    945
                 | 
                                    
                                                     | 
                
                 | 
                	public static function translation_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    946
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    947
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    948
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    949
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM translation WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    950
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    951
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    952
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    953
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    954
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    955
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    956
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    957
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    958
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    959
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    960
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    961
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = "\t";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    962
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    963
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'translation.tsv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    964
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    965
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    966
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    967
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    968
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    969
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    970
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    971
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    972
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    973
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    974
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    975
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    976
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    977
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    978
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    979
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    980
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    981
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    982
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    983
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    984
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    985
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    986
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    987
                 | 
                                    
                                                     | 
                
                 | 
                	/*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    988
                 | 
                                    
                                                     | 
                
                 | 
                	* This function use FAA public data.  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    989
                 | 
                                    
                                                     | 
                
                 | 
                	* With the help of data from other source, Mfr id is added to manufacturer table. Then ModeS with ICAO are added based on that.  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    990
                 | 
                                    
                                                     | 
                
                 | 
                	*/  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    991
                 | 
                                    
                                                     | 
                
                 | 
                	public static function modes_faa() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    992
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    993
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    994
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    995
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    996
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    997
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_faa')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    998
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    999
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1000
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1001
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1002
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1003
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1004
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1005
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1006
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_faa')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1007
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1008
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1009
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1010
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1011
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ",";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1012
                 | 
                                    
                                                     | 
                
                 | 
                		$mfr = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1013
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1014
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1015
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1016
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1017
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1018
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1019
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1020
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1021
                 | 
                                    
                                                     | 
                
                 | 
                					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1022
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1023
                 | 
                                    
                                                     | 
                
                 | 
                						$sths = $Connection->db->prepare($query_search);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1024
                 | 
                                    
                                                     | 
                
                 | 
                						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1025
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1026
                 | 
                                    
                                                     | 
                
                 | 
                						return "error s : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1027
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1028
                 | 
                                    
                                                     | 
                
                 | 
                					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1029
                 | 
                                    
                                                     | 
                
                 | 
                					if (!empty($result_search)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1030
                 | 
                                    
                                                     | 
                
                 | 
                						if ($globalDebug) echo '.';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1031
                 | 
                                    
                                                     | 
                
                 | 
                							//if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1032
                 | 
                                    
                                                     | 
                
                 | 
                							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1033
                 | 
                                    
                                                     | 
                
                 | 
                							//} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1034
                 | 
                                    
                                                     | 
                
                 | 
                								$queryi = "INSERT INTO faamfr (mfr,icao) SELECT :mfr,:icao WHERE NOT EXISTS (SELECT 1 FROM faamfr WHERE mfr = :mfr);";   | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1035
                 | 
                                    
                                                     | 
                
                 | 
                							//}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1036
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1037
                 | 
                                    
                                                     | 
                
                 | 
                							$sthi = $Connection->db->prepare($queryi);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1038
                 | 
                                    
                                                     | 
                
                 | 
                							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1039
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1040
                 | 
                                    
                                                     | 
                
                 | 
                							return "error u : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1041
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1042
                 | 
                                    
                                                     | 
                
                 | 
                					} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1043
                 | 
                                    
                                                     | 
                
                 | 
                						$query_search_mfr = 'SELECT icao FROM faamfr WHERE mfr = :mfr';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1044
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1045
                 | 
                                    
                                                     | 
                
                 | 
                							$sthsm = $Connection->db->prepare($query_search_mfr);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1046
                 | 
                                    
                                                     | 
                
                 | 
                							$sthsm->execute(array(':mfr' => $data[2])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1047
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1048
                 | 
                                    
                                                     | 
                
                 | 
                							return "error mfr : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1049
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1050
                 | 
                                    
                                                     | 
                
                 | 
                						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1051
                 | 
                                    
                                                     | 
                
                 | 
                						if (!empty($result_search_mfr)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1052
                 | 
                                    
                                                     | 
                
                 | 
                							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1053
                 | 
                                    
                                                     | 
                
                 | 
                							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1054
                 | 
                                    
                                                     | 
                
                 | 
                							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1055
                 | 
                                    
                                                     | 
                
                 | 
                							try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1056
                 | 
                                    
                                                     | 
                
                 | 
                								$sthf = $Connection->db->prepare($queryf);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1057
                 | 
                                    
                                                     | 
                
                 | 
                								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1058
                 | 
                                    
                                                     | 
                
                 | 
                							} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1059
                 | 
                                    
                                                     | 
                
                 | 
                								return "error f : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1060
                 | 
                                    
                                                     | 
                
                 | 
                							}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1061
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1062
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1063
                 | 
                                    
                                                     | 
                
                 | 
                					if (strtotime($data[29]) > time()) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1064
                 | 
                                    
                                                     | 
                
                 | 
                						if ($globalDebug) echo 'i';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1065
                 | 
                                    
                                                     | 
                
                 | 
                						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1066
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1067
                 | 
                                    
                                                     | 
                
                 | 
                							$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1068
                 | 
                                    
                                                     | 
                
                 | 
                							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1069
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1070
                 | 
                                    
                                                     | 
                
                 | 
                							return "error i : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1071
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1072
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1073
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1074
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i % 90 == 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1075
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1076
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1077
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1078
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1079
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1080
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1081
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1082
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1083
                 | 
                                    
                                                     | 
                
                 | 
                		print_r($mfr);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1084
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                                                                
            
                                    
            
            
                | 
                    1085
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1086
                 | 
                                    
                                                     | 
                
                 | 
                	public static function modes_fam() { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1087
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1088
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1089
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1090
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1091
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1092
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_fam')); | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1093
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1094
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1095
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1096
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1097
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1098
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1099
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = "\t";  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1100
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1101
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1102
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1103
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1104
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1105
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1106
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                        
                            
            
                                    
            
            
                | 
                    1107
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1108
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1109
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1110
                 | 
                                    
                                                     | 
                
                 | 
                					if ($data[1] == 'NULL') $data[1] = $data[0];  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1111
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1112
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1113
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1114
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1115
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1116
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1117
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1118
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1119
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1120
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1121
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1122
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                        
                            
            
                                    
            
            
                | 
                    1123
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1124
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                        
                            
            
                                    
            
            
                | 
                    1125
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1126
                 | 
                                    
                                                     | 
                
                 | 
                          | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1127
                 | 
                                    
                                                     | 
                
                 | 
                	public static function owner_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1128
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1129
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1130
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1131
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1132
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1133
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1134
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1135
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1136
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1137
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1138
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = "\t";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1139
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1140
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1141
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1142
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1143
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1144
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1145
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1146
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1147
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1148
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1149
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1150
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1151
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1152
                 | 
                                    
                                                     | 
                
                 | 
                						print_r($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1153
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1154
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1155
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1156
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1157
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1158
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1159
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1160
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1161
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1162
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1163
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1164
                 | 
                                    
                                                     | 
                
                 | 
                	public static function routes_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1165
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1166
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1167
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1168
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1169
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1170
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1171
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1172
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1173
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1174
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1175
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1176
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1177
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = "\t";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1178
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1179
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1180
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1181
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1182
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1183
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1184
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1185
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1186
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1187
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1188
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1189
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1190
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1191
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1192
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1193
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1194
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1195
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1196
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1197
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1198
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1199
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1200
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1201
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1202
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1203
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1204
                 | 
                                    
                                                     | 
                
                 | 
                	public static function marine_identity_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1205
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1206
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "TRUNCATE TABLE marine_identity";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1207
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1208
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1209
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1210
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1211
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1212
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1213
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1214
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1215
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1216
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1217
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = "\t";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1218
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1219
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'marine_identity.tsv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1220
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1221
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1222
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1223
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1224
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1225
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1226
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1227
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i > 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1228
                 | 
                                    
                                                     | 
                
                 | 
                					$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)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1229
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1230
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1231
                 | 
                                    
                                                     | 
                
                 | 
                						$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])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1232
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1233
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1234
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1235
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1236
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1237
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1238
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1239
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1240
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1241
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1242
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1243
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1244
                 | 
                                    
                                                     | 
                
                 | 
                	public static function banned_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1245
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1246
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "UPDATE airlines SET ban_eu = 0";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1247
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1248
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1249
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1250
                 | 
                                    
                                                     | 
                
                 | 
                			$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1251
                 | 
                                    
                                                     | 
                
                 | 
                		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1252
                 | 
                                    
                                                     | 
                
                 | 
                			return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1253
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1254
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1255
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1256
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1257
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1258
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1259
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgetcsv($handle, 1000)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1260
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1261
                 | 
                                    
                                                     | 
                
                 | 
                				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1262
                 | 
                                    
                                                     | 
                
                 | 
                				if ($data[0] != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1263
                 | 
                                    
                                                     | 
                
                 | 
                					$icao = $data[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1264
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1265
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1266
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':icao' => $icao)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1267
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1268
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1269
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1270
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1271
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1272
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1273
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1274
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1275
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1276
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1277
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1278
                 | 
                                    
                                                     | 
                
                 | 
                	public static function tle($filename,$tletype) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1279
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1280
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1281
                 | 
                                    
                                                     | 
                
                 | 
                		//$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1282
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1283
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM tle WHERE tle_source = '' OR tle_source = :source";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1284
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1285
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1286
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1287
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':source' => $filename)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1288
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1289
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1290
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1291
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1292
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1293
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($filename, 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1294
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1295
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1296
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1297
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1298
                 | 
                                    
                                                     | 
                
                 | 
                			$dbdata = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1299
                 | 
                                    
                                                     | 
                
                 | 
                			while (($data = fgets($handle, 1000)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1300
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1301
                 | 
                                    
                                                     | 
                
                 | 
                				if ($i == 0) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1302
                 | 
                                    
                                                     | 
                
                 | 
                					$dbdata['name'] = trim($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1303
                 | 
                                    
                                                     | 
                
                 | 
                					$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1304
                 | 
                                    
                                                     | 
                
                 | 
                				} elseif ($i == 1) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1305
                 | 
                                    
                                                     | 
                
                 | 
                					$dbdata['tle1'] = trim($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1306
                 | 
                                    
                                                     | 
                
                 | 
                					$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1307
                 | 
                                    
                                                     | 
                
                 | 
                				} elseif ($i == 2) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1308
                 | 
                                    
                                                     | 
                
                 | 
                					$dbdata['tle2'] = trim($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1309
                 | 
                                    
                                                     | 
                
                 | 
                					//print_r($dbdata);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1310
                 | 
                                    
                                                     | 
                
                 | 
                					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1311
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1312
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1313
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1314
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1315
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1316
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1317
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1318
                 | 
                                    
                                                     | 
                
                 | 
                					$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1319
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1320
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1321
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1322
                 | 
                                    
                                                     | 
                
                 | 
                			//$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1323
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1324
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1325
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1326
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1327
                 | 
                                    
                                                     | 
                
                 | 
                	/**  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1328
                 | 
                                    
                                                     | 
                
                 | 
                        * Convert a HTML table to an array  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1329
                 | 
                                    
                                                     | 
                
                 | 
                        * @param String $data HTML page  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1330
                 | 
                                    
                                                     | 
                
                 | 
                        * @return Array array of the tables in HTML page  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1331
                 | 
                                    
                                                     | 
                
                 | 
                        */  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1332
                 | 
                                    
                                                     | 
                
                 | 
                        private static function table2array($data) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1333
                 | 
                                    
                                                     | 
                
                 | 
                                $html = str_get_html($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1334
                 | 
                                    
                                                     | 
                
                 | 
                                $tabledata=array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1335
                 | 
                                    
                                                     | 
                
                 | 
                                foreach($html->find('tr') as $element) | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1336
                 | 
                                    
                                                     | 
                
                 | 
                                { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1337
                 | 
                                    
                                                     | 
                
                 | 
                                        $td = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1338
                 | 
                                    
                                                     | 
                
                 | 
                                        foreach( $element->find('th') as $row) | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1339
                 | 
                                    
                                                     | 
                
                 | 
                                        { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1340
                 | 
                                    
                                                     | 
                
                 | 
                                                $td [] = trim($row->plaintext);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1341
                 | 
                                    
                                                     | 
                
                 | 
                                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1342
                 | 
                                    
                                                     | 
                
                 | 
                                        $td=array_filter($td);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1343
                 | 
                                    
                                                     | 
                
                 | 
                                        $tabledata[] = $td;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1344
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1345
                 | 
                                    
                                                     | 
                
                 | 
                                        $td = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1346
                 | 
                                    
                                                     | 
                
                 | 
                                        $tdi = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1347
                 | 
                                    
                                                     | 
                
                 | 
                                        foreach( $element->find('td') as $row) | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1348
                 | 
                                    
                                                     | 
                
                 | 
                                        { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1349
                 | 
                                    
                                                     | 
                
                 | 
                                                $td [] = trim($row->plaintext);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1350
                 | 
                                    
                                                     | 
                
                 | 
                                                $tdi [] = trim($row->innertext);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1351
                 | 
                                    
                                                     | 
                
                 | 
                                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1352
                 | 
                                    
                                                     | 
                
                 | 
                                        $td=array_filter($td);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1353
                 | 
                                    
                                                     | 
                
                 | 
                                        $tdi=array_filter($tdi);  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1354
                 | 
                                    
                                                     | 
                
                 | 
                                    //    $tabledata[]=array_merge($td,$tdi);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1355
                 | 
                                    
                                                     | 
                
                 | 
                                        $tabledata[]=$td;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1356
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1357
                 | 
                                    
                                                     | 
                
                 | 
                                return(array_filter($tabledata));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1358
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1359
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1360
                 | 
                                    
                                                     | 
                
                 | 
                       /**  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1361
                 | 
                                    
                                                     | 
                
                 | 
                        * Get data from form result  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1362
                 | 
                                    
                                                     | 
                
                 | 
                        * @param String $url form URL  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1363
                 | 
                                    
                                                     | 
                
                 | 
                        * @return String the result  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1364
                 | 
                                    
                                                     | 
                
                 | 
                        */  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1365
                 | 
                                    
                                                     | 
                
                 | 
                        private static function getData($url) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1366
                 | 
                                    
                                                     | 
                
                 | 
                                $ch = curl_init();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1367
                 | 
                                    
                                                     | 
                
                 | 
                                curl_setopt($ch, CURLOPT_URL, $url);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1368
                 | 
                                    
                                                     | 
                
                 | 
                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1369
                 | 
                                    
                                                     | 
                
                 | 
                                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1370
                 | 
                                    
                                                     | 
                
                 | 
                                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');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1371
                 | 
                                    
                                                     | 
                
                 | 
                                return curl_exec($ch);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1372
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1373
                 | 
                                    
                                                     | 
                
                 | 
                /*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1374
                 | 
                                    
                                                     | 
                
                 | 
                	public static function waypoints() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1375
                 | 
                                    
                                                     | 
                
                 | 
                		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1376
                 | 
                                    
                                                     | 
                
                 | 
                		$table = update_db::table2array($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1377
                 | 
                                    
                                                     | 
                
                 | 
                //		print_r($table);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1378
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'TRUNCATE TABLE waypoints';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1379
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1380
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1381
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1382
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1383
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1384
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1385
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1386
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1387
                 | 
                                    
                                                     | 
                
                 | 
                		$query_dest = 'INSERT INTO waypoints (`ident`,`latitude`,`longitude`,`control`,`usage`) VALUES (:ident, :latitude, :longitude, :control, :usage)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1388
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1389
                 | 
                                    
                                                     | 
                
                 | 
                		$sth_dest = $Connection->db->prepare($query_dest);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1390
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection->db->beginTransaction();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1391
                 | 
                                    
                                                     | 
                
                 | 
                                foreach ($table as $row) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1392
                 | 
                                    
                                                     | 
                
                 | 
                            		if ($row[0] != 'Ident') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1393
                 | 
                                    
                                                     | 
                
                 | 
                				$ident = $row[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1394
                 | 
                                    
                                                     | 
                
                 | 
                				$latitude = $row[2];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1395
                 | 
                                    
                                                     | 
                
                 | 
                				$longitude = $row[3];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1396
                 | 
                                    
                                                     | 
                
                 | 
                				$control = $row[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1397
                 | 
                                    
                                                     | 
                
                 | 
                				if (isset($row[5])) $usage = $row[5]; else $usage = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1398
                 | 
                                    
                                                     | 
                
                 | 
                				$query_dest_values = array(':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':control' => $control,':usage' => $usage); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1399
                 | 
                                    
                                                     | 
                
                 | 
                				try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1400
                 | 
                                    
                                                     | 
                
                 | 
                					$sth_dest->execute($query_dest_values);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1401
                 | 
                                    
                                                     | 
                
                 | 
                				} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1402
                 | 
                                    
                                                     | 
                
                 | 
                					return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1403
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1404
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1405
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1406
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection->db->commit();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1407
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1408
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1409
                 | 
                                    
                                                     | 
                
                 | 
                */  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1410
                 | 
                                    
                                                     | 
                
                 | 
                	public static function waypoints($filename) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1411
                 | 
                                    
                                                     | 
                
                 | 
                		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1412
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1413
                 | 
                                    
                                                     | 
                
                 | 
                		//$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1414
                 | 
                                    
                                                     | 
                
                 | 
                		//$out_file = $tmp_dir.'translation.zip';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1415
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::download('http://www.acarsd.org/download/translation.php',$out_file); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1416
                 | 
                                    
                                                     | 
                
                 | 
                		//if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1417
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1418
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::unzip($out_file);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1419
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1420
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ' ';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1421
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($filename, 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1422
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1423
                 | 
                                    
                                                     | 
                
                 | 
                			$i = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1424
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1425
                 | 
                                    
                                                     | 
                
                 | 
                			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1426
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1427
                 | 
                                    
                                                     | 
                
                 | 
                				$i++;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1428
                 | 
                                    
                                                     | 
                
                 | 
                				if($i > 3 && count($row) > 2) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1429
                 | 
                                    
                                                     | 
                
                 | 
                					$data = array_values(array_filter($row));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1430
                 | 
                                    
                                                     | 
                
                 | 
                					$cntdata = count($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1431
                 | 
                                    
                                                     | 
                
                 | 
                					if ($cntdata > 10) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1432
                 | 
                                    
                                                     | 
                
                 | 
                						$value = $data[9];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1433
                 | 
                                    
                                                     | 
                
                 | 
                						  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1434
                 | 
                                    
                                                     | 
                
                 | 
                						for ($i =10;$i < $cntdata;$i++) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1435
                 | 
                                    
                                                     | 
                
                 | 
                							$value .= ' '.$data[$i];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1436
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1437
                 | 
                                    
                                                     | 
                
                 | 
                						$data[9] = $value;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1438
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1439
                 | 
                                    
                                                     | 
                
                 | 
                					//print_r($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1440
                 | 
                                    
                                                     | 
                
                 | 
                					if (count($data) > 9) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1441
                 | 
                                    
                                                     | 
                
                 | 
                						$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)';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1442
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1443
                 | 
                                    
                                                     | 
                
                 | 
                							$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1444
                 | 
                                    
                                                     | 
                
                 | 
                							$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])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1445
                 | 
                                    
                                                     | 
                
                 | 
                						} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1446
                 | 
                                    
                                                     | 
                
                 | 
                							return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1447
                 | 
                                    
                                                     | 
                
                 | 
                						}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1448
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1449
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1450
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1451
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1452
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1453
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1454
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1455
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1456
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1457
                 | 
                                    
                                                     | 
                
                 | 
                	public static function ivao_airlines($filename) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1458
                 | 
                                    
                                                     | 
                
                 | 
                		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1459
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalTransaction;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1460
                 | 
                                    
                                                     | 
                
                 | 
                		//$query = 'TRUNCATE TABLE airlines';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1461
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM airlines WHERE forsource = 'ivao'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1462
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1463
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1464
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1465
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1466
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1467
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1468
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1469
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1470
                 | 
                                    
                                                     | 
                
                 | 
                		$header = NULL;  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1471
                 | 
                                    
                                                     | 
                
                 | 
                		$delimiter = ':';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1472
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1473
                 | 
                                    
                                                     | 
                
                 | 
                		if (($handle = fopen($filename, 'r')) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1474
                 | 
                                    
                                                     | 
                
                 | 
                		{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1475
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->beginTransaction();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1476
                 | 
                                    
                                                     | 
                
                 | 
                			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1477
                 | 
                                    
                                                     | 
                
                 | 
                			{ | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1478
                 | 
                                    
                                                     | 
                
                 | 
                				if(count($row) > 1) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1479
                 | 
                                    
                                                     | 
                
                 | 
                					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1480
                 | 
                                    
                                                     | 
                
                 | 
                					try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1481
                 | 
                                    
                                                     | 
                
                 | 
                						$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1482
                 | 
                                    
                                                     | 
                
                 | 
                						$sth->execute(array(':name' => $row[1],':icao' => $row[0])); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1483
                 | 
                                    
                                                     | 
                
                 | 
                					} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1484
                 | 
                                    
                                                     | 
                
                 | 
                						return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1485
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1486
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1487
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1488
                 | 
                                    
                                                     | 
                
                 | 
                			fclose($handle);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1489
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalTransaction) $Connection->db->commit();  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1490
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1491
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1492
                 | 
                                    
                                                     | 
                
                 | 
                        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1493
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1494
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_airspace() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1495
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1496
                 | 
                                    
                                                     | 
                
                 | 
                		include_once('class.create_db.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1497
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1498
                 | 
                                    
                                                     | 
                
                 | 
                		if ($Connection->tableExists('airspace')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1499
                 | 
                                    
                                                     | 
                
                 | 
                			$query = 'DROP TABLE airspace';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1500
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1501
                 | 
                                    
                                                     | 
                
                 | 
                				$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1502
                 | 
                                    
                                                     | 
                
                 | 
                                    		$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1503
                 | 
                                    
                                                     | 
                
                 | 
                	                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1504
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1505
                 | 
                                    
                                                     | 
                
                 | 
                	                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1506
                 | 
                                    
                                                     | 
                
                 | 
                	        }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1507
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1508
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1509
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1510
                 | 
                                    
                                                     | 
                
                 | 
                		else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1511
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1512
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "CREATE EXTENSION postgis";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1513
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1514
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1515
                 | 
                                    
                                                     | 
                
                 | 
                				$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1516
                 | 
                                    
                                                     | 
                
                 | 
                				$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1517
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1518
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1519
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1520
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1521
                 | 
                                    
                                                     | 
                
                 | 
                		$error = create_db::import_file($tmp_dir.'airspace.sql');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1522
                 | 
                                    
                                                     | 
                
                 | 
                		return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1523
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1524
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1525
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_notam_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1526
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1527
                 | 
                                    
                                                     | 
                
                 | 
                		include_once('class.create_db.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1528
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1529
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1530
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1531
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1532
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'notam.txt.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1533
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1534
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'notam.txt.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1535
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1536
                 | 
                                    
                                                     | 
                
                 | 
                			//$error = create_db::import_file($tmp_dir.'notam.sql');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1537
                 | 
                                    
                                                     | 
                
                 | 
                			$NOTAM = new NOTAM();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1538
                 | 
                                    
                                                     | 
                
                 | 
                			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1539
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1540
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1541
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1542
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1543
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1544
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1545
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1546
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_vatsim() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1547
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1548
                 | 
                                    
                                                     | 
                
                 | 
                		include_once('class.create_db.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1549
                 | 
                                    
                                                     | 
                
                 | 
                		$error = create_db::import_file('../db/vatsim/airlines.sql'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1550
                 | 
                                    
                                                     | 
                
                 | 
                		return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1551
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1552
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1553
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_countries() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1554
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1555
                 | 
                                    
                                                     | 
                
                 | 
                		include_once('class.create_db.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1556
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1557
                 | 
                                    
                                                     | 
                
                 | 
                		if ($Connection->tableExists('countries')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1558
                 | 
                                    
                                                     | 
                
                 | 
                			$query = 'DROP TABLE countries';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1559
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1560
                 | 
                                    
                                                     | 
                
                 | 
                				$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1561
                 | 
                                    
                                                     | 
                
                 | 
                            	        	$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1562
                 | 
                                    
                                                     | 
                
                 | 
                	                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1563
                 | 
                                    
                                                     | 
                
                 | 
                    	                	echo "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1564
                 | 
                                    
                                                     | 
                
                 | 
                	                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1565
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1566
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1567
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1568
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1569
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1570
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1571
                 | 
                                    
                                                     | 
                
                 | 
                		$error = create_db::import_file($tmp_dir.'countries.sql');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1572
                 | 
                                    
                                                     | 
                
                 | 
                		return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1573
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1574
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1575
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1576
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_waypoints() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1577
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1578
                 | 
                                    
                                                     | 
                
                 | 
                //		update_db::download('http://dev.x-plane.com/update/data/AptNav201310XP1000.zip',$tmp_dir.'AptNav.zip'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1579
                 | 
                                    
                                                     | 
                
                 | 
                //		update_db::unzip($tmp_dir.'AptNav.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1580
                 | 
                                    
                                                     | 
                
                 | 
                //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1581
                 | 
                                    
                                                     | 
                
                 | 
                //		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'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1582
                 | 
                                    
                                                     | 
                
                 | 
                		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'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1583
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::gunzip($tmp_dir.'awy.dat.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1584
                 | 
                                    
                                                     | 
                
                 | 
                		$error = update_db::waypoints($tmp_dir.'awy.dat');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1585
                 | 
                                    
                                                     | 
                
                 | 
                		return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1586
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1587
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1588
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ivao() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1589
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1590
                 | 
                                    
                                                     | 
                
                 | 
                		$Common = new Common();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1591
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1592
                 | 
                                    
                                                     | 
                
                 | 
                		//Direct download forbidden  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1593
                 | 
                                    
                                                     | 
                
                 | 
                		//if ($globalDebug) echo "IVAO : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1594
                 | 
                                    
                                                     | 
                
                 | 
                		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1595
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'ivae_feb2013.zip')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1596
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Unzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1597
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::unzip($tmp_dir.'ivae_feb2013.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1598
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1599
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1600
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1601
                 | 
                                    
                                                     | 
                
                 | 
                			if (is_writable(dirname(__FILE__).'/../images/airlines')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1602
                 | 
                                    
                                                     | 
                
                 | 
                				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1603
                 | 
                                    
                                                     | 
                
                 | 
                			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1604
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1605
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1606
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1607
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1608
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1609
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1610
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1611
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_routes() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1612
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1613
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1614
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Routes : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1615
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1616
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'StandingData.sqb.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1617
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1618
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1619
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1620
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1621
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1622
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1623
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1624
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1625
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1626
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1627
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_oneworld() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1628
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1629
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1630
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Schedules Oneworld : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1631
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1632
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'oneworld.csv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1633
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1634
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'oneworld.csv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1635
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1636
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1637
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1638
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1639
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1640
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1641
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1642
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1643
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_skyteam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1644
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1645
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1646
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Schedules Skyteam : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1647
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1648
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'skyteam.csv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1649
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1650
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'skyteam.csv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1651
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1652
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1653
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1654
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1655
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1656
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1657
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1658
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1659
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ModeS() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1660
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1661
                 | 
                                    
                                                     | 
                
                 | 
                /*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1662
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Modes : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1663
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://pp-sqb.mantma.co.uk/basestation_latest.zip',$tmp_dir.'basestation_latest.zip'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1664
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Unzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1665
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::unzip($tmp_dir.'basestation_latest.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1666
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1667
                 | 
                                    
                                                     | 
                
                 | 
                		$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'/basestation_latest/basestation.sqb');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1668
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != true) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1669
                 | 
                                    
                                                     | 
                
                 | 
                			echo $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1670
                 | 
                                    
                                                     | 
                
                 | 
                			exit;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1671
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1672
                 | 
                                    
                                                     | 
                
                 | 
                */  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1673
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Modes : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1674
                 | 
                                    
                                                     | 
                
                 | 
                //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1675
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1676
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1677
                 | 
                                    
                                                     | 
                
                 | 
                //		if (file_exists($tmp_dir.'basestation_latest.zip')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1678
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1679
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Unzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1680
                 | 
                                    
                                                     | 
                
                 | 
                //			update_db::unzip($tmp_dir.'basestation_latest.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1681
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1682
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1683
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1684
                 | 
                                    
                                                     | 
                
                 | 
                //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1685
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1686
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1687
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1688
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1689
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1690
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1691
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1692
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ModeS_faa() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1693
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1694
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Modes FAA: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1695
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1696
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1697
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Unzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1698
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1699
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1700
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::modes_faa();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1701
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1702
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1703
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1704
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1705
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1706
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1707
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1708
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ModeS_flarm() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1709
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1710
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Modes Flarmnet: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1711
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1712
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'data.fln')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1713
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1714
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1715
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1716
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1717
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1718
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1719
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1720
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1721
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1722
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ModeS_ogn() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1723
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1724
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Modes OGN: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1725
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1726
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'ogn.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1727
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1728
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1729
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1730
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1731
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1732
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1733
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1734
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1735
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1736
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_owner() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1737
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug, $globalMasterSource;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1738
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1739
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner France: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1740
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1741
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_f.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1742
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1743
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1744
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1745
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1746
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1747
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1748
                 | 
                                    
                                                     | 
                
                 | 
                		  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1749
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Ireland: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1750
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1751
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_ei.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1752
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1753
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1754
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1755
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1756
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1757
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1758
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Switzerland: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1759
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1760
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_hb.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1761
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1762
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1763
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1764
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1765
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1766
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1767
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Czech Republic: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1768
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1769
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_ok.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1770
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1771
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1772
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1773
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1774
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1775
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1776
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Australia: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1777
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1778
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_vh.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1779
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1780
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1781
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1782
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1783
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1784
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1785
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Austria: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1786
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1787
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_oe.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1788
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1789
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1790
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1791
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1792
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1793
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1794
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Chile: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1795
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1796
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_cc.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1797
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1798
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1799
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1800
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1801
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1802
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1803
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Colombia: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1804
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1805
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_hj.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1806
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1807
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1808
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1809
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1810
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1811
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1812
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1813
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1814
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_e7.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1815
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1816
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1817
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1818
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1819
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1820
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1821
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Brazil: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1822
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1823
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_pp.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1824
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1825
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1826
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1827
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1828
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1829
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1830
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Cayman Islands: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1831
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1832
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_vp.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1833
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1834
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1835
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1836
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1837
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1838
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1839
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Croatia: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1840
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1841
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_9a.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1842
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1843
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1844
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1845
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1846
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1847
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1848
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Luxembourg: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1849
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1850
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_lx.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1851
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1852
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1853
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1854
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1855
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1856
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1857
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Maldives: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1858
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1859
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_8q.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1860
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1861
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1862
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1863
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1864
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1865
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1866
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner New Zealand: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1867
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1868
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_zk.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1869
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1870
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1871
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1872
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1873
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1874
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1875
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Papua New Guinea: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1876
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1877
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_p2.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1878
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1879
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1880
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1881
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1882
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1883
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1884
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Slovakia: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1885
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1886
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_om.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1887
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1888
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1889
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1890
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1891
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1892
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1893
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Ecuador: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1894
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1895
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_hc.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1896
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1897
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1898
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1899
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1900
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1901
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1902
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Iceland: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1903
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1904
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_tf.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1905
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1906
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1907
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1908
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1909
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1910
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1911
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Owner Isle of Man: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1912
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1913
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owner_m.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1914
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1915
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1916
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1917
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1918
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1919
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1920
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalMasterSource) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1921
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "ModeS Netherlands: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1922
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1923
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists($tmp_dir.'owner_ph.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1924
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1925
                 | 
                                    
                                                     | 
                
                 | 
                				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1926
                 | 
                                    
                                                     | 
                
                 | 
                			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1927
                 | 
                                    
                                                     | 
                
                 | 
                			if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1928
                 | 
                                    
                                                     | 
                
                 | 
                				return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1929
                 | 
                                    
                                                     | 
                
                 | 
                			} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1930
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "ModeS Denmark: Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1931
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1932
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists($tmp_dir.'owner_oy.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1933
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1934
                 | 
                                    
                                                     | 
                
                 | 
                				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1935
                 | 
                                    
                                                     | 
                
                 | 
                			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1936
                 | 
                                    
                                                     | 
                
                 | 
                			if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1937
                 | 
                                    
                                                     | 
                
                 | 
                				return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1938
                 | 
                                    
                                                     | 
                
                 | 
                			} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1939
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1940
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1941
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1942
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1943
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_translation() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1944
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1945
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1946
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Translation : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1947
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1948
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'translation.zip')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1949
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Unzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1950
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::unzip($tmp_dir.'translation.zip');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1951
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1952
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::translation();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1953
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1954
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1955
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1956
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1957
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1958
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1959
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1960
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_translation_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1961
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1962
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1963
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1964
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'translation.tsv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1965
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1966
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'translation.tsv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1967
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1968
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::translation_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1969
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1970
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1971
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1972
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1973
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1974
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1975
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_ModeS_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1976
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1977
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1978
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1979
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'modes.tsv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1980
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1981
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'modes.tsv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1982
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1983
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::modes_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1984
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1985
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1986
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1987
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1988
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1989
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1990
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_owner_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1991
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug, $globalOwner;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1992
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "owner from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1993
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalOwner === TRUE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1994
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1995
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1996
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1997
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1998
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'owners.tsv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    1999
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2000
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'owners.tsv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2001
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2002
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::owner_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2003
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2004
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2005
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2006
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2007
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2008
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2009
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_routes_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2010
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2011
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2012
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2013
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'routes.tsv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2014
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2015
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::gunzip($tmp_dir.'routes.tsv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2016
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2017
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::routes_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2018
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2019
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2020
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2021
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2022
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2023
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2024
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_marine_identity_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2025
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2026
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2027
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2028
                 | 
                                    
                                                     | 
                
                 | 
                			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2029
                 | 
                                    
                                                     | 
                
                 | 
                			$marine_identity_md5 = $marine_identity_md5_file[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2030
                 | 
                                    
                                                     | 
                
                 | 
                			if (!update_db::check_marine_identity_version($marine_identity_md5)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2031
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2032
                 | 
                                    
                                                     | 
                
                 | 
                				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2033
                 | 
                                    
                                                     | 
                
                 | 
                				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2034
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2035
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2036
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2037
                 | 
                                    
                                                     | 
                
                 | 
                					$error = update_db::marine_identity_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2038
                 | 
                                    
                                                     | 
                
                 | 
                				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2039
                 | 
                                    
                                                     | 
                
                 | 
                				if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2040
                 | 
                                    
                                                     | 
                
                 | 
                					return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2041
                 | 
                                    
                                                     | 
                
                 | 
                				} elseif ($globalDebug) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2042
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::insert_marine_identity_version($marine_identity_md5);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2043
                 | 
                                    
                                                     | 
                
                 | 
                					echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2044
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2045
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2046
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2047
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2048
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2049
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_banned_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2050
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2051
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2052
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2053
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'ban_eu.csv')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2054
                 | 
                                    
                                                     | 
                
                 | 
                			//if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2055
                 | 
                                    
                                                     | 
                
                 | 
                			//update_db::gunzip($tmp_dir.'ban_ue.csv');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2056
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2057
                 | 
                                    
                                                     | 
                
                 | 
                			$error = update_db::banned_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2058
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2059
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2060
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2061
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2062
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2063
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2064
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2065
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_airspace_fam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2066
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug, $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2067
                 | 
                                    
                                                     | 
                
                 | 
                		include_once('class.create_db.php'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2068
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2069
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2070
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2071
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2072
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2073
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2074
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2075
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2076
                 | 
                                    
                                                     | 
                
                 | 
                			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2077
                 | 
                                    
                                                     | 
                
                 | 
                			$airspace_md5 = $airspace_md5_file[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2078
                 | 
                                    
                                                     | 
                
                 | 
                			if (!update_db::check_airspace_version($airspace_md5)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2079
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2080
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2081
                 | 
                                    
                                                     | 
                
                 | 
                				} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2082
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2083
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2084
                 | 
                                    
                                                     | 
                
                 | 
                				if (file_exists($tmp_dir.'airspace.sql.gz')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2085
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalDebug) echo "Gunzip...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2086
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::gunzip($tmp_dir.'airspace.sql.gz');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2087
                 | 
                                    
                                                     | 
                
                 | 
                					if ($globalDebug) echo "Add to DB...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2088
                 | 
                                    
                                                     | 
                
                 | 
                					$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2089
                 | 
                                    
                                                     | 
                
                 | 
                					if ($Connection->tableExists('airspace')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2090
                 | 
                                    
                                                     | 
                
                 | 
                						$query = 'DROP TABLE airspace';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2091
                 | 
                                    
                                                     | 
                
                 | 
                						try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2092
                 | 
                                    
                                                     | 
                
                 | 
                							$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2093
                 | 
                                    
                                                     | 
                
                 | 
                    	    	    					$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2094
                 | 
                                    
                                                     | 
                
                 | 
                			            		} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2095
                 | 
                                    
                                                     | 
                
                 | 
                							return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2096
                 | 
                                    
                                                     | 
                
                 | 
                		            			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2097
                 | 
                                    
                                                     | 
                
                 | 
                		    			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2098
                 | 
                                    
                                                     | 
                
                 | 
                					$error = create_db::import_file($tmp_dir.'airspace.sql');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2099
                 | 
                                    
                                                     | 
                
                 | 
                					update_db::insert_airspace_version($airspace_md5);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2100
                 | 
                                    
                                                     | 
                
                 | 
                				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2101
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2102
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2103
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2104
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2105
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2106
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2107
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2108
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2109
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_tle() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2110
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2111
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Download TLE : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2112
                 | 
                                    
                                                     | 
                
                 | 
                		$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', | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2113
                 | 
                                    
                                                     | 
                
                 | 
                		'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',  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2114
                 | 
                                    
                                                     | 
                
                 | 
                		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2115
                 | 
                                    
                                                     | 
                
                 | 
                		foreach ($alltle as $filename) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2116
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "downloading ".$filename.'...';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2117
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2118
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists($tmp_dir.$filename)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2119
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo "Add to DB ".$filename."...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2120
                 | 
                                    
                                                     | 
                
                 | 
                				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2121
                 | 
                                    
                                                     | 
                
                 | 
                			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2122
                 | 
                                    
                                                     | 
                
                 | 
                			if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2123
                 | 
                                    
                                                     | 
                
                 | 
                				echo $error."\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2124
                 | 
                                    
                                                     | 
                
                 | 
                			} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2125
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2126
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2127
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2128
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2129
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_models() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2130
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2131
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2132
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Models from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2133
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2134
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2135
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Check files...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2136
                 | 
                                    
                                                     | 
                
                 | 
                			$newmodelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2137
                 | 
                                    
                                                     | 
                
                 | 
                			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2138
                 | 
                                    
                                                     | 
                
                 | 
                				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2139
                 | 
                                    
                                                     | 
                
                 | 
                					$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2140
                 | 
                                    
                                                     | 
                
                 | 
                					$newmodelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2141
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2142
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2143
                 | 
                                    
                                                     | 
                
                 | 
                			$modelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2144
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2145
                 | 
                                    
                                                     | 
                
                 | 
                				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2146
                 | 
                                    
                                                     | 
                
                 | 
                					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2147
                 | 
                                    
                                                     | 
                
                 | 
                						$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2148
                 | 
                                    
                                                     | 
                
                 | 
                						$modelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2149
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2150
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2151
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2152
                 | 
                                    
                                                     | 
                
                 | 
                			$diff = array_diff($newmodelsdb,$modelsdb);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2153
                 | 
                                    
                                                     | 
                
                 | 
                			foreach ($diff as $key => $value) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2154
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2155
                 | 
                                    
                                                     | 
                
                 | 
                				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2156
                 | 
                                    
                                                     | 
                
                 | 
                				  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2157
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2158
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2159
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2160
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2161
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2162
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2163
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2164
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2165
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2166
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_space_models() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2167
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2168
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2169
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2170
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2171
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'space_models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2172
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Check files...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2173
                 | 
                                    
                                                     | 
                
                 | 
                			$newmodelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2174
                 | 
                                    
                                                     | 
                
                 | 
                			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2175
                 | 
                                    
                                                     | 
                
                 | 
                				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2176
                 | 
                                    
                                                     | 
                
                 | 
                					$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2177
                 | 
                                    
                                                     | 
                
                 | 
                					$newmodelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2178
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2179
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2180
                 | 
                                    
                                                     | 
                
                 | 
                			$modelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2181
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2182
                 | 
                                    
                                                     | 
                
                 | 
                				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2183
                 | 
                                    
                                                     | 
                
                 | 
                					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2184
                 | 
                                    
                                                     | 
                
                 | 
                						$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2185
                 | 
                                    
                                                     | 
                
                 | 
                						$modelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2186
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2187
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2188
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2189
                 | 
                                    
                                                     | 
                
                 | 
                			$diff = array_diff($newmodelsdb,$modelsdb);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2190
                 | 
                                    
                                                     | 
                
                 | 
                			foreach ($diff as $key => $value) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2191
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2192
                 | 
                                    
                                                     | 
                
                 | 
                				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2193
                 | 
                                    
                                                     | 
                
                 | 
                				  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2194
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2195
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2196
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2197
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2198
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2199
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2200
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2201
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2202
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2203
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_vehicules_models() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2204
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2205
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2206
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2207
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2208
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'vehicules_models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2209
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo "Check files...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2210
                 | 
                                    
                                                     | 
                
                 | 
                			$newmodelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2211
                 | 
                                    
                                                     | 
                
                 | 
                			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2212
                 | 
                                    
                                                     | 
                
                 | 
                				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2213
                 | 
                                    
                                                     | 
                
                 | 
                					$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2214
                 | 
                                    
                                                     | 
                
                 | 
                					$newmodelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2215
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2216
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2217
                 | 
                                    
                                                     | 
                
                 | 
                			$modelsdb = array();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2218
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2219
                 | 
                                    
                                                     | 
                
                 | 
                				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2220
                 | 
                                    
                                                     | 
                
                 | 
                					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2221
                 | 
                                    
                                                     | 
                
                 | 
                						$model = trim($row[2]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2222
                 | 
                                    
                                                     | 
                
                 | 
                						$modelsdb[$model] = trim($row[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2223
                 | 
                                    
                                                     | 
                
                 | 
                					}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2224
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2225
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2226
                 | 
                                    
                                                     | 
                
                 | 
                			$diff = array_diff($newmodelsdb,$modelsdb);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2227
                 | 
                                    
                                                     | 
                
                 | 
                			foreach ($diff as $key => $value) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2228
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2229
                 | 
                                    
                                                     | 
                
                 | 
                				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2230
                 | 
                                    
                                                     | 
                
                 | 
                				  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2231
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2232
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2233
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2234
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2235
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2236
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2237
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2238
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2239
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2240
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_aircraft() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2241
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2242
                 | 
                                    
                                                     | 
                
                 | 
                		date_default_timezone_set('UTC'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2243
                 | 
                                    
                                                     | 
                
                 | 
                		//$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2244
                 | 
                                    
                                                     | 
                
                 | 
                		/*  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2245
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Aircrafts : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2246
                 | 
                                    
                                                     | 
                
                 | 
                		$data_req_array = array('Mnfctrer' => '','Model' => '','Dscrptn'=> '','EngCount' =>'' ,'EngType'=> '','TDesig' => '*','WTC' => '','Button' => 'Search'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2247
                 | 
                                    
                                                     | 
                
                 | 
                		$data_req = 'Mnfctrer=Airbus&Model=&Dscrptn=&EngCount=&EngType=&TDesig=&WTC=&Button=Search';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2248
                 | 
                                    
                                                     | 
                
                 | 
                		//$data = Common::getData('http://cfapp.icao.int/Doc8643/8643_List1.cfm','post',$data_req_array,array('Content-Type: application/x-www-form-urlencoded','Host: cfapp.icao.int','Origin: http://cfapp.icao.int','Pragma: no-cache','Upgrade-Insecure-Requests: 1','Content-Length: '.strlen($data_req)),'','http://cfapp.icao.int/Doc8643/search.cfm',20); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2249
                 | 
                                    
                                                     | 
                
                 | 
                		$data = Common::getData('http://cfapp.icao.int/Doc8643/8643_List1.cfm','post',$data_req_array,'','','http://cfapp.icao.int/Doc8643/search.cfm',30); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2250
                 | 
                                    
                                                     | 
                
                 | 
                //		echo strlen($data_req);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2251
                 | 
                                    
                                                     | 
                
                 | 
                		echo $data;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2252
                 | 
                                    
                                                     | 
                
                 | 
                		*/  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2253
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'aircrafts.html')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2254
                 | 
                                    
                                                     | 
                
                 | 
                		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2255
                 | 
                                    
                                                     | 
                
                 | 
                		    $fh = fopen($tmp_dir.'aircrafts.html',"r");  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2256
                 | 
                                    
                                                     | 
                
                 | 
                		    $result = fread($fh,100000000);  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2257
                 | 
                                    
                                                     | 
                
                 | 
                		    //echo $result;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2258
                 | 
                                    
                                                     | 
                
                 | 
                		    //var_dump(str_get_html($result));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2259
                 | 
                                    
                                                     | 
                
                 | 
                		    //print_r(self::table2array($result));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2260
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2261
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2262
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2263
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2264
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_notam() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2265
                 | 
                                    
                                                     | 
                
                 | 
                		global $tmp_dir, $globalDebug, $globalNOTAMSource;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2266
                 | 
                                    
                                                     | 
                
                 | 
                		require(dirname(__FILE__).'/../require/class.NOTAM.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2267
                 | 
                                    
                                                     | 
                
                 | 
                		$Common = new Common();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2268
                 | 
                                    
                                                     | 
                
                 | 
                		date_default_timezone_set('UTC'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2269
                 | 
                                    
                                                     | 
                
                 | 
                		$query = 'TRUNCATE TABLE notam';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2270
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2271
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2272
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2273
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2274
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2275
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2276
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2277
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2278
                 | 
                                    
                                                     | 
                
                 | 
                		$error = '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2279
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDebug) echo "Notam : Download...";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2280
                 | 
                                    
                                                     | 
                
                 | 
                		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2281
                 | 
                                    
                                                     | 
                
                 | 
                		if (file_exists($tmp_dir.'notam.rss')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2282
                 | 
                                    
                                                     | 
                
                 | 
                			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2283
                 | 
                                    
                                                     | 
                
                 | 
                			foreach ($notams['channel']['item'] as $notam) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2284
                 | 
                                    
                                                     | 
                
                 | 
                				$title = explode(':',$notam['title']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2285
                 | 
                                    
                                                     | 
                
                 | 
                				$data['ref'] = trim($title[0]);  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2286
                 | 
                                    
                                                     | 
                
                 | 
                				unset($title[0]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2287
                 | 
                                    
                                                     | 
                
                 | 
                				$data['title'] = trim(implode(':',$title)); | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                    
                        
                         
                                                                                        
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2288
                 | 
                                    
                                                     | 
                
                 | 
                				$description = strip_tags($notam['description'],'<pre>');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2289
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match(':^(.*?)<pre>:',$description,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2290
                 | 
                                    
                                                     | 
                
                 | 
                				$q = explode('/',$match[1]); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2291
                 | 
                                    
                                                     | 
                
                 | 
                				$data['fir'] = $q[0];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2292
                 | 
                                    
                                                     | 
                
                 | 
                				$data['code'] = $q[1];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2293
                 | 
                                    
                                                     | 
                
                 | 
                				$ifrvfr = $q[2];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2294
                 | 
                                    
                                                     | 
                
                 | 
                				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2295
                 | 
                                    
                                                     | 
                
                 | 
                				if ($ifrvfr == 'I') $data['rules'] = 'IFR';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2296
                 | 
                                    
                                                     | 
                
                 | 
                				if ($ifrvfr == 'V') $data['rules'] = 'VFR';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2297
                 | 
                                    
                                                     | 
                
                 | 
                				if ($q[4] == 'A') $data['scope'] = 'Airport warning';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2298
                 | 
                                    
                                                     | 
                
                 | 
                				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2299
                 | 
                                    
                                                     | 
                
                 | 
                				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2300
                 | 
                                    
                                                     | 
                
                 | 
                				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2301
                 | 
                                    
                                                     | 
                
                 | 
                				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2302
                 | 
                                    
                                                     | 
                
                 | 
                				//$data['scope'] = $q[4];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2303
                 | 
                                    
                                                     | 
                
                 | 
                				$data['lower_limit'] = $q[5];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2304
                 | 
                                    
                                                     | 
                
                 | 
                				$data['upper_limit'] = $q[6];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2305
                 | 
                                    
                                                     | 
                
                 | 
                				$latlonrad = $q[7];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2306
                 | 
                                    
                                                     | 
                
                 | 
                				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);  | 
            
                            
                    | 
                        
                     | 
                     | 
                     | 
                    
                                                                                                                                                                                                                                                                
                        
                         
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     
                     | 
                
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2307
                 | 
                                    
                                                     | 
                
                 | 
                				$latitude = $Common->convertDec($las,'latitude');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2308
                 | 
                                    
                                                     | 
                
                 | 
                				$longitude = $Common->convertDec($lns,'longitude');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2309
                 | 
                                    
                                                     | 
                
                 | 
                				if ($lac == 'S') $latitude = '-'.$latitude;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2310
                 | 
                                    
                                                     | 
                
                 | 
                				if ($lnc == 'W') $longitude = '-'.$longitude;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2311
                 | 
                                    
                                                     | 
                
                 | 
                				$data['center_latitude'] = $latitude;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2312
                 | 
                                    
                                                     | 
                
                 | 
                				$data['center_longitude'] = $longitude;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2313
                 | 
                                    
                                                     | 
                
                 | 
                				$data['radius'] = intval($radius);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2314
                 | 
                                    
                                                     | 
                
                 | 
                				  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2315
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match(':<pre>(.*?)</pre>:',$description,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2316
                 | 
                                    
                                                     | 
                
                 | 
                				$data['text'] = $match[1];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2317
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match(':</pre>(.*?)$:',$description,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2318
                 | 
                                    
                                                     | 
                
                 | 
                				$fromto = $match[1];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2319
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match('#FROM:(.*?)TO:#',$fromto,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2320
                 | 
                                    
                                                     | 
                
                 | 
                				$fromall = trim($match[1]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2321
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2322
                 | 
                                    
                                                     | 
                
                 | 
                				$from = trim($match[1]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2323
                 | 
                                    
                                                     | 
                
                 | 
                				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2324
                 | 
                                    
                                                     | 
                
                 | 
                				preg_match('#TO:(.*?)$#',$fromto,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2325
                 | 
                                    
                                                     | 
                
                 | 
                				$toall = trim($match[1]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2326
                 | 
                                    
                                                     | 
                
                 | 
                				if (!preg_match(':Permanent:',$toall)) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2327
                 | 
                                    
                                                     | 
                
                 | 
                					preg_match('#^(.*?) \((.*?)\)#',$toall,$match); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2328
                 | 
                                    
                                                     | 
                
                 | 
                					$to = trim($match[1]);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2329
                 | 
                                    
                                                     | 
                
                 | 
                					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2330
                 | 
                                    
                                                     | 
                
                 | 
                					$data['permanent'] = 0;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2331
                 | 
                                    
                                                     | 
                
                 | 
                				} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2332
                 | 
                                    
                                                     | 
                
                 | 
                				    $data['date_end'] = NULL;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2333
                 | 
                                    
                                                     | 
                
                 | 
                				    $data['permanent'] = 1;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2334
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2335
                 | 
                                    
                                                     | 
                
                 | 
                				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2336
                 | 
                                    
                                                     | 
                
                 | 
                				$NOTAM = new NOTAM();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2337
                 | 
                                    
                                                     | 
                
                 | 
                				$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']);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2338
                 | 
                                    
                                                     | 
                
                 | 
                				unset($data);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2339
                 | 
                                    
                                                     | 
                
                 | 
                			}   | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2340
                 | 
                                    
                                                     | 
                
                 | 
                		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2341
                 | 
                                    
                                                     | 
                
                 | 
                		if ($error != '') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2342
                 | 
                                    
                                                     | 
                
                 | 
                			return $error;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2343
                 | 
                                    
                                                     | 
                
                 | 
                		} elseif ($globalDebug) echo "Done\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2344
                 | 
                                    
                                                     | 
                
                 | 
                		return '';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2345
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2346
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2347
                 | 
                                    
                                                     | 
                
                 | 
                	public static function create_airspace() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2348
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver, $globalDebug, $tmp_dir, $globalDBhost, $globalDBuser, $globalDBname, $globalDBpass, $globalDBport;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2349
                 | 
                                    
                                                     | 
                
                 | 
                		$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2350
                 | 
                                    
                                                     | 
                
                 | 
                		if ($Connection->tableExists('airspace')) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2351
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2352
                 | 
                                    
                                                     | 
                
                 | 
                				$query = 'DROP TABLE geometry_columns; DROP TABLE spatial_ref_sys;DROP TABLE airspace;';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2353
                 | 
                                    
                                                     | 
                
                 | 
                			} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2354
                 | 
                                    
                                                     | 
                
                 | 
                				$query = 'DROP TABLE airspace';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2355
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2356
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2357
                 | 
                                    
                                                     | 
                
                 | 
                				$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2358
                 | 
                                    
                                                     | 
                
                 | 
                				$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2359
                 | 
                                    
                                                     | 
                
                 | 
                				$sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2360
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2361
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2362
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2363
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2364
                 | 
                                    
                                                     | 
                
                 | 
                		$Common = new Common();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2365
                 | 
                                    
                                                     | 
                
                 | 
                		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2366
                 | 
                                    
                                                     | 
                
                 | 
                		$airspace_json = json_decode($airspace_lst,true);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2367
                 | 
                                    
                                                     | 
                
                 | 
                		foreach ($airspace_json['records'] as $airspace) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2368
                 | 
                                    
                                                     | 
                
                 | 
                			if ($globalDebug) echo $airspace['name']."...\n";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2369
                 | 
                                    
                                                     | 
                
                 | 
                			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2370
                 | 
                                    
                                                     | 
                
                 | 
                			if (file_exists($tmp_dir.$airspace['name'])) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2371
                 | 
                                    
                                                     | 
                
                 | 
                				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2372
                 | 
                                    
                                                     | 
                
                 | 
                				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2373
                 | 
                                    
                                                     | 
                
                 | 
                				if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2374
                 | 
                                    
                                                     | 
                
                 | 
                					system('ogr2ogr -update -append -f "MySQL" MySQL:"'.$globalDBname.',host='.$globalDBhost.',user='.$globalDBuser.',password='.$globalDBpass.',port='.$globalDBport.'" -nln airspace -nlt POLYGON -skipfailures -lco ENGINE=MyISAM "'.$tmp_dir.$airspace['name'].'"'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2375
                 | 
                                    
                                                     | 
                
                 | 
                				} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2376
                 | 
                                    
                                                     | 
                
                 | 
                					system('ogr2ogr -append -f "PostgreSQL" PG:"host='.$globalDBhost.' user='.$globalDBuser.' dbname='.$globalDBname.' password='.$globalDBpass.' port='.$globalDBport.'" -nln airspace -nlt POLYGON -skipfailures "'.$tmp_dir.$airspace['name'].'"'); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2377
                 | 
                                    
                                                     | 
                
                 | 
                				}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2378
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2379
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2380
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2381
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2382
                 | 
                                    
                                                     | 
                
                 | 
                	public static function fix_icaotype() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2383
                 | 
                                    
                                                     | 
                
                 | 
                		require_once(dirname(__FILE__).'/../require/class.Spotter.php');  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2384
                 | 
                                    
                                                     | 
                
                 | 
                		$Spotter = new Spotter();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2385
                 | 
                                    
                                                     | 
                
                 | 
                		foreach ($Spotter->aircraft_correct_icaotype as $old => $new) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2386
                 | 
                                    
                                                     | 
                
                 | 
                			$query = 'UPDATE aircraft_modes SET ICAOTypeCode = :new WHERE ICAOTypeCode = :old';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2387
                 | 
                                    
                                                     | 
                
                 | 
                			try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2388
                 | 
                                    
                                                     | 
                
                 | 
                				$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2389
                 | 
                                    
                                                     | 
                
                 | 
                				$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2390
                 | 
                                    
                                                     | 
                
                 | 
                				$sth->execute(array(':new' => $new, ':old' => $old)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2391
                 | 
                                    
                                                     | 
                
                 | 
                			} catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2392
                 | 
                                    
                                                     | 
                
                 | 
                				return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2393
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2394
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2395
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2396
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2397
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2398
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2399
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2400
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2401
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2402
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2403
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2404
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2405
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2406
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2407
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2408
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2409
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2410
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2411
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2412
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2413
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2414
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2415
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2416
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2417
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_db';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2418
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_db',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2419
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2420
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2421
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2422
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2423
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2424
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2425
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2426
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2427
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2428
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_airspace_version($version) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2429
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'airspace_version' AND value = :version";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2430
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2431
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2432
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2433
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':version' => $version)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2434
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2435
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2436
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2437
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2438
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2439
                 | 
                                    
                                                     | 
                
                 | 
                                else return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2440
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2441
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2442
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_marine_identity_version($version) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2443
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'marine_identity_version' AND value = :version";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2444
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2445
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2446
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2447
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':version' => $version)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2448
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2449
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2450
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2451
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2452
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2453
                 | 
                                    
                                                     | 
                
                 | 
                                else return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2454
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2455
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2456
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2457
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_airspace_version($version) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2458
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'airspace_version';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2459
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('airspace_version',:version);"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2460
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2461
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2462
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2463
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':version' => $version)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2464
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2465
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2466
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2467
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2468
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2469
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_marine_identity_version($version) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2470
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'marine_identity_version';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2471
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('marine_identity_version',:version);"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2472
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2473
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2474
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2475
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute(array(':version' => $version)); | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2476
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2477
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2478
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2479
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2480
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2481
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_notam_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2482
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2483
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2484
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2485
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2486
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '1 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2487
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2488
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2489
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2490
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2491
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2492
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2493
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2494
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2495
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2496
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2497
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2498
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2499
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2500
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_notam_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2501
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_notam_db';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2502
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2503
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2504
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2505
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2506
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2507
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2508
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2509
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2510
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2511
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_airspace_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2512
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2513
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2514
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_airspace_db' AND value > DATE_SUB(NOW(), INTERVAL 7 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2515
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2516
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_airspace_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '7 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2517
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2518
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2519
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2520
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2521
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2522
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2523
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2524
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2525
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2526
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2527
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2528
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2529
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2530
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_airspace_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2531
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_airspace_db';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2532
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_airspace_db',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2533
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2534
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2535
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2536
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2537
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2538
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2539
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2540
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2541
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2542
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_owner_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2543
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2544
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2545
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2546
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2547
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2548
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2549
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2550
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2551
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2552
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2553
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2554
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2555
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2556
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2557
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2558
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2559
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2560
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2561
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_owner_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2562
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_owner_db';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2563
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_owner_db',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2564
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2565
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2566
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2567
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2568
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2569
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2570
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2571
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2572
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_schedules_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2573
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2574
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2575
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_schedules' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2576
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2577
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_schedules' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2578
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2579
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2580
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2581
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2582
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2583
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2584
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2585
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2586
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2587
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2588
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2589
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2590
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2591
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_schedules_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2592
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_schedules';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2593
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_schedules',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2594
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2595
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2596
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2597
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2598
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2599
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2600
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2601
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2602
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_tle_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2603
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2604
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2605
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_tle' AND value > DATE_SUB(NOW(), INTERVAL 7 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2606
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2607
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_tle' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '7 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2608
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2609
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2610
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2611
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2612
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2613
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2614
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2615
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2616
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2617
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2618
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2619
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2620
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2621
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_tle_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2622
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_tle';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2623
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_tle',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2624
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2625
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2626
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2627
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2628
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2629
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2630
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2631
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2632
                 | 
                                    
                                                     | 
                
                 | 
                	public static function check_last_marine_identity_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2633
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2634
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2635
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_marine_identity' AND value > DATE_SUB(NOW(), INTERVAL 7 DAY)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2636
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2637
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_marine_identity' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '7 DAYS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2638
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2639
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2640
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2641
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2642
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2643
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2644
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2645
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2646
                 | 
                                    
                                                     | 
                
                 | 
                                $row = $sth->fetch(PDO::FETCH_ASSOC);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2647
                 | 
                                    
                                                     | 
                
                 | 
                                if ($row['nb'] > 0) return false;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2648
                 | 
                                    
                                                     | 
                
                 | 
                                else return true;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2649
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2650
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2651
                 | 
                                    
                                                     | 
                
                 | 
                	public static function insert_last_marine_identity_update() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2652
                 | 
                                    
                                                     | 
                
                 | 
                		$query = "DELETE FROM config WHERE name = 'last_update_marine_identity';  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2653
                 | 
                                    
                                                     | 
                
                 | 
                			INSERT INTO config (name,value) VALUES ('last_update_marine_identity',NOW());"; | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2654
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2655
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2656
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2657
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2658
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2659
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2660
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2661
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2662
                 | 
                                    
                                                     | 
                
                 | 
                	public static function delete_duplicatemodes() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2663
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2664
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2665
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "DELETE a FROM aircraft_modes a, aircraft_modes b WHERE a.ModeS = b.ModeS AND a.FirstCreated < b.FirstCreated AND a.Source != 'ACARS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2666
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2667
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "DELETE FROM aircraft_modes WHERE AircraftID IN (SELECT AircraftID FROM (SELECT AircraftID, ROW_NUMBER() OVER (partition BY ModeS ORDER BY FirstCreated) AS rnum FROM aircraft_modes) t WHERE t.rnum > 1) AND Source != 'ACARS'";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2668
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2669
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2670
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2671
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2672
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2673
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2674
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2675
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2676
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2677
                 | 
                                    
                                                     | 
                
                 | 
                	public static function delete_duplicateowner() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2678
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalDBdriver;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2679
                 | 
                                    
                                                     | 
                
                 | 
                		if ($globalDBdriver == 'mysql') { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2680
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "DELETE a FROM aircraft_owner a, aircraft_owner b WHERE a.registration = b.registration AND a.owner_id < b.owner_id";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2681
                 | 
                                    
                                                     | 
                
                 | 
                		} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2682
                 | 
                                    
                                                     | 
                
                 | 
                			$query = "DELETE FROM aircraft_owner WHERE owner_id IN (SELECT owner_id FROM (SELECT owner_id, ROW_NUMBER() OVER (partition BY registration ORDER BY owner_id) AS rnum FROM aircraft_owner) t WHERE t.rnum > 1)";  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2683
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2684
                 | 
                                    
                                                     | 
                
                 | 
                		try { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2685
                 | 
                                    
                                                     | 
                
                 | 
                			$Connection = new Connection();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2686
                 | 
                                    
                                                     | 
                
                 | 
                			$sth = $Connection->db->prepare($query);  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2687
                 | 
                                    
                                                     | 
                
                 | 
                                        $sth->execute();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2688
                 | 
                                    
                                                     | 
                
                 | 
                                } catch(PDOException $e) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2689
                 | 
                                    
                                                     | 
                
                 | 
                                        return "error : ".$e->getMessage();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2690
                 | 
                                    
                                                     | 
                
                 | 
                                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2691
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2692
                 | 
                                    
                                                     | 
                
                 | 
                	  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2693
                 | 
                                    
                                                     | 
                
                 | 
                	public static function update_all() { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2694
                 | 
                                    
                                                     | 
                
                 | 
                		global $globalMasterServer, $globalMasterSource;  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2695
                 | 
                                    
                                                     | 
                
                 | 
                		if (!isset($globalMasterServer) || !$globalMasterServer) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2696
                 | 
                                    
                                                     | 
                
                 | 
                			if (isset($globalMasterSource) && $globalMasterSource) { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2697
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_routes();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2698
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_translation();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2699
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_notam_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2700
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_ModeS();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2701
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_ModeS_flarm();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2702
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_ModeS_ogn();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2703
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_ModeS_faa();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2704
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::fix_icaotype();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2705
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_banned_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2706
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::delete_duplicatemodes();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2707
                 | 
                                    
                                                     | 
                
                 | 
                			} else { | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2708
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_routes();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2709
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_routes_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2710
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_translation();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2711
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_translation_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2712
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_notam_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2713
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_ModeS();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2714
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_ModeS_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2715
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::update_ModeS_flarm();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2716
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_ModeS_ogn();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2717
                 | 
                                    
                                                     | 
                
                 | 
                				//echo update_db::delete_duplicatemodes();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2718
                 | 
                                    
                                                     | 
                
                 | 
                				echo update_db::update_banned_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2719
                 | 
                                    
                                                     | 
                
                 | 
                			}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2720
                 | 
                                    
                                                     | 
                
                 | 
                		}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2721
                 | 
                                    
                                                     | 
                
                 | 
                	}  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2722
                 | 
                                    
                                                     | 
                
                 | 
                }  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2723
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2724
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_airports();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2725
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::translation();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2726
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_waypoints();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2727
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_airspace();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2728
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_notam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2729
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ivao();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2730
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ModeS_flarm();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2731
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ModeS_ogn();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2732
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_aircraft();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2733
                 | 
                                    
                                                     | 
                
                 | 
                //$update_db = new update_db();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2734
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_owner();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2735
                 | 
                                    
                                                     | 
                
                 | 
                //update_db::update_translation_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2736
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_routes();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2737
                 | 
                                    
                                                     | 
                
                 | 
                //update_db::update_models();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2738
                 | 
                                    
                                                     | 
                
                 | 
                //echo $update_db::update_skyteam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2739
                 | 
                                    
                                                     | 
                
                 | 
                //echo $update_db::update_tle();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2740
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_notam_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2741
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::create_airspace();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2742
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ModeS();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2743
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ModeS_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2744
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_routes_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2745
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_ModeS_faa();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2746
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_banned_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2747
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::modes_faa();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2748
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::update_owner_fam();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2749
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::delete_duplicateowner();  | 
            
            
                                                                                                            
                            
            
                                    
            
            
                | 
                    2750
                 | 
                                    
                                                     | 
                
                 | 
                //echo update_db::fix_icaotype();  | 
            
            
                                                                                                            
                                                                
            
                                    
            
            
                | 
                    2751
                 | 
                                    
                                                     | 
                
                 | 
                ?>  | 
            
            
                                                        
            
                                    
            
            
                | 
                    2752
                 | 
                                    
                                                     | 
                
                 | 
                 | 
            
            
                        
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.