| 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) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 		//$query = 'TRUNCATE TABLE aircraft_modes'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR 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 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		if ($fh = fopen($database_file,"r")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 			$sth_dest = $Connection->db->prepare($query_dest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 				if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 				$tmp = fgetcsv($fh,9999,',','"'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |             			while (!feof($fh)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |             				$line = fgetcsv($fh,9999,',','"'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |             				$values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |             				//print_r($line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |             				if ($country == 'F') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |             				    $values['base'] = $line[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |             				    $values['owner'] = $line[5]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |             				    if ($line[6] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 					    $values['cancel'] = $line[7]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 					} elseif ($country == 'EI') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 					    // TODO : add modeS & reg to aircraft_modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             				    $values['base'] = $line[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |             				    $values['owner'] = $line[2]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |             				    if ($line[1] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 					} elseif ($country == 'HB') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 					    // TODO : add modeS & reg to aircraft_modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |             				    $values['owner'] = $line[5]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |             				    $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 					} elseif ($country == 'OK') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 					    // TODO : add modeS & reg to aircraft_modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             				    $values['registration'] = $line[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             				    $values['owner'] = $line[5]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |             				    if ($line[18] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 					} elseif ($country == 'VH') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 					    // TODO : add modeS & reg to aircraft_modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |             				    $values['owner'] = $line[12]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |             				    if ($line[28] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 					    $values['cancel'] = $line[39]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             				    $values['owner'] = $line[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             				    $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 					} elseif ($country == 'CC') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |             				    $values['owner'] = $line[6]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |             				    $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 					} elseif ($country == 'HJ') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |             				    $values['owner'] = $line[8]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |             				    if ($line[7] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 					} elseif ($country == 'PP') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             				    $values['owner'] = $line[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |             				    if ($line[6] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 					    $values['cancel'] = $line[7]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 					} elseif ($country == 'E7') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |             				    $values['owner'] = $line[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |             				    if ($line[5] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 					} elseif ($country == '8Q') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |             				    $values['owner'] = $line[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |             				    if ($line[7] == '') $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |             				    $values['registration'] = $line[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |             				    $values['base'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |             				    $values['owner'] = $line[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |             				    $values['date_first_reg'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 					    $values['cancel'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 					if ($values['cancel'] == '' && $values['registration'] != null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 						$sth_dest->execute($query_dest_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 				if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 			} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	* This function is used to create a list of airports. Sources : Wikipedia, ourairports.com ans partow.net | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 	public static function update_airports() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		global $tmp_dir, $globalTransaction, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 		require_once(dirname(__FILE__).'/libs/sparqllib.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 		$db = sparql_connect('http://dbpedia.org/sparql'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 		$query = ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 		    PREFIX dbo: <http://dbpedia.org/ontology/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 		    PREFIX dbp: <http://dbpedia.org/property/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 		    PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 		    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 		    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		    SELECT ?name ?icao ?iata ?faa ?lid ?latitude ?longitude ?airport ?homepage ?type ?country ?country_bis ?altitude ?image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		    FROM <http://dbpedia.org> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		    WHERE { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 			?airport rdf:type <http://dbpedia.org/ontology/Airport> . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 			    ?airport dbo:icaoLocationIdentifier ?icao . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 			    FILTER regex(?icao, "^[A-Z0-9]{4}$") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 			    ?airport dbo:iataLocationIdentifier ?iata . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 			    FILTER regex(?iata, "^[A-Z0-9]{3}$") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			    ?airport dbo:locationIdentifier ?lid . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 			    FILTER regex(?lid, "^[A-Z0-9]{4}$") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			    FILTER (!bound(?icao) || (bound(?icao) && (?icao != ?lid))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 			    OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 				?airport_y rdf:type <http://dbpedia.org/ontology/Airport> . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 				?airport_y dbo:icaoLocationIdentifier ?other_icao . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 				FILTER (bound(?lid) && (?airport_y != ?airport && ?lid = ?other_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			    FILTER (!bound(?other_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 			    ?airport dbo:faaLocationIdentifier ?faa . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 			    FILTER regex(?faa, "^[A-Z0-9]{3}$") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			    FILTER (!bound(?iata) || (bound(?iata) && (?iata != ?faa))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 			    OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 				?airport_x rdf:type <http://dbpedia.org/ontology/Airport> . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 				?airport_x dbo:iataLocationIdentifier ?other_iata . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 				FILTER (bound(?faa) && (?airport_x != ?airport && ?faa = ?other_iata)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 			    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			    FILTER (!bound(?other_iata)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 			FILTER (bound(?icao) || bound(?iata) || bound(?faa) || bound(?lid)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			    ?airport rdfs:label ?name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 			    FILTER (lang(?name) = "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			    ?airport foaf:homepage ?homepage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 		     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 			    ?airport dbp:coordinatesRegion ?country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			    ?airport dbp:type ?type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 			    ?airport dbo:elevation ?altitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 			OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 			    ?airport dbp:image ?image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 			    ?airport geo:lat ?latitude . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 			    ?airport geo:long ?longitude . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 			    FILTER (datatype(?latitude) = xsd:float) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 			    FILTER (datatype(?longitude) = xsd:float) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 			} UNION { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 			    ?airport geo:lat ?latitude . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 			    ?airport geo:long ?longitude . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 			    FILTER (datatype(?latitude) = xsd:double) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 			    FILTER (datatype(?longitude) = xsd:double) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 			    OPTIONAL { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 				?airport geo:lat ?lat_f . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 				?airport geo:long ?long_f . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 				FILTER (datatype(?lat_f) = xsd:float) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 				FILTER (datatype(?long_f) = xsd:float) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 			    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 			    FILTER (!bound(?lat_f) && !bound(?long_f)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 		    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 		    ORDER BY ?airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 		$result = sparql_query($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 		$query = 'TRUNCATE TABLE airport'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		$query = 'ALTER TABLE airport DROP INDEX icaoidx'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 		$sth_dest = $Connection->db->prepare($query_dest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 		if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 		$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 		while($row = sparql_fetch_array($result)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 			if ($i >= 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 			//print_r($row); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 			if (!isset($row['iata'])) $row['iata'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 			if (!isset($row['icao'])) $row['icao'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 			if (!isset($row['type'])) $row['type'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 			if (!isset($row['altitude'])) $row['altitude'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 			if (isset($row['city_bis'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 				$row['city'] = $row['city_bis']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 			if (!isset($row['city'])) $row['city'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 			if (!isset($row['country'])) $row['country'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 			if (!isset($row['homepage'])) $row['homepage'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 			if (!isset($row['name'])) continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 			if (!isset($row['image'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 				$row['image'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 				$row['image_thumb'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 				$image = str_replace(' ','_',$row['image']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 				$digest = md5($image); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 			$country = explode('-',$row['country']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 			$row['country'] = $country[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 			$row['type'] = trim($row['type']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 				$row['type'] = 'Military'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 				$row['type'] = 'small_airport'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 			//print_r($query_dest_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 				$sth_dest->execute($query_dest_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 			} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 			$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 		echo "Delete duplicate rows...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 		if ($globalDebug) echo "Insert Not available Airport...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |                         $sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 		$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 		echo "Download data from ourairports.com...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 		$delimiter = ','; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 		$out_file = $tmp_dir.'airports.csv'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 		update_db::download('http://ourairports.com/data/airports.csv',$out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 		echo "Add data from ourairports.com...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 		$header = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 		if (($handle = fopen($out_file, 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 				if(!$header) $header = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 				else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 					$data = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 					$data = array_combine($header, $row); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 						$sth->execute(array(':icao' => $data['gps_code'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 					if ($sth->fetchColumn() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 							$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 							return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  | 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 							$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 							$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 							return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 						$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 			//$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 		echo "Download data from another free database...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  | 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  | 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  | 		update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 		$header = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 		echo "Add data from another free database...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 		$delimiter = ':'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  | 		if (($handle = fopen($tmp_dir.'GlobalAirportDatabase.txt', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 				if(!$header) $header = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 				else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 					$data = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 			//$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 		echo "Put type military for all air base"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  | 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 			$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  | 		} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  | 			return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  | 				$sth2 = $Connection->db->prepare($query2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  | 				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  | 			} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |                 return "success"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | 	public static function translation() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 		require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 		$Spotter = new Spotter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 		//$out_file = $tmp_dir.'translation.zip'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 		//update_db::download('http://www.acarsd.org/download/translation.php',$out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 		//if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 		//$query = 'TRUNCATE TABLE translation'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 		$query = "DELETE FROM translation WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |                         $sth->execute(array(':source' => 'translation.csv')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 		//update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 		$header = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 		$delimiter = ';'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  | 		if (($handle = fopen($tmp_dir.'translation.csv', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 				if($i > 12) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 					$data = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 					$operator = $data[2]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |                                                 //echo substr($operator, 0, 2)."\n";; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |                                                 if (count($airline_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  | 							//print_r($airline_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 							$operator = $airline_array[0]['icao'].substr($operator,2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |                                                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |                                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 					$operator_correct = $data[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |                                                 if (count($airline_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |                                             		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |                                             	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |                                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 			//$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 	public static function translation_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 		require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 		$Spotter = new Spotter(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 		$query = "DELETE FROM translation WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |                         $sth->execute(array(':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  | 		//update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | 		$header = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  | 		$delimiter = "\t"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  | 		if (($handle = fopen($tmp_dir.'translation.tsv', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 				if ($i > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  | 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  | 			//$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 	* This function use FAA public data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  | 	* With the help of data from other source, Mfr id is added to manufacturer table. Then ModeS with ICAO are added based on that. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  | 	public static function modes_faa() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 		global $tmp_dir, $globalTransaction, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  | 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |                         $sth->execute(array(':source' => 'website_faa')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  | 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |                         $sth->execute(array(':source' => 'website_faa')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | 		$delimiter = ","; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  | 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 				if ($i > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  | 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  | 						$sths = $Connection->db->prepare($query_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 						return "error s : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 					if (!empty($result_search)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 						if ($globalDebug) echo '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  | 						$queryi = 'UPDATE aircraft SET mfr = :mfr WHERE icao = :icao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  | 							$sthi = $Connection->db->prepare($queryi); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  | 							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 							return "error u : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  | 						$query_search_mfr = 'SELECT icao FROM aircraft WHERE mfr = :mfr'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 							$sthsm = $Connection->db->prepare($query_search_mfr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  | 							$sthsm->execute(array(':mfr' => $data[2])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 							return "error mfr : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  | 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 						if (!empty($result_search_mfr)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  | 							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  | 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 							try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 								$sthf = $Connection->db->prepare($queryf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  | 								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  | 							} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  | 								return "error f : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  | 					if (strtotime($data[29]) > time()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 						if ($globalDebug) echo 'i'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  | 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  | 							$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  | 							return "error i : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 				if ($i % 90 == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  | 					if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  | 					if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  | 	public static function modes_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  | 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  |                         $sth->execute(array(':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  | 		//update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  | 		$delimiter = "\t"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  | 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  | 				if ($i > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  | 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  | 	public static function owner_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  | 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |                         $sth->execute(array(':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  | 		$delimiter = "\t"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  | 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  | 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  | 				if ($i > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  | 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  | 						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  | 						print_r($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  | 	public static function routes_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  | 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  |                         $sth->execute(array(':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  | 		//update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  | 		$delimiter = "\t"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  | 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  | 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  | 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  | 				if ($i > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  | 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  | 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 	public static function tle($filename,$tletype) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  | 		require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 		//$Spotter = new Spotter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 		$query = "DELETE FROM tle WHERE tle_source = '' OR tle_source = :source"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  |                         $sth->execute(array(':source' => $filename)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  | 		if (($handle = fopen($filename, 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 			//$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  | 			$dbdata = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 			while (($data = fgets($handle, 1000)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 				if ($i == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 					$dbdata['name'] = trim($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  | 					$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  | 				} elseif ($i == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  | 					$dbdata['tle1'] = trim($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 					$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  | 				} elseif ($i == 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 					$dbdata['tle2'] = trim($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 					//print_r($dbdata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  | 					$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  | 			//$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  |         * Convert a HTML table to an array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  |         * @param String $data HTML page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  |         * @return Array array of the tables in HTML page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  |         private static function table2array($data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  |                 $html = str_get_html($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  |                 $tabledata=array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  |                 foreach($html->find('tr') as $element) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  |                 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  |                         $td = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  |                         foreach( $element->find('th') as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  |                         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  |                                 $td [] = trim($row->plaintext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  |                         $td=array_filter($td); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  |                         $tabledata[] = $td; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  |                         $td = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  |                         $tdi = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  |                         foreach( $element->find('td') as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  |                         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  |                                 $td [] = trim($row->plaintext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  |                                 $tdi [] = trim($row->innertext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |                         $td=array_filter($td); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  |                         $tdi=array_filter($tdi); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  |                     //    $tabledata[]=array_merge($td,$tdi); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  |                         $tabledata[]=$td; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  |                 return(array_filter($tabledata)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  |        /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  |         * Get data from form result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  |         * @param String $url form URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  |         * @return String the result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  |         private static function getData($url) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  |                 $ch = curl_init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  |                 curl_setopt($ch, CURLOPT_URL, $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  |                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  |                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  |                 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'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  |                 return curl_exec($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  | 	public static function waypoints() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  | 		$table = update_db::table2array($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  | //		print_r($table); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  | 		$query = 'TRUNCATE TABLE waypoints'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  | 		$query_dest = 'INSERT INTO waypoints (`ident`,`latitude`,`longitude`,`control`,`usage`) VALUES (:ident, :latitude, :longitude, :control, :usage)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  | 		$sth_dest = $Connection->db->prepare($query_dest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  | 		$Connection->db->beginTransaction(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  |                 foreach ($table as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  |             		if ($row[0] != 'Ident') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  | 				$ident = $row[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 				$latitude = $row[2]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  | 				$longitude = $row[3]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  | 				$control = $row[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  | 				if (isset($row[5])) $usage = $row[5]; else $usage = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 				$query_dest_values = array(':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':control' => $control,':usage' => $usage); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 				try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  | 					$sth_dest->execute($query_dest_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  | 				} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  | 					return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  | 		$Connection->db->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 	public static function waypoints($filename) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  | 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 		//$Spotter = new Spotter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 		//$out_file = $tmp_dir.'translation.zip'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 		//update_db::download('http://www.acarsd.org/download/translation.php',$out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 		//if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 		//update_db::unzip($out_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  | 		$header = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  | 		$delimiter = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  | 		if (($handle = fopen($filename, 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 			$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  | 				if($i > 3 && count($row) > 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  | 					$data = array_values(array_filter($row)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  | 					$cntdata = count($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 					if ($cntdata > 10) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  | 						$value = $data[9]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 						for ($i =10;$i < $cntdata;$i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 							$value .= ' '.$data[$i]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 						$data[9] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 					//print_r($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  | 					if (count($data) > 9) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  | 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 							$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  | 							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  | 						} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  | 							return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  | 	public static function ivao_airlines($filename) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  | 		global $tmp_dir, $globalTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 		//$query = 'TRUNCATE TABLE airlines'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 		$query = "DELETE FROM airlines WHERE forsource = 'ivao'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 		$header = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 		$delimiter = ':'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 		if (($handle = fopen($filename, 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  | 			if ($globalTransaction) $Connection->db->beginTransaction(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 				if(count($row) > 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 					try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  | 						$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  | 						$sth->execute(array(':name' => $row[1],':icao' => $row[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 					} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  | 						return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  | 			if ($globalTransaction) $Connection->db->commit(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  | 	public static function update_airspace() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 		global $tmp_dir, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  | 		include_once('class.create_db.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 		if ($Connection->tableExists('airspace')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  | 			$query = 'DROP TABLE airspace'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  | 				$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  |                     		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 	                } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  | 	                } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 	        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  | 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  | 			$query = "CREATE EXTENSION postgis"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 				$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  | 				$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 			} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 		$error = create_db::import_file($tmp_dir.'airspace.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 		return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 	public static function update_notam_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  | 		include_once('class.create_db.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  | 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 		if (file_exists($tmp_dir.'notam.txt.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  | 			update_db::gunzip($tmp_dir.'notam.txt.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  | 			//$error = create_db::import_file($tmp_dir.'notam.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 			$NOTAM = new NOTAM(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  | 	public static function update_vatsim() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 		global $tmp_dir; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  | 		include_once('class.create_db.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  | 		$error = create_db::import_file('../db/vatsim/airlines.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  | 		return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  | 	public static function update_countries() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  | 		global $tmp_dir, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 		include_once('class.create_db.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 		if ($Connection->tableExists('countries')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  | 			$query = 'DROP TABLE countries'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 				$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  |             	        	$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  | 	                } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  |     	                	echo "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  | 	                } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  | 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  | 			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 		$error = create_db::import_file($tmp_dir.'countries.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  | 		return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  | 	public static function update_waypoints() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 		global $tmp_dir; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | //		update_db::download('http://dev.x-plane.com/update/data/AptNav201310XP1000.zip',$tmp_dir.'AptNav.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  | //		update_db::unzip($tmp_dir.'AptNav.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  | //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  | 		update_db::gunzip($tmp_dir.'awy.dat.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 		$error = update_db::waypoints($tmp_dir.'awy.dat'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  | 		return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  | 	public static function update_ivao() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 		$Common = new Common(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 		//Direct download forbidden | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  | 		//if ($globalDebug) echo "IVAO : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  | 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  | 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 			if ($globalDebug) echo "Unzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  | 			update_db::unzip($tmp_dir.'ivae_feb2013.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  | 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 			if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  | 			if (is_writable(dirname(__FILE__).'/../images/airlines')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  | 				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  | 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  | 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  | 	public static function update_routes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  | 		$error = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  | 		if ($globalDebug) echo "Routes : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  | 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  | 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  | 		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  | 	public static function update_oneworld() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  | 		$error = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  | 		if ($globalDebug) echo "Schedules Oneworld : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  | 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  | 		if (file_exists($tmp_dir.'oneworld.csv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  | 			update_db::gunzip($tmp_dir.'oneworld.csv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  | 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  | 		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  | 	public static function update_skyteam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  | 		$error = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  | 		if ($globalDebug) echo "Schedules Skyteam : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  | 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  | 		if (file_exists($tmp_dir.'skyteam.csv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  | 			update_db::gunzip($tmp_dir.'skyteam.csv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  | 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  | 	public static function update_ModeS() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  | 		if ($globalDebug) echo "Modes : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 		update_db::download('http://pp-sqb.mantma.co.uk/basestation_latest.zip',$tmp_dir.'basestation_latest.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 		if ($globalDebug) echo "Unzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  | 		update_db::unzip($tmp_dir.'basestation_latest.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 		if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 		$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'/basestation_latest/basestation.sqb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  | 		if ($error != true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  | 			echo $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  | 		if ($globalDebug) echo "Modes : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  | //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  | 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  | //		if (file_exists($tmp_dir.'basestation_latest.zip')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  | 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  | 			if ($globalDebug) echo "Unzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  | //			update_db::unzip($tmp_dir.'basestation_latest.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  | 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  | 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  | //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  | 		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  | 	public static function update_ModeS_faa() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  | 		if ($globalDebug) echo "Modes FAA: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  | 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  | 			if ($globalDebug) echo "Unzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  | 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  | 			$error = update_db::modes_faa(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  | 		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  | 	public static function update_ModeS_flarm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  | 		if ($globalDebug) echo "Modes Flarmnet: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  | 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  | 		if (file_exists($tmp_dir.'data.fln')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  | 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 	public static function update_ModeS_ogn() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  | 		if ($globalDebug) echo "Modes OGN: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  | 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  | 		if (file_exists($tmp_dir.'ogn.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  | 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  | 		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  | 	public static function update_owner() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  | 		if ($globalDebug) echo "Owner France: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1620 |  |  | 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  | 		if (file_exists($tmp_dir.'owner_f.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  | 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  | 		if ($globalDebug) echo "Owner Ireland: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  | 		if (file_exists($tmp_dir.'owner_ei.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  | 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  | 		if ($globalDebug) echo "Owner Switzerland: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  | 		if (file_exists($tmp_dir.'owner_hb.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  | 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  | 		if ($globalDebug) echo "Owner Czech Republic: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  | 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  | 		if (file_exists($tmp_dir.'owner_ok.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  | 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  | 		if ($globalDebug) echo "Owner Australia: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  | 		if (file_exists($tmp_dir.'owner_vh.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  | 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1665 |  |  | 		if ($globalDebug) echo "Owner Austria: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1666 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1667 |  |  | 		if (file_exists($tmp_dir.'owner_oe.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1668 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1669 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1670 |  |  | 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1671 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1672 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1673 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1674 |  |  | 		if ($globalDebug) echo "Owner Chile: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1675 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1676 |  |  | 		if (file_exists($tmp_dir.'owner_cc.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1677 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1678 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1679 |  |  | 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1680 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1681 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1682 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1683 |  |  | 		if ($globalDebug) echo "Owner Colombia: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1684 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1685 |  |  | 		if (file_exists($tmp_dir.'owner_hj.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1686 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1687 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1688 |  |  | 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1689 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1690 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1691 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1692 |  |  | 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1693 |  |  | 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1694 |  |  | 		if (file_exists($tmp_dir.'owner_e7.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1695 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1696 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1697 |  |  | 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1698 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1699 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1700 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1701 |  |  | 		if ($globalDebug) echo "Owner Brazil: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1702 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1703 |  |  | 		if (file_exists($tmp_dir.'owner_pp.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1704 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1705 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1706 |  |  | 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1707 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1708 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1709 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1710 |  |  | 		if ($globalDebug) echo "Owner Cayman Islands: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1711 |  |  | 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1712 |  |  | 		if (file_exists($tmp_dir.'owner_vp.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1713 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1714 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1715 |  |  | 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1716 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1717 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1718 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1719 |  |  | 		if ($globalDebug) echo "Owner Croatia: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1720 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1721 |  |  | 		if (file_exists($tmp_dir.'owner_9a.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1722 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1723 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1724 |  |  | 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1725 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1726 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1727 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1728 |  |  | 		if ($globalDebug) echo "Owner Luxembourg: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1729 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1730 |  |  | 		if (file_exists($tmp_dir.'owner_lx.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1731 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1732 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1733 |  |  | 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1734 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1735 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1736 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1737 |  |  | 		if ($globalDebug) echo "Owner Maldives: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1738 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1739 |  |  | 		if (file_exists($tmp_dir.'owner_8q.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1740 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1741 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1742 |  |  | 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1743 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1744 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1745 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1746 |  |  | 		if ($globalDebug) echo "Owner New Zealand: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1747 |  |  | 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1748 |  |  | 		if (file_exists($tmp_dir.'owner_zk.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1749 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1750 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1751 |  |  | 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1752 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1753 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1754 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1755 |  |  | 		if ($globalDebug) echo "Owner Papua New Guinea: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1756 |  |  | 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1757 |  |  | 		if (file_exists($tmp_dir.'owner_p2.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1758 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1759 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1760 |  |  | 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1761 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1762 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1763 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1764 |  |  | 		if ($globalDebug) echo "Owner Slovakia: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1765 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1766 |  |  | 		if (file_exists($tmp_dir.'owner_om.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1767 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1768 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1769 |  |  | 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1770 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1771 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1772 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1773 |  |  | 		if ($globalDebug) echo "Owner Ecuador: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1774 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1775 |  |  | 		if (file_exists($tmp_dir.'owner_hc.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1776 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1777 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1778 |  |  | 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1779 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1780 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1781 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1782 |  |  | 		if ($globalDebug) echo "Owner Iceland: Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1783 |  |  | 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1784 |  |  | 		if (file_exists($tmp_dir.'owner_tf.csv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1785 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1786 |  |  | 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1787 |  |  | 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1788 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1789 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1790 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1791 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1792 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1793 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1794 |  |  | 	public static function update_translation() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1795 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1796 |  |  | 		$error = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1797 |  |  | 		if ($globalDebug) echo "Translation : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1798 |  |  | 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1799 |  |  | 		if (file_exists($tmp_dir.'translation.zip')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1800 |  |  | 			if ($globalDebug) echo "Unzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1801 |  |  | 			update_db::unzip($tmp_dir.'translation.zip'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1802 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1803 |  |  | 			$error = update_db::translation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1804 |  |  | 		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1805 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1806 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1807 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1808 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1809 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1810 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1811 |  |  | 	public static function update_translation_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1812 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1813 |  |  | 		if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1814 |  |  | 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1815 |  |  | 		if (file_exists($tmp_dir.'translation.tsv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1816 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1817 |  |  | 			update_db::gunzip($tmp_dir.'translation.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1818 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1819 |  |  | 			$error = update_db::translation_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1820 |  |  | 		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1821 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1822 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1823 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1824 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1825 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1826 |  |  | 	public static function update_ModeS_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1827 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1828 |  |  | 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1829 |  |  | 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1830 |  |  | 		if (file_exists($tmp_dir.'modes.tsv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1831 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1832 |  |  | 			update_db::gunzip($tmp_dir.'modes.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1833 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1834 |  |  | 			$error = update_db::modes_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1835 |  |  | 		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1836 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1837 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1838 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1839 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1840 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1841 |  |  | 	public static function update_owner_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1842 |  |  | 		global $tmp_dir, $globalDebug, $globalOwner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1843 |  |  | 		if ($globalDebug) echo "owner from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1844 |  |  | 		if ($globalOwner === TRUE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1845 |  |  | 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1846 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1847 |  |  | 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1848 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1849 |  |  | 		if (file_exists($tmp_dir.'owners.tsv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1850 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1851 |  |  | 			update_db::gunzip($tmp_dir.'owners.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1852 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1853 |  |  | 			$error = update_db::owner_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1854 |  |  | 		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1855 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1856 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1857 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1858 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1859 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1860 |  |  | 	public static function update_routes_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1861 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1862 |  |  | 		if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1863 |  |  | 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1864 |  |  | 		if (file_exists($tmp_dir.'routes.tsv.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1865 |  |  | 			if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1866 |  |  | 			update_db::gunzip($tmp_dir.'routes.tsv.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1867 |  |  | 			if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1868 |  |  | 			$error = update_db::routes_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1869 |  |  | 		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1870 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1871 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1872 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1873 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1874 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1875 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1876 |  |  | 	public static function update_airspace_fam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1877 |  |  | 		global $tmp_dir, $globalDebug, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1878 |  |  | 		include_once('class.create_db.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1879 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1880 |  |  | 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1881 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1882 |  |  | 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1883 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1884 |  |  | 			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1885 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1886 |  |  | 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1887 |  |  | 			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1888 |  |  | 			$airspace_md5 = $airspace_md5_file[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1889 |  |  | 			if (!update_db::check_airspace_version($airspace_md5)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1890 |  |  | 				if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1891 |  |  | 					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1892 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1893 |  |  | 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1894 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1895 |  |  | 				if (file_exists($tmp_dir.'airspace.sql.gz')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1896 |  |  | 					if ($globalDebug) echo "Gunzip..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1897 |  |  | 					update_db::gunzip($tmp_dir.'airspace.sql.gz'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1898 |  |  | 					if ($globalDebug) echo "Add to DB..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1899 |  |  | 					$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1900 |  |  | 					if ($Connection->tableExists('airspace')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1901 |  |  | 						$query = 'DROP TABLE airspace'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1902 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1903 |  |  | 							$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1904 |  |  |     	    	    					$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1905 |  |  | 			            		} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1906 |  |  | 							return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1907 |  |  | 		            			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1908 |  |  | 		    			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1909 |  |  | 					$error = create_db::import_file($tmp_dir.'airspace.sql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1910 |  |  | 					update_db::insert_airspace_version($airspace_md5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1911 |  |  | 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1912 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1913 |  |  | 		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1914 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1915 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1916 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1917 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1918 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1919 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1920 |  |  | 	public static function update_tle() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1921 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1922 |  |  | 		if ($globalDebug) echo "Download TLE : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1923 |  |  | 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1924 |  |  | 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1925 |  |  | 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1926 |  |  | 		foreach ($alltle as $filename) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1927 |  |  | 			if ($globalDebug) echo "downloading ".$filename.'...'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1928 |  |  | 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1929 |  |  | 			if (file_exists($tmp_dir.$filename)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1930 |  |  | 				if ($globalDebug) echo "Add to DB ".$filename."..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1931 |  |  | 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1932 |  |  | 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1933 |  |  | 			if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1934 |  |  | 				echo $error."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1935 |  |  | 			} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1936 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1937 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1938 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1940 |  |  | 	public static function update_models() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1941 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1942 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1943 |  |  | 		if ($globalDebug) echo "Models from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1944 |  |  | 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1945 |  |  | 		if (file_exists($tmp_dir.'models.md5sum')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1946 |  |  | 			if ($globalDebug) echo "Check files...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1947 |  |  | 			$newmodelsdb = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1948 |  |  | 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1949 |  |  | 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1950 |  |  | 					$model = trim($row[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1951 |  |  | 					$newmodelsdb[$model] = trim($row[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1952 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1953 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1954 |  |  | 			$modelsdb = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1955 |  |  | 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1956 |  |  | 				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1957 |  |  | 					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1958 |  |  | 						$model = trim($row[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1959 |  |  | 						$modelsdb[$model] = trim($row[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1960 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1961 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1962 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1963 |  |  | 			$diff = array_diff($newmodelsdb,$modelsdb); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1964 |  |  | 			foreach ($diff as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1965 |  |  | 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1966 |  |  | 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1967 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1968 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1969 |  |  | 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1970 |  |  | 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1971 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1972 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1973 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1974 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1975 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1976 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1977 |  |  | 	public static function update_space_models() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1978 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1979 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1980 |  |  | 		if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1981 |  |  | 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1982 |  |  | 		if (file_exists($tmp_dir.'space_models.md5sum')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1983 |  |  | 			if ($globalDebug) echo "Check files...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1984 |  |  | 			$newmodelsdb = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1985 |  |  | 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1986 |  |  | 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1987 |  |  | 					$model = trim($row[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1988 |  |  | 					$newmodelsdb[$model] = trim($row[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1989 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1990 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1991 |  |  | 			$modelsdb = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1992 |  |  | 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1993 |  |  | 				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1994 |  |  | 					while (($row = fgetcsv($handle,1000," ")) !== FALSE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1995 |  |  | 						$model = trim($row[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1996 |  |  | 						$modelsdb[$model] = trim($row[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1997 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1998 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1999 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2000 |  |  | 			$diff = array_diff($newmodelsdb,$modelsdb); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2001 |  |  | 			foreach ($diff as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2002 |  |  | 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2003 |  |  | 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2004 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2005 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2006 |  |  | 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2007 |  |  | 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2008 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2009 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2010 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2011 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2012 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2013 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2014 |  |  | 	public static function update_aircraft() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2015 |  |  | 		global $tmp_dir, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2016 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2017 |  |  | 		//$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2018 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2019 |  |  | 		if ($globalDebug) echo "Aircrafts : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2020 |  |  | 		$data_req_array = array('Mnfctrer' => '','Model' => '','Dscrptn'=> '','EngCount' =>'' ,'EngType'=> '','TDesig' => '*','WTC' => '','Button' => 'Search'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2021 |  |  | 		$data_req = 'Mnfctrer=Airbus&Model=&Dscrptn=&EngCount=&EngType=&TDesig=&WTC=&Button=Search'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2022 |  |  | 		//$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); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2023 |  |  | 		$data = Common::getData('http://cfapp.icao.int/Doc8643/8643_List1.cfm','post',$data_req_array,'','','http://cfapp.icao.int/Doc8643/search.cfm',30); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2024 |  |  | //		echo strlen($data_req); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2025 |  |  | 		echo $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2026 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2027 |  |  | 		if (file_exists($tmp_dir.'aircrafts.html')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2028 |  |  | 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2029 |  |  | 		    $fh = fopen($tmp_dir.'aircrafts.html',"r"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2030 |  |  | 		    $result = fread($fh,100000000); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2031 |  |  | 		    //echo $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2032 |  |  | 		    //var_dump(str_get_html($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2033 |  |  | 		    //print_r(self::table2array($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2034 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2035 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2036 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2037 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2038 |  |  | 	public static function update_notam() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2039 |  |  | 		global $tmp_dir, $globalDebug, $globalNOTAMSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2040 |  |  | 		require(dirname(__FILE__).'/../require/class.NOTAM.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2041 |  |  | 		$Common = new Common(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2042 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2043 |  |  | 		$query = 'TRUNCATE TABLE notam'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2044 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2045 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2046 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2047 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2048 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2049 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2050 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2051 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2052 |  |  | 		$error = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2053 |  |  | 		if ($globalDebug) echo "Notam : Download..."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2054 |  |  | 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2055 |  |  | 		if (file_exists($tmp_dir.'notam.rss')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2056 |  |  | 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2057 |  |  | 			foreach ($notams['channel']['item'] as $notam) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2058 |  |  | 				$title = explode(':',$notam['title']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2059 |  |  | 				$data['ref'] = trim($title[0]); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2060 |  |  | 				unset($title[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2061 |  |  | 				$data['title'] = trim(implode(':',$title)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2062 |  |  | 				$description = strip_tags($notam['description'],'<pre>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2063 |  |  | 				preg_match(':^(.*?)<pre>:',$description,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2064 |  |  | 				$q = explode('/',$match[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2065 |  |  | 				$data['fir'] = $q[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2066 |  |  | 				$data['code'] = $q[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2067 |  |  | 				$ifrvfr = $q[2]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2068 |  |  | 				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2069 |  |  | 				if ($ifrvfr == 'I') $data['rules'] = 'IFR'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2070 |  |  | 				if ($ifrvfr == 'V') $data['rules'] = 'VFR'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2071 |  |  | 				if ($q[4] == 'A') $data['scope'] = 'Airport warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2072 |  |  | 				if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2073 |  |  | 				if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2074 |  |  | 				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2075 |  |  | 				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2076 |  |  | 				//$data['scope'] = $q[4]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2077 |  |  | 				$data['lower_limit'] = $q[5]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2078 |  |  | 				$data['upper_limit'] = $q[6]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2079 |  |  | 				$latlonrad = $q[7]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2080 |  |  | 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2081 |  |  | 				$latitude = $Common->convertDec($las,'latitude'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2082 |  |  | 				$longitude = $Common->convertDec($lns,'longitude'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2083 |  |  | 				if ($lac == 'S') $latitude = '-'.$latitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2084 |  |  | 				if ($lnc == 'W') $longitude = '-'.$longitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2085 |  |  | 				$data['center_latitude'] = $latitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2086 |  |  | 				$data['center_longitude'] = $longitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2087 |  |  | 				$data['radius'] = intval($radius); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2088 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2089 |  |  | 				preg_match(':<pre>(.*?)</pre>:',$description,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2090 |  |  | 				$data['text'] = $match[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2091 |  |  | 				preg_match(':</pre>(.*?)$:',$description,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2092 |  |  | 				$fromto = $match[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2093 |  |  | 				preg_match('#FROM:(.*?)TO:#',$fromto,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2094 |  |  | 				$fromall = trim($match[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2095 |  |  | 				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2096 |  |  | 				$from = trim($match[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2097 |  |  | 				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2098 |  |  | 				preg_match('#TO:(.*?)$#',$fromto,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2099 |  |  | 				$toall = trim($match[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2100 |  |  | 				if (!preg_match(':Permanent:',$toall)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2101 |  |  | 					preg_match('#^(.*?) \((.*?)\)#',$toall,$match); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2102 |  |  | 					$to = trim($match[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2103 |  |  | 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2104 |  |  | 					$data['permanent'] = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2105 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2106 |  |  | 				    $data['date_end'] = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2107 |  |  | 				    $data['permanent'] = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2108 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2109 |  |  | 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2110 |  |  | 				$NOTAM = new NOTAM(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2111 |  |  | 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2112 |  |  | 				unset($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2113 |  |  | 			}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2114 |  |  | 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2115 |  |  | 		if ($error != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2116 |  |  | 			return $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2117 |  |  | 		} elseif ($globalDebug) echo "Done\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2118 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2119 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2120 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2121 |  |  | 	public static function create_airspace() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2122 |  |  | 		global $globalDBdriver, $globalDebug, $tmp_dir, $globalDBhost, $globalDBuser, $globalDBname, $globalDBpass, $globalDBport; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2123 |  |  | 		$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2124 |  |  | 		if ($Connection->tableExists('airspace')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2125 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2126 |  |  | 				$query = 'DROP TABLE geometry_columns; DROP TABLE spatial_ref_sys;DROP TABLE airspace;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2127 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2128 |  |  | 				$query = 'DROP TABLE airspace'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2129 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2130 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2131 |  |  | 				$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2132 |  |  | 				$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2133 |  |  | 				$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2134 |  |  | 			} catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2135 |  |  | 				return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2136 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2137 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2138 |  |  | 		$Common = new Common(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2139 |  |  | 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2140 |  |  | 		$airspace_json = json_decode($airspace_lst,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2141 |  |  | 		foreach ($airspace_json['records'] as $airspace) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2142 |  |  | 			if ($globalDebug) echo $airspace['name']."...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2143 |  |  | 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2144 |  |  | 			if (file_exists($tmp_dir.$airspace['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2145 |  |  | 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2146 |  |  | 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2147 |  |  | 				if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2148 |  |  | 					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'].'"'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2149 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2150 |  |  | 					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'].'"'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2151 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2152 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2153 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2154 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2155 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2156 |  |  | 	public static function check_last_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2157 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2158 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2159 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2160 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2161 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2162 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2163 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2164 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2165 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2166 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2167 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2168 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2169 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2170 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2171 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2172 |  |  |                 else return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2173 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2175 |  |  | 	public static function insert_last_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2176 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_db'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2177 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_db',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2178 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2179 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2180 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2181 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2182 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2183 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2184 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2185 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2187 |  |  | 	public static function check_airspace_version($version) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2188 |  |  | 		$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'airspace_version' AND value = :version"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2189 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2190 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2191 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2192 |  |  |                         $sth->execute(array(':version' => $version)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2193 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2194 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2195 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2196 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2197 |  |  |                 if ($row['nb'] > 0) return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2198 |  |  |                 else return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2199 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2202 |  |  | 	public static function insert_airspace_version($version) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2203 |  |  | 		$query = "DELETE FROM config WHERE name = 'airspace_version'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2204 |  |  | 			INSERT INTO config (name,value) VALUES ('airspace_version',:version);"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2205 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2206 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2207 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2208 |  |  |                         $sth->execute(array(':version' => $version)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2209 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2210 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2211 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2212 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2214 |  |  | 	public static function check_last_notam_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2215 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2216 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2217 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2218 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2219 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '1 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2220 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2221 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2222 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2223 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2224 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2225 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2226 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2227 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2228 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2229 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2230 |  |  |                 else return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2231 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2233 |  |  | 	public static function insert_last_notam_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2234 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_notam_db'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2235 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2236 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2237 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2238 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2239 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2240 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2241 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2242 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2243 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2244 |  |  | 	public static function check_last_airspace_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2245 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2246 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2247 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_airspace_db' AND value > DATE_SUB(NOW(), INTERVAL 7 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2248 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2249 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_airspace_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '7 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2250 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2251 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2252 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2253 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2254 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2255 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2256 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2257 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2258 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2259 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2260 |  |  |                 else return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2261 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2263 |  |  | 	public static function insert_last_airspace_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2264 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_airspace_db'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2265 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_airspace_db',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2266 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2267 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2268 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2269 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2270 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2271 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2272 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2273 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 2274 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 2275 |  |  | 	public static function check_last_owner_update() { | 
            
                                                                        
                            
            
                                    
            
            
                | 2276 |  |  | 		global $globalDBdriver; | 
            
                                                                        
                            
            
                                    
            
            
                | 2277 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                        
                            
            
                                    
            
            
                | 2278 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)"; | 
            
                                                                        
                            
            
                                    
            
            
                | 2279 |  |  | 		} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 2280 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'"; | 
            
                                                                        
                            
            
                                    
            
            
                | 2281 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 2282 |  |  | 		try { | 
            
                                                                        
                            
            
                                    
            
            
                | 2283 |  |  | 			$Connection = new Connection(); | 
            
                                                                        
                            
            
                                    
            
            
                | 2284 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                        
                            
            
                                    
            
            
                | 2285 |  |  |                         $sth->execute(); | 
            
                                                                        
                            
            
                                    
            
            
                | 2286 |  |  |                 } catch(PDOException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 2287 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                        
                            
            
                                    
            
            
                | 2288 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 2289 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                        
                            
            
                                    
            
            
                | 2290 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 2291 |  |  |                 else return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 2292 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2294 |  |  | 	public static function insert_last_owner_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2295 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_owner_db'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2296 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_owner_db',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2297 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2298 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2299 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2300 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2301 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2302 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2303 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2304 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2305 |  |  | 	public static function check_last_schedules_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2306 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2307 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2308 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_schedules' AND value > DATE_SUB(NOW(), INTERVAL 15 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2309 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2310 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_schedules' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2311 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2312 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2313 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2314 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2315 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2316 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2317 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2318 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2319 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2320 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2321 |  |  |                 else return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2322 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2324 |  |  | 	public static function insert_last_schedules_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2325 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_schedules'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2326 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_schedules',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2327 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2328 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2329 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2330 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2331 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2332 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2333 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2334 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2335 |  |  | 	public static function check_last_tle_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2336 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2337 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2338 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_tle' AND value > DATE_SUB(NOW(), INTERVAL 7 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2339 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2340 |  |  | 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_tle' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '7 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2341 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2342 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2343 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2344 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2345 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2346 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2347 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2348 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2349 |  |  |                 $row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2350 |  |  |                 if ($row['nb'] > 0) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2351 |  |  |                 else return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2352 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2354 |  |  | 	public static function insert_last_tle_update() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2355 |  |  | 		$query = "DELETE FROM config WHERE name = 'last_update_tle'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2356 |  |  | 			INSERT INTO config (name,value) VALUES ('last_update_tle',NOW());"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2357 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2358 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2359 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2360 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2361 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2362 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2363 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2364 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2365 |  |  | 	public static function delete_duplicatemodes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2366 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2367 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2368 |  |  | 			$query = "DELETE a FROM aircraft_modes a, aircraft_modes b WHERE a.ModeS = b.ModeS AND a.FirstCreated < b.FirstCreated AND a.Source != 'ACARS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2369 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2370 |  |  | 			$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'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2371 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2372 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2373 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2374 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2375 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2376 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2377 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2378 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2379 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2380 |  |  | 	public static function delete_duplicateowner() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2381 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2382 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2383 |  |  | 			$query = "DELETE a FROM aircraft_owner a, aircraft_owner b WHERE a.registration = b.registration AND a.owner_id < b.owner_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2384 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2385 |  |  | 			$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)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2386 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2387 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2388 |  |  | 			$Connection = new Connection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2389 |  |  | 			$sth = $Connection->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2390 |  |  |                         $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2391 |  |  |                 } catch(PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2392 |  |  |                         return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2393 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2394 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2395 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2396 |  |  | 	public static function update_all() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2397 |  |  | 		global $globalMasterServer, $globalMasterSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2398 |  |  | 		if (!isset($globalMasterServer) || !$globalMasterServer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2399 |  |  | 			if (isset($globalMasterSource) && $globalMasterSource) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2400 |  |  | 				echo update_db::update_routes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2401 |  |  | 				echo update_db::update_translation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2402 |  |  | 				echo update_db::update_notam_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2403 |  |  | 				echo update_db::update_ModeS(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2404 |  |  | 				echo update_db::update_ModeS_flarm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2405 |  |  | 				echo update_db::update_ModeS_ogn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2406 |  |  | 				echo update_db::update_ModeS_faa(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2407 |  |  | 				//echo update_db::delete_duplicatemodes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2408 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2409 |  |  | 				//echo update_db::update_routes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2410 |  |  | 				echo update_db::update_routes_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2411 |  |  | 				echo update_db::update_translation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2412 |  |  | 				echo update_db::update_translation_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2413 |  |  | 				echo update_db::update_notam_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2414 |  |  | 				//echo update_db::update_ModeS(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2415 |  |  | 				echo update_db::update_ModeS_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2416 |  |  | 				echo update_db::update_ModeS_flarm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2417 |  |  | 				echo update_db::update_ModeS_ogn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2418 |  |  | 				echo update_db::delete_duplicatemodes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2419 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2420 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2421 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2422 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2424 |  |  | //echo update_db::update_airports(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2425 |  |  | //echo update_db::translation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2426 |  |  | //echo update_db::update_waypoints(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2427 |  |  | //echo update_db::update_airspace(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2428 |  |  | //echo update_db::update_notam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2429 |  |  | //echo update_db::update_ivao(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2430 |  |  | //echo update_db::update_ModeS_flarm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2431 |  |  | //echo update_db::update_ModeS_ogn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2432 |  |  | //echo update_db::update_aircraft(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2433 |  |  | //$update_db = new update_db(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2434 |  |  | //echo $update_db->update_owner(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2435 |  |  | //update_db::update_translation_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2436 |  |  | //echo update_db::update_routes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2437 |  |  | //update_db::update_models(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2438 |  |  | //echo $update_db::update_skyteam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2439 |  |  | //echo $update_db::update_tle(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2440 |  |  | //echo update_db::update_notam_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2441 |  |  | //echo update_db::create_airspace(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2442 |  |  | //echo update_db::update_ModeS(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2443 |  |  | //echo update_db::update_ModeS_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2444 |  |  | //echo update_db::update_routes_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2445 |  |  | //echo update_db::update_ModeS_faa(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2446 |  |  | //echo update_db::modes_faa(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2447 |  |  | //echo update_db::update_owner_fam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2448 |  |  | //echo update_db::delete_duplicateowner(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 2449 |  |  | ?> | 
            
                                                        
            
                                    
            
            
                | 2450 |  |  |  | 
            
                        
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.