@@ -4,55 +4,55 @@ discard block |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | 6 | if (isset($_GET['start_date'])) { |
| 7 | - //for the date manipulation into the query |
|
| 8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | - $start_date = $_GET['start_date'].":00"; |
|
| 10 | - $end_date = $_GET['end_date'].":00"; |
|
| 11 | - $sql_date = $start_date.",".$end_date; |
|
| 12 | - } else if($_GET['start_date'] != ""){ |
|
| 13 | - $start_date = $_GET['start_date'].":00"; |
|
| 14 | - $sql_date = $start_date; |
|
| 15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | - $sql_date = $end_date; |
|
| 18 | - } else $sql_date = ''; |
|
| 7 | + //for the date manipulation into the query |
|
| 8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | + $start_date = $_GET['start_date'].":00"; |
|
| 10 | + $end_date = $_GET['end_date'].":00"; |
|
| 11 | + $sql_date = $start_date.",".$end_date; |
|
| 12 | + } else if($_GET['start_date'] != ""){ |
|
| 13 | + $start_date = $_GET['start_date'].":00"; |
|
| 14 | + $sql_date = $start_date; |
|
| 15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | + $sql_date = $end_date; |
|
| 18 | + } else $sql_date = ''; |
|
| 19 | 19 | } else $sql_date = ''; |
| 20 | 20 | |
| 21 | 21 | if (isset($_GET['highest_altitude'])) { |
| 22 | - //for altitude manipulation |
|
| 23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | - $end_altitude = $_GET['highest_altitude']; |
|
| 25 | - $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | - } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | - $end_altitude = $_GET['highest_altitude']; |
|
| 29 | - $sql_altitude = $end_altitude; |
|
| 30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | - $sql_altitude = $start_altitude; |
|
| 33 | - } else $sql_altitude = ''; |
|
| 22 | + //for altitude manipulation |
|
| 23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | + $end_altitude = $_GET['highest_altitude']; |
|
| 25 | + $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | + } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | + $end_altitude = $_GET['highest_altitude']; |
|
| 29 | + $sql_altitude = $end_altitude; |
|
| 30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | + $sql_altitude = $start_altitude; |
|
| 33 | + } else $sql_altitude = ''; |
|
| 34 | 34 | } else $sql_altitude = ''; |
| 35 | 35 | |
| 36 | 36 | //calculuation for the pagination |
| 37 | 37 | if(!isset($_GET['limit'])) |
| 38 | 38 | { |
| 39 | - if (!isset($_GET['number_results'])) |
|
| 40 | - { |
|
| 41 | - $limit_start = 0; |
|
| 42 | - $limit_end = 25; |
|
| 43 | - $absolute_difference = 25; |
|
| 44 | - } else { |
|
| 45 | - if ($_GET['number_results'] > 1000){ |
|
| 46 | - $_GET['number_results'] = 1000; |
|
| 47 | - } |
|
| 48 | - $limit_start = 0; |
|
| 49 | - $limit_end = $_GET['number_results']; |
|
| 50 | - $absolute_difference = $_GET['number_results']; |
|
| 51 | - } |
|
| 39 | + if (!isset($_GET['number_results'])) |
|
| 40 | + { |
|
| 41 | + $limit_start = 0; |
|
| 42 | + $limit_end = 25; |
|
| 43 | + $absolute_difference = 25; |
|
| 44 | + } else { |
|
| 45 | + if ($_GET['number_results'] > 1000){ |
|
| 46 | + $_GET['number_results'] = 1000; |
|
| 47 | + } |
|
| 48 | + $limit_start = 0; |
|
| 49 | + $limit_end = $_GET['number_results']; |
|
| 50 | + $absolute_difference = $_GET['number_results']; |
|
| 51 | + } |
|
| 52 | 52 | } else { |
| 53 | - $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | - $limit_start = $limit_explode[0]; |
|
| 55 | - $limit_end = $limit_explode[1]; |
|
| 53 | + $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | + $limit_start = $limit_explode[0]; |
|
| 55 | + $limit_end = $limit_explode[1]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |
@@ -89,56 +89,56 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $output = '<?xml version="1.0" encoding="UTF-8" ?>'; |
| 91 | 91 | $output .= '<flightairmap>'; |
| 92 | - $output .= '<title>'.$globalName.' XML Feed</title>'; |
|
| 93 | - $output .= '<link>http://'.$_SERVER['HTTP_HOST'].$globalURL.'</link>'; |
|
| 94 | - $output .= '<aircrafts>'; |
|
| 92 | + $output .= '<title>'.$globalName.' XML Feed</title>'; |
|
| 93 | + $output .= '<link>http://'.$_SERVER['HTTP_HOST'].$globalURL.'</link>'; |
|
| 94 | + $output .= '<aircrafts>'; |
|
| 95 | 95 | |
| 96 | - if (!empty($spotter_array)) |
|
| 96 | + if (!empty($spotter_array)) |
|
| 97 | 97 | { |
| 98 | - foreach($spotter_array as $spotter_item) |
|
| 99 | - { |
|
| 98 | + foreach($spotter_array as $spotter_item) |
|
| 99 | + { |
|
| 100 | 100 | |
| 101 | - $output .= '<aircraft>'; |
|
| 102 | - $output .= '<id>'.$spotter_item['spotter_id'].'</id>'; |
|
| 103 | - $output .= '<ident>'.$spotter_item['ident'].'</ident>'; |
|
| 104 | - $output .= '<registration>'.$spotter_item['registration'].'</registration>'; |
|
| 105 | - $output .= '<aircraft_icao>'.$spotter_item['aircraft_type'].'</aircraft_icao>'; |
|
| 106 | - $output .= '<aircraft_name>'.$spotter_item['aircraft_name'].'</aircraft_name>'; |
|
| 107 | - $output .= '<aircraft_manufacturer>'.$spotter_item['aircraft_manufacturer'].'</aircraft_manufacturer>'; |
|
| 108 | - $output .= '<airline_name>'.$spotter_item['airline_name'].'</airline_name>'; |
|
| 109 | - $output .= '<airline_icao>'.$spotter_item['airline_icao'].'</airline_icao>'; |
|
| 101 | + $output .= '<aircraft>'; |
|
| 102 | + $output .= '<id>'.$spotter_item['spotter_id'].'</id>'; |
|
| 103 | + $output .= '<ident>'.$spotter_item['ident'].'</ident>'; |
|
| 104 | + $output .= '<registration>'.$spotter_item['registration'].'</registration>'; |
|
| 105 | + $output .= '<aircraft_icao>'.$spotter_item['aircraft_type'].'</aircraft_icao>'; |
|
| 106 | + $output .= '<aircraft_name>'.$spotter_item['aircraft_name'].'</aircraft_name>'; |
|
| 107 | + $output .= '<aircraft_manufacturer>'.$spotter_item['aircraft_manufacturer'].'</aircraft_manufacturer>'; |
|
| 108 | + $output .= '<airline_name>'.$spotter_item['airline_name'].'</airline_name>'; |
|
| 109 | + $output .= '<airline_icao>'.$spotter_item['airline_icao'].'</airline_icao>'; |
|
| 110 | 110 | if (isset($spotter_item['airline_iata'])) { |
| 111 | - $output .= '<airline_iata>'.$spotter_item['airline_iata'].'</airline_iata>'; |
|
| 112 | - } |
|
| 113 | - $output .= '<airline_country>'.$spotter_item['airline_country'].'</airline_country>'; |
|
| 114 | - if (isset($spotter_item['airline_callsign'])) { |
|
| 115 | - $output .= '<airline_callsign>'.$spotter_item['airline_callsign'].'</airline_callsign>'; |
|
| 116 | - } |
|
| 117 | - $output .= '<airline_type>'.$spotter_item['airline_type'].'</airline_type>'; |
|
| 118 | - $output .= '<departure_airport_city>'.$spotter_item['departure_airport_city'].'</departure_airport_city>'; |
|
| 119 | - $output .= '<departure_airport_country>'.$spotter_item['departure_airport_country'].'</departure_airport_country>'; |
|
| 120 | - $output .= '<departure_airport_iata>'.$spotter_item['departure_airport_iata'].'</departure_airport_iata>'; |
|
| 121 | - $output .= '<departure_airport_icao>'.$spotter_item['departure_airport_icao'].'</departure_airport_icao>'; |
|
| 122 | - $output .= '<departure_airport_latitude>'.$spotter_item['departure_airport_latitude'].'</departure_airport_latitude>'; |
|
| 123 | - $output .= '<departure_airport_longitude>'.$spotter_item['departure_airport_longitude'].'</departure_airport_longitude>'; |
|
| 124 | - $output .= '<departure_airport_altitude>'.$spotter_item['departure_airport_altitude'].'</departure_airport_altitude>'; |
|
| 125 | - $output .= '<arrival_airport_city>'.$spotter_item['arrival_airport_city'].'</arrival_airport_city>'; |
|
| 126 | - $output .= '<arrival_airport_country>'.$spotter_item['arrival_airport_country'].'</arrival_airport_country>'; |
|
| 127 | - $output .= '<arrival_airport_iata>'.$spotter_item['arrival_airport_iata'].'</arrival_airport_iata>'; |
|
| 128 | - $output .= '<arrival_airport_icao>'.$spotter_item['arrival_airport_icao'].'</arrival_airport_icao>'; |
|
| 129 | - $output .= '<arrival_airport_latitude>'.$spotter_item['arrival_airport_latitude'].'</arrival_airport_latitude>'; |
|
| 130 | - $output .= '<arrival_airport_longitude>'.$spotter_item['arrival_airport_longitude'].'</arrival_airport_longitude>'; |
|
| 131 | - $output .= '<arrival_airport_altitude>'.$spotter_item['arrival_airport_altitude'].'</arrival_airport_altitude>'; |
|
| 132 | - $output .= '<latitude>'.$spotter_item['latitude'].'</latitude>'; |
|
| 133 | - $output .= '<longitude>'.$spotter_item['longitude'].'</longitude>'; |
|
| 134 | - $output .= '<altitude>'.$spotter_item['altitude'].'</altitude>'; |
|
| 135 | - $output .= '<ground_speed>'.$spotter_item['ground_speed'].'</ground_speed>'; |
|
| 136 | - $output .= '<heading>'.$spotter_item['heading'].'</heading>'; |
|
| 137 | - $output .= '<heading_name>'.$spotter_item['heading_name'].'</heading_name>'; |
|
| 138 | - $output .= '<waypoints>'.$spotter_item['waypoints'].'</waypoints>'; |
|
| 139 | - $output .= '<date>'.date("c", strtotime($spotter_item['date_iso_8601'])).'</date>'; |
|
| 140 | - $output .= '</aircraft>'; |
|
| 141 | - } |
|
| 111 | + $output .= '<airline_iata>'.$spotter_item['airline_iata'].'</airline_iata>'; |
|
| 112 | + } |
|
| 113 | + $output .= '<airline_country>'.$spotter_item['airline_country'].'</airline_country>'; |
|
| 114 | + if (isset($spotter_item['airline_callsign'])) { |
|
| 115 | + $output .= '<airline_callsign>'.$spotter_item['airline_callsign'].'</airline_callsign>'; |
|
| 116 | + } |
|
| 117 | + $output .= '<airline_type>'.$spotter_item['airline_type'].'</airline_type>'; |
|
| 118 | + $output .= '<departure_airport_city>'.$spotter_item['departure_airport_city'].'</departure_airport_city>'; |
|
| 119 | + $output .= '<departure_airport_country>'.$spotter_item['departure_airport_country'].'</departure_airport_country>'; |
|
| 120 | + $output .= '<departure_airport_iata>'.$spotter_item['departure_airport_iata'].'</departure_airport_iata>'; |
|
| 121 | + $output .= '<departure_airport_icao>'.$spotter_item['departure_airport_icao'].'</departure_airport_icao>'; |
|
| 122 | + $output .= '<departure_airport_latitude>'.$spotter_item['departure_airport_latitude'].'</departure_airport_latitude>'; |
|
| 123 | + $output .= '<departure_airport_longitude>'.$spotter_item['departure_airport_longitude'].'</departure_airport_longitude>'; |
|
| 124 | + $output .= '<departure_airport_altitude>'.$spotter_item['departure_airport_altitude'].'</departure_airport_altitude>'; |
|
| 125 | + $output .= '<arrival_airport_city>'.$spotter_item['arrival_airport_city'].'</arrival_airport_city>'; |
|
| 126 | + $output .= '<arrival_airport_country>'.$spotter_item['arrival_airport_country'].'</arrival_airport_country>'; |
|
| 127 | + $output .= '<arrival_airport_iata>'.$spotter_item['arrival_airport_iata'].'</arrival_airport_iata>'; |
|
| 128 | + $output .= '<arrival_airport_icao>'.$spotter_item['arrival_airport_icao'].'</arrival_airport_icao>'; |
|
| 129 | + $output .= '<arrival_airport_latitude>'.$spotter_item['arrival_airport_latitude'].'</arrival_airport_latitude>'; |
|
| 130 | + $output .= '<arrival_airport_longitude>'.$spotter_item['arrival_airport_longitude'].'</arrival_airport_longitude>'; |
|
| 131 | + $output .= '<arrival_airport_altitude>'.$spotter_item['arrival_airport_altitude'].'</arrival_airport_altitude>'; |
|
| 132 | + $output .= '<latitude>'.$spotter_item['latitude'].'</latitude>'; |
|
| 133 | + $output .= '<longitude>'.$spotter_item['longitude'].'</longitude>'; |
|
| 134 | + $output .= '<altitude>'.$spotter_item['altitude'].'</altitude>'; |
|
| 135 | + $output .= '<ground_speed>'.$spotter_item['ground_speed'].'</ground_speed>'; |
|
| 136 | + $output .= '<heading>'.$spotter_item['heading'].'</heading>'; |
|
| 137 | + $output .= '<heading_name>'.$spotter_item['heading_name'].'</heading_name>'; |
|
| 138 | + $output .= '<waypoints>'.$spotter_item['waypoints'].'</waypoints>'; |
|
| 139 | + $output .= '<date>'.date("c", strtotime($spotter_item['date_iso_8601'])).'</date>'; |
|
| 140 | + $output .= '</aircraft>'; |
|
| 141 | + } |
|
| 142 | 142 | } |
| 143 | 143 | $output .= '</aircrafts>'; |
| 144 | 144 | $output .= '</flightairmap>'; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | function drawChart() { |
| 36 | 36 | var data = google.visualization.arrayToDataTable([ |
| 37 | 37 | ["'._("Country").'", "'._("# of times").'"], '; |
| 38 | - $country_data = ''; |
|
| 38 | + $country_data = ''; |
|
| 39 | 39 | foreach($airline_array as $airline_item) |
| 40 | 40 | { |
| 41 | 41 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
@@ -4,55 +4,55 @@ |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | 6 | if (isset($_GET['start_date'])) { |
| 7 | - //for the date manipulation into the query |
|
| 8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | - $start_date = $_GET['start_date'].":00"; |
|
| 10 | - $end_date = $_GET['end_date'].":00"; |
|
| 11 | - $sql_date = $start_date.",".$end_date; |
|
| 12 | - } else if($_GET['start_date'] != ""){ |
|
| 13 | - $start_date = $_GET['start_date'].":00"; |
|
| 14 | - $sql_date = $start_date; |
|
| 15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | - $sql_date = $end_date; |
|
| 18 | - } else $sql_date = ''; |
|
| 7 | + //for the date manipulation into the query |
|
| 8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | + $start_date = $_GET['start_date'].":00"; |
|
| 10 | + $end_date = $_GET['end_date'].":00"; |
|
| 11 | + $sql_date = $start_date.",".$end_date; |
|
| 12 | + } else if($_GET['start_date'] != ""){ |
|
| 13 | + $start_date = $_GET['start_date'].":00"; |
|
| 14 | + $sql_date = $start_date; |
|
| 15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | + $sql_date = $end_date; |
|
| 18 | + } else $sql_date = ''; |
|
| 19 | 19 | } else $sql_date = ''; |
| 20 | 20 | |
| 21 | 21 | if (isset($_GET['highest_altitude'])) { |
| 22 | - //for altitude manipulation |
|
| 23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | - $end_altitude = $_GET['highest_altitude']; |
|
| 25 | - $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | - } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | - $end_altitude = $_GET['highest_altitude']; |
|
| 29 | - $sql_altitude = $end_altitude; |
|
| 30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | - $sql_altitude = $start_altitude; |
|
| 33 | - } else $sql_altitude = ''; |
|
| 22 | + //for altitude manipulation |
|
| 23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | + $end_altitude = $_GET['highest_altitude']; |
|
| 25 | + $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | + } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | + $end_altitude = $_GET['highest_altitude']; |
|
| 29 | + $sql_altitude = $end_altitude; |
|
| 30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | + $sql_altitude = $start_altitude; |
|
| 33 | + } else $sql_altitude = ''; |
|
| 34 | 34 | } else $sql_altitude = ''; |
| 35 | 35 | |
| 36 | 36 | //calculuation for the pagination |
| 37 | 37 | if(!isset($_GET['limit'])) |
| 38 | 38 | { |
| 39 | - if (!isset($_GET['number_results'])) |
|
| 40 | - { |
|
| 41 | - $limit_start = 0; |
|
| 42 | - $limit_end = 25; |
|
| 43 | - $absolute_difference = 25; |
|
| 44 | - } else { |
|
| 45 | - if ($_GET['number_results'] > 1000){ |
|
| 46 | - $_GET['number_results'] = 1000; |
|
| 47 | - } |
|
| 48 | - $limit_start = 0; |
|
| 49 | - $limit_end = $_GET['number_results']; |
|
| 50 | - $absolute_difference = $_GET['number_results']; |
|
| 51 | - } |
|
| 39 | + if (!isset($_GET['number_results'])) |
|
| 40 | + { |
|
| 41 | + $limit_start = 0; |
|
| 42 | + $limit_end = 25; |
|
| 43 | + $absolute_difference = 25; |
|
| 44 | + } else { |
|
| 45 | + if ($_GET['number_results'] > 1000){ |
|
| 46 | + $_GET['number_results'] = 1000; |
|
| 47 | + } |
|
| 48 | + $limit_start = 0; |
|
| 49 | + $limit_end = $_GET['number_results']; |
|
| 50 | + $absolute_difference = $_GET['number_results']; |
|
| 51 | + } |
|
| 52 | 52 | } else { |
| 53 | - $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | - $limit_start = $limit_explode[0]; |
|
| 55 | - $limit_end = $limit_explode[1]; |
|
| 53 | + $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | + $limit_start = $limit_explode[0]; |
|
| 55 | + $limit_end = $limit_explode[1]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |
@@ -8,18 +8,18 @@ discard block |
||
| 8 | 8 | class update_schema { |
| 9 | 9 | |
| 10 | 10 | public static function update_schedule() { |
| 11 | - $Connection = new Connection(); |
|
| 12 | - $Schedule = new Schedule(); |
|
| 13 | - $query = "SELECT * FROM schedule"; |
|
| 14 | - try { |
|
| 15 | - $sth = $Connection->db->prepare($query); |
|
| 11 | + $Connection = new Connection(); |
|
| 12 | + $Schedule = new Schedule(); |
|
| 13 | + $query = "SELECT * FROM schedule"; |
|
| 14 | + try { |
|
| 15 | + $sth = $Connection->db->prepare($query); |
|
| 16 | 16 | $sth->execute(); |
| 17 | - } catch(PDOException $e) { |
|
| 17 | + } catch(PDOException $e) { |
|
| 18 | 18 | return "error : ".$e->getMessage()."\n"; |
| 19 | - } |
|
| 20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
| 22 | - } |
|
| 19 | + } |
|
| 20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | */ |
| 45 | 45 | private static function update_from_1() { |
| 46 | - $Connection = new Connection(); |
|
| 47 | - // Add new column to routes table |
|
| 48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
| 46 | + $Connection = new Connection(); |
|
| 47 | + // Add new column to routes table |
|
| 48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
| 49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
| 50 | - try { |
|
| 51 | - $sth = $Connection->db->prepare($query); |
|
| 52 | - $sth->execute(); |
|
| 53 | - } catch(PDOException $e) { |
|
| 54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
| 55 | - } |
|
| 56 | - // Copy schedules data to routes table |
|
| 57 | - self::update_schedule(); |
|
| 58 | - // Delete schedule table |
|
| 50 | + try { |
|
| 51 | + $sth = $Connection->db->prepare($query); |
|
| 52 | + $sth->execute(); |
|
| 53 | + } catch(PDOException $e) { |
|
| 54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
| 55 | + } |
|
| 56 | + // Copy schedules data to routes table |
|
| 57 | + self::update_schedule(); |
|
| 58 | + // Delete schedule table |
|
| 59 | 59 | $query = "DROP TABLE `schedule`"; |
| 60 | - try { |
|
| 61 | - $sth = $Connection->db->prepare($query); |
|
| 62 | - $sth->execute(); |
|
| 63 | - } catch(PDOException $e) { |
|
| 64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
| 65 | - } |
|
| 66 | - // Add source column |
|
| 67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
| 68 | - try { |
|
| 69 | - $sth = $Connection->db->prepare($query); |
|
| 70 | - $sth->execute(); |
|
| 71 | - } catch(PDOException $e) { |
|
| 72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 73 | - } |
|
| 60 | + try { |
|
| 61 | + $sth = $Connection->db->prepare($query); |
|
| 62 | + $sth->execute(); |
|
| 63 | + } catch(PDOException $e) { |
|
| 64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
| 65 | + } |
|
| 66 | + // Add source column |
|
| 67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
| 68 | + try { |
|
| 69 | + $sth = $Connection->db->prepare($query); |
|
| 70 | + $sth->execute(); |
|
| 71 | + } catch(PDOException $e) { |
|
| 72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 73 | + } |
|
| 74 | 74 | // Delete unused column |
| 75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
| 76 | - try { |
|
| 77 | - $sth = $Connection->db->prepare($query); |
|
| 78 | - $sth->execute(); |
|
| 79 | - } catch(PDOException $e) { |
|
| 80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 81 | - } |
|
| 76 | + try { |
|
| 77 | + $sth = $Connection->db->prepare($query); |
|
| 78 | + $sth->execute(); |
|
| 79 | + } catch(PDOException $e) { |
|
| 80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 81 | + } |
|
| 82 | 82 | // Add ModeS column |
| 83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
| 84 | - try { |
|
| 85 | - $sth = $Connection->db->prepare($query); |
|
| 86 | - $sth->execute(); |
|
| 87 | - } catch(PDOException $e) { |
|
| 88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
| 89 | - } |
|
| 84 | + try { |
|
| 85 | + $sth = $Connection->db->prepare($query); |
|
| 86 | + $sth->execute(); |
|
| 87 | + } catch(PDOException $e) { |
|
| 88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
| 89 | + } |
|
| 90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
| 91 | - try { |
|
| 92 | - $sth = $Connection->db->prepare($query); |
|
| 93 | - $sth->execute(); |
|
| 94 | - } catch(PDOException $e) { |
|
| 95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
| 96 | - } |
|
| 97 | - // Add auto_increment for aircraft_modes |
|
| 98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
| 99 | - try { |
|
| 100 | - $sth = $Connection->db->prepare($query); |
|
| 101 | - $sth->execute(); |
|
| 102 | - } catch(PDOException $e) { |
|
| 103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 104 | - } |
|
| 105 | - $error = ''; |
|
| 91 | + try { |
|
| 92 | + $sth = $Connection->db->prepare($query); |
|
| 93 | + $sth->execute(); |
|
| 94 | + } catch(PDOException $e) { |
|
| 95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
| 96 | + } |
|
| 97 | + // Add auto_increment for aircraft_modes |
|
| 98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
| 99 | + try { |
|
| 100 | + $sth = $Connection->db->prepare($query); |
|
| 101 | + $sth->execute(); |
|
| 102 | + } catch(PDOException $e) { |
|
| 103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 104 | + } |
|
| 105 | + $error = ''; |
|
| 106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
| 107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
| 108 | 108 | // Update schema_version to 2 |
| 109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
| 110 | - try { |
|
| 111 | - $sth = $Connection->db->prepare($query); |
|
| 112 | - $sth->execute(); |
|
| 113 | - } catch(PDOException $e) { |
|
| 114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 115 | - } |
|
| 110 | + try { |
|
| 111 | + $sth = $Connection->db->prepare($query); |
|
| 112 | + $sth->execute(); |
|
| 113 | + } catch(PDOException $e) { |
|
| 114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 115 | + } |
|
| 116 | 116 | return $error; |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | private static function update_from_2() { |
| 120 | - $Connection = new Connection(); |
|
| 121 | - // Add new column decode to acars_live table |
|
| 120 | + $Connection = new Connection(); |
|
| 121 | + // Add new column decode to acars_live table |
|
| 122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
| 123 | - try { |
|
| 124 | - $sth = $Connection->db->prepare($query); |
|
| 125 | - $sth->execute(); |
|
| 126 | - } catch(PDOException $e) { |
|
| 127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
| 128 | - } |
|
| 129 | - $error = ''; |
|
| 130 | - // Create table acars_archive |
|
| 123 | + try { |
|
| 124 | + $sth = $Connection->db->prepare($query); |
|
| 125 | + $sth->execute(); |
|
| 126 | + } catch(PDOException $e) { |
|
| 127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
| 128 | + } |
|
| 129 | + $error = ''; |
|
| 130 | + // Create table acars_archive |
|
| 131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
| 132 | 132 | // Update schema_version to 3 |
| 133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
| 134 | - try { |
|
| 135 | - $sth = $Connection->db->prepare($query); |
|
| 136 | - $sth->execute(); |
|
| 137 | - } catch(PDOException $e) { |
|
| 138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 139 | - } |
|
| 134 | + try { |
|
| 135 | + $sth = $Connection->db->prepare($query); |
|
| 136 | + $sth->execute(); |
|
| 137 | + } catch(PDOException $e) { |
|
| 138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 139 | + } |
|
| 140 | 140 | return $error; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | private static function update_from_3() { |
| 144 | - $Connection = new Connection(); |
|
| 145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
| 144 | + $Connection = new Connection(); |
|
| 145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
| 146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
| 147 | - try { |
|
| 148 | - $sth = $Connection->db->prepare($query); |
|
| 149 | - $sth->execute(); |
|
| 150 | - } catch(PDOException $e) { |
|
| 151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 152 | - } |
|
| 153 | - // Add image_source_website column to spotter_image |
|
| 147 | + try { |
|
| 148 | + $sth = $Connection->db->prepare($query); |
|
| 149 | + $sth->execute(); |
|
| 150 | + } catch(PDOException $e) { |
|
| 151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
| 152 | + } |
|
| 153 | + // Add image_source_website column to spotter_image |
|
| 154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
| 155 | - try { |
|
| 156 | - $sth = $Connection->db->prepare($query); |
|
| 157 | - $sth->execute(); |
|
| 158 | - } catch(PDOException $e) { |
|
| 159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
| 160 | - } |
|
| 161 | - $error = ''; |
|
| 155 | + try { |
|
| 156 | + $sth = $Connection->db->prepare($query); |
|
| 157 | + $sth->execute(); |
|
| 158 | + } catch(PDOException $e) { |
|
| 159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
| 160 | + } |
|
| 161 | + $error = ''; |
|
| 162 | 162 | // Update schema_version to 4 |
| 163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
| 164 | - try { |
|
| 165 | - $sth = $Connection->db->prepare($query); |
|
| 166 | - $sth->execute(); |
|
| 167 | - } catch(PDOException $e) { |
|
| 168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 169 | - } |
|
| 164 | + try { |
|
| 165 | + $sth = $Connection->db->prepare($query); |
|
| 166 | + $sth->execute(); |
|
| 167 | + } catch(PDOException $e) { |
|
| 168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 169 | + } |
|
| 170 | 170 | return $error; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | private static function update_from_4() { |
| 174 | - $Connection = new Connection(); |
|
| 174 | + $Connection = new Connection(); |
|
| 175 | 175 | |
| 176 | - $error = ''; |
|
| 177 | - // Create table acars_label |
|
| 176 | + $error = ''; |
|
| 177 | + // Create table acars_label |
|
| 178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
| 179 | 179 | if ($error == '') { |
| 180 | - // Update schema_version to 5 |
|
| 181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
| 182 | - try { |
|
| 183 | - $sth = $Connection->db->prepare($query); |
|
| 180 | + // Update schema_version to 5 |
|
| 181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
| 182 | + try { |
|
| 183 | + $sth = $Connection->db->prepare($query); |
|
| 184 | 184 | $sth->execute(); |
| 185 | - } catch(PDOException $e) { |
|
| 185 | + } catch(PDOException $e) { |
|
| 186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 187 | - } |
|
| 188 | - } |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | 189 | return $error; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | private static function update_from_5() { |
| 193 | - $Connection = new Connection(); |
|
| 194 | - // Add columns to translation |
|
| 193 | + $Connection = new Connection(); |
|
| 194 | + // Add columns to translation |
|
| 195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
| 196 | - try { |
|
| 197 | - $sth = $Connection->db->prepare($query); |
|
| 198 | - $sth->execute(); |
|
| 199 | - } catch(PDOException $e) { |
|
| 200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
| 201 | - } |
|
| 202 | - // Add aircraft_shadow column to aircraft |
|
| 203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
| 204 | - try { |
|
| 205 | - $sth = $Connection->db->prepare($query); |
|
| 206 | - $sth->execute(); |
|
| 207 | - } catch(PDOException $e) { |
|
| 208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
| 209 | - } |
|
| 210 | - // Add aircraft_shadow column to spotter_live |
|
| 211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
| 212 | - try { |
|
| 213 | - $sth = $Connection->db->prepare($query); |
|
| 214 | - $sth->execute(); |
|
| 215 | - } catch(PDOException $e) { |
|
| 216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 217 | - } |
|
| 218 | - $error = ''; |
|
| 219 | - // Update table aircraft |
|
| 196 | + try { |
|
| 197 | + $sth = $Connection->db->prepare($query); |
|
| 198 | + $sth->execute(); |
|
| 199 | + } catch(PDOException $e) { |
|
| 200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
| 201 | + } |
|
| 202 | + // Add aircraft_shadow column to aircraft |
|
| 203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
| 204 | + try { |
|
| 205 | + $sth = $Connection->db->prepare($query); |
|
| 206 | + $sth->execute(); |
|
| 207 | + } catch(PDOException $e) { |
|
| 208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
| 209 | + } |
|
| 210 | + // Add aircraft_shadow column to spotter_live |
|
| 211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
| 212 | + try { |
|
| 213 | + $sth = $Connection->db->prepare($query); |
|
| 214 | + $sth->execute(); |
|
| 215 | + } catch(PDOException $e) { |
|
| 216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 217 | + } |
|
| 218 | + $error = ''; |
|
| 219 | + // Update table aircraft |
|
| 220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
| 221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
| 222 | 222 | |
| 223 | 223 | // Update schema_version to 6 |
| 224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
| 225 | - try { |
|
| 226 | - $sth = $Connection->db->prepare($query); |
|
| 227 | - $sth->execute(); |
|
| 228 | - } catch(PDOException $e) { |
|
| 229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 230 | - } |
|
| 225 | + try { |
|
| 226 | + $sth = $Connection->db->prepare($query); |
|
| 227 | + $sth->execute(); |
|
| 228 | + } catch(PDOException $e) { |
|
| 229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 230 | + } |
|
| 231 | 231 | return $error; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | private static function update_from_6() { |
| 235 | - $Connection = new Connection(); |
|
| 236 | - if (!$Connection−>indexExists('spotter_output','flightaware_id')) { |
|
| 237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
| 235 | + $Connection = new Connection(); |
|
| 236 | + if (!$Connection−>indexExists('spotter_output','flightaware_id')) { |
|
| 237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
| 238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
| 239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
| 240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
| 247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
| 248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
| 249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
| 250 | - try { |
|
| 251 | - $sth = $Connection->db->prepare($query); |
|
| 250 | + try { |
|
| 251 | + $sth = $Connection->db->prepare($query); |
|
| 252 | 252 | $sth->execute(); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch(PDOException $e) { |
|
| 254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
| 255 | - } |
|
| 256 | - } |
|
| 257 | - $error = ''; |
|
| 258 | - // Update table countries |
|
| 259 | - if ($Connection->tableExists('airspace')) { |
|
| 260 | - $error .= update_db::update_countries(); |
|
| 261 | - if ($error != '') return $error; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + $error = ''; |
|
| 258 | + // Update table countries |
|
| 259 | + if ($Connection->tableExists('airspace')) { |
|
| 260 | + $error .= update_db::update_countries(); |
|
| 261 | + if ($error != '') return $error; |
|
| 262 | 262 | } |
| 263 | 263 | // Update schema_version to 7 |
| 264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
| 265 | - try { |
|
| 266 | - $sth = $Connection->db->prepare($query); |
|
| 267 | - $sth->execute(); |
|
| 268 | - } catch(PDOException $e) { |
|
| 269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 270 | - } |
|
| 265 | + try { |
|
| 266 | + $sth = $Connection->db->prepare($query); |
|
| 267 | + $sth->execute(); |
|
| 268 | + } catch(PDOException $e) { |
|
| 269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 270 | + } |
|
| 271 | 271 | return $error; |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | private static function update_from_7() { |
| 275 | 275 | global $globalDBname, $globalDBdriver; |
| 276 | - $Connection = new Connection(); |
|
| 277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 276 | + $Connection = new Connection(); |
|
| 277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
| 279 | - try { |
|
| 280 | - $sth = $Connection->db->prepare($query); |
|
| 281 | - $sth->execute(); |
|
| 282 | - } catch(PDOException $e) { |
|
| 283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
| 284 | - } |
|
| 285 | - if ($globalDBdriver == 'mysql') { |
|
| 286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 287 | - try { |
|
| 288 | - $sth = $Connection->db->prepare($query); |
|
| 289 | - $sth->execute(); |
|
| 290 | - } catch(PDOException $e) { |
|
| 279 | + try { |
|
| 280 | + $sth = $Connection->db->prepare($query); |
|
| 281 | + $sth->execute(); |
|
| 282 | + } catch(PDOException $e) { |
|
| 283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
| 284 | + } |
|
| 285 | + if ($globalDBdriver == 'mysql') { |
|
| 286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 287 | + try { |
|
| 288 | + $sth = $Connection->db->prepare($query); |
|
| 289 | + $sth->execute(); |
|
| 290 | + } catch(PDOException $e) { |
|
| 291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 292 | - } |
|
| 293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 294 | - if ($row['engine'] == 'ARCHIVE') { |
|
| 292 | + } |
|
| 293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 294 | + if ($row['engine'] == 'ARCHIVE') { |
|
| 295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
| 296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
| 297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
| 298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
| 299 | 299 | DROP TABLE spotter_archive; |
| 300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
| 301 | - } else { |
|
| 302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 303 | - } |
|
| 304 | - } else { |
|
| 305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 306 | - } |
|
| 307 | - try { |
|
| 308 | - $sth = $Connection->db->prepare($query); |
|
| 309 | - $sth->execute(); |
|
| 310 | - } catch(PDOException $e) { |
|
| 311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 312 | - } |
|
| 301 | + } else { |
|
| 302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 303 | + } |
|
| 304 | + } else { |
|
| 305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 306 | + } |
|
| 307 | + try { |
|
| 308 | + $sth = $Connection->db->prepare($query); |
|
| 309 | + $sth->execute(); |
|
| 310 | + } catch(PDOException $e) { |
|
| 311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $error = ''; |
|
| 315 | - // Update table aircraft |
|
| 314 | + $error = ''; |
|
| 315 | + // Update table aircraft |
|
| 316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
| 317 | 317 | if ($error != '') return $error; |
| 318 | 318 | // Update schema_version to 6 |
| 319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
| 320 | - try { |
|
| 321 | - $sth = $Connection->db->prepare($query); |
|
| 322 | - $sth->execute(); |
|
| 323 | - } catch(PDOException $e) { |
|
| 324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 325 | - } |
|
| 320 | + try { |
|
| 321 | + $sth = $Connection->db->prepare($query); |
|
| 322 | + $sth->execute(); |
|
| 323 | + } catch(PDOException $e) { |
|
| 324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 325 | + } |
|
| 326 | 326 | return $error; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | private static function update_from_8() { |
| 330 | - $Connection = new Connection(); |
|
| 331 | - $error = ''; |
|
| 332 | - // Update table aircraft |
|
| 330 | + $Connection = new Connection(); |
|
| 331 | + $error = ''; |
|
| 332 | + // Update table aircraft |
|
| 333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
| 334 | 334 | if ($error != '') return $error; |
| 335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
| 336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
| 337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
| 338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
| 339 | - try { |
|
| 340 | - $sth = $Connection->db->prepare($query); |
|
| 341 | - $sth->execute(); |
|
| 342 | - } catch(PDOException $e) { |
|
| 343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
| 344 | - } |
|
| 339 | + try { |
|
| 340 | + $sth = $Connection->db->prepare($query); |
|
| 341 | + $sth->execute(); |
|
| 342 | + } catch(PDOException $e) { |
|
| 343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
| 344 | + } |
|
| 345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
| 346 | - try { |
|
| 347 | - $sth = $Connection->db->prepare($query); |
|
| 348 | - $sth->execute(); |
|
| 349 | - } catch(PDOException $e) { |
|
| 350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 351 | - } |
|
| 346 | + try { |
|
| 347 | + $sth = $Connection->db->prepare($query); |
|
| 348 | + $sth->execute(); |
|
| 349 | + } catch(PDOException $e) { |
|
| 350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 351 | + } |
|
| 352 | 352 | return $error; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | private static function update_from_9() { |
| 356 | - $Connection = new Connection(); |
|
| 357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 356 | + $Connection = new Connection(); |
|
| 357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
| 359 | - try { |
|
| 360 | - $sth = $Connection->db->prepare($query); |
|
| 361 | - $sth->execute(); |
|
| 362 | - } catch(PDOException $e) { |
|
| 363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
| 364 | - } |
|
| 359 | + try { |
|
| 360 | + $sth = $Connection->db->prepare($query); |
|
| 361 | + $sth->execute(); |
|
| 362 | + } catch(PDOException $e) { |
|
| 363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
| 364 | + } |
|
| 365 | 365 | $error = ''; |
| 366 | - // Update table atc |
|
| 366 | + // Update table atc |
|
| 367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
| 368 | 368 | if ($error != '') return $error; |
| 369 | 369 | |
| 370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
| 371 | - try { |
|
| 372 | - $sth = $Connection->db->prepare($query); |
|
| 373 | - $sth->execute(); |
|
| 374 | - } catch(PDOException $e) { |
|
| 375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 376 | - } |
|
| 371 | + try { |
|
| 372 | + $sth = $Connection->db->prepare($query); |
|
| 373 | + $sth->execute(); |
|
| 374 | + } catch(PDOException $e) { |
|
| 375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 376 | + } |
|
| 377 | 377 | return $error; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | private static function update_from_10() { |
| 381 | - $Connection = new Connection(); |
|
| 382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 383 | - try { |
|
| 384 | - $sth = $Connection->db->prepare($query); |
|
| 385 | - $sth->execute(); |
|
| 386 | - } catch(PDOException $e) { |
|
| 387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
| 388 | - } |
|
| 381 | + $Connection = new Connection(); |
|
| 382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 383 | + try { |
|
| 384 | + $sth = $Connection->db->prepare($query); |
|
| 385 | + $sth->execute(); |
|
| 386 | + } catch(PDOException $e) { |
|
| 387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
| 388 | + } |
|
| 389 | 389 | $error = ''; |
| 390 | - // Add tables |
|
| 390 | + // Add tables |
|
| 391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
| 392 | 392 | if ($error != '') return $error; |
| 393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,75 +398,75 @@ discard block |
||
| 398 | 398 | if ($error != '') return $error; |
| 399 | 399 | |
| 400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
| 401 | - try { |
|
| 402 | - $sth = $Connection->db->prepare($query); |
|
| 403 | - $sth->execute(); |
|
| 404 | - } catch(PDOException $e) { |
|
| 405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 406 | - } |
|
| 401 | + try { |
|
| 402 | + $sth = $Connection->db->prepare($query); |
|
| 403 | + $sth->execute(); |
|
| 404 | + } catch(PDOException $e) { |
|
| 405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 406 | + } |
|
| 407 | 407 | return $error; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | private static function update_from_11() { |
| 411 | - $Connection = new Connection(); |
|
| 412 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 413 | - try { |
|
| 414 | - $sth = $Connection->db->prepare($query); |
|
| 415 | - $sth->execute(); |
|
| 416 | - } catch(PDOException $e) { |
|
| 417 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
| 418 | - } |
|
| 419 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 420 | - try { |
|
| 421 | - $sth = $Connection->db->prepare($query); |
|
| 422 | - $sth->execute(); |
|
| 423 | - } catch(PDOException $e) { |
|
| 424 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 425 | - } |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 427 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 428 | - try { |
|
| 429 | - $sth = $Connection->db->prepare($query); |
|
| 430 | - $sth->execute(); |
|
| 431 | - } catch(PDOException $e) { |
|
| 411 | + $Connection = new Connection(); |
|
| 412 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 413 | + try { |
|
| 414 | + $sth = $Connection->db->prepare($query); |
|
| 415 | + $sth->execute(); |
|
| 416 | + } catch(PDOException $e) { |
|
| 417 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
| 418 | + } |
|
| 419 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 420 | + try { |
|
| 421 | + $sth = $Connection->db->prepare($query); |
|
| 422 | + $sth->execute(); |
|
| 423 | + } catch(PDOException $e) { |
|
| 424 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 425 | + } |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 428 | + try { |
|
| 429 | + $sth = $Connection->db->prepare($query); |
|
| 430 | + $sth->execute(); |
|
| 431 | + } catch(PDOException $e) { |
|
| 432 | 432 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 433 | - } |
|
| 434 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 435 | - if ($row['engine'] == 'ARCHIVE') { |
|
| 433 | + } |
|
| 434 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 435 | + if ($row['engine'] == 'ARCHIVE') { |
|
| 436 | 436 | $query = "CREATE TABLE copy LIKE spotter_archive; |
| 437 | 437 | ALTER TABLE copy ENGINE=ARCHIVE; |
| 438 | 438 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
| 439 | 439 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
| 440 | 440 | DROP TABLE spotter_archive; |
| 441 | 441 | RENAME TABLE copy TO spotter_archive;"; |
| 442 | - } else { |
|
| 443 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 444 | - } |
|
| 445 | - } else { |
|
| 446 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 447 | - } |
|
| 448 | - try { |
|
| 449 | - $sth = $Connection->db->prepare($query); |
|
| 450 | - $sth->execute(); |
|
| 451 | - } catch(PDOException $e) { |
|
| 452 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 453 | - } |
|
| 442 | + } else { |
|
| 443 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 447 | + } |
|
| 448 | + try { |
|
| 449 | + $sth = $Connection->db->prepare($query); |
|
| 450 | + $sth->execute(); |
|
| 451 | + } catch(PDOException $e) { |
|
| 452 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | $error = ''; |
| 456 | 456 | |
| 457 | 457 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
| 458 | - try { |
|
| 459 | - $sth = $Connection->db->prepare($query); |
|
| 460 | - $sth->execute(); |
|
| 461 | - } catch(PDOException $e) { |
|
| 462 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 463 | - } |
|
| 458 | + try { |
|
| 459 | + $sth = $Connection->db->prepare($query); |
|
| 460 | + $sth->execute(); |
|
| 461 | + } catch(PDOException $e) { |
|
| 462 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 463 | + } |
|
| 464 | 464 | return $error; |
| 465 | 465 | } |
| 466 | 466 | private static function update_from_12() { |
| 467 | - $Connection = new Connection(); |
|
| 467 | + $Connection = new Connection(); |
|
| 468 | 468 | $error = ''; |
| 469 | - // Add tables |
|
| 469 | + // Add tables |
|
| 470 | 470 | $error .= create_db::import_file('../db/stats.sql'); |
| 471 | 471 | if ($error != '') return $error; |
| 472 | 472 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -483,188 +483,188 @@ discard block |
||
| 483 | 483 | if ($error != '') return $error; |
| 484 | 484 | |
| 485 | 485 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
| 486 | - try { |
|
| 487 | - $sth = $Connection->db->prepare($query); |
|
| 488 | - $sth->execute(); |
|
| 489 | - } catch(PDOException $e) { |
|
| 490 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 491 | - } |
|
| 486 | + try { |
|
| 487 | + $sth = $Connection->db->prepare($query); |
|
| 488 | + $sth->execute(); |
|
| 489 | + } catch(PDOException $e) { |
|
| 490 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 491 | + } |
|
| 492 | 492 | return $error; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | private static function update_from_13() { |
| 496 | - $Connection = new Connection(); |
|
| 497 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 498 | - try { |
|
| 499 | - $sth = $Connection->db->prepare($query); |
|
| 500 | - $sth->execute(); |
|
| 501 | - } catch(PDOException $e) { |
|
| 502 | - return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
|
| 503 | - } |
|
| 496 | + $Connection = new Connection(); |
|
| 497 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 498 | + try { |
|
| 499 | + $sth = $Connection->db->prepare($query); |
|
| 500 | + $sth->execute(); |
|
| 501 | + } catch(PDOException $e) { |
|
| 502 | + return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - $error = ''; |
|
| 505 | + $error = ''; |
|
| 506 | 506 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
| 507 | - try { |
|
| 508 | - $sth = $Connection->db->prepare($query); |
|
| 509 | - $sth->execute(); |
|
| 510 | - } catch(PDOException $e) { |
|
| 511 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 512 | - } |
|
| 507 | + try { |
|
| 508 | + $sth = $Connection->db->prepare($query); |
|
| 509 | + $sth->execute(); |
|
| 510 | + } catch(PDOException $e) { |
|
| 511 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 512 | + } |
|
| 513 | 513 | return $error; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | private static function update_from_14() { |
| 517 | - $Connection = new Connection(); |
|
| 517 | + $Connection = new Connection(); |
|
| 518 | 518 | $error = ''; |
| 519 | - // Add tables |
|
| 519 | + // Add tables |
|
| 520 | 520 | $error .= create_db::import_file('../db/stats_flight.sql'); |
| 521 | 521 | if ($error != '') return $error; |
| 522 | 522 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
| 523 | - try { |
|
| 524 | - $sth = $Connection->db->prepare($query); |
|
| 525 | - $sth->execute(); |
|
| 526 | - } catch(PDOException $e) { |
|
| 527 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 528 | - } |
|
| 523 | + try { |
|
| 524 | + $sth = $Connection->db->prepare($query); |
|
| 525 | + $sth->execute(); |
|
| 526 | + } catch(PDOException $e) { |
|
| 527 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 528 | + } |
|
| 529 | 529 | return $error; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | private static function update_from_15() { |
| 534 | - $Connection = new Connection(); |
|
| 534 | + $Connection = new Connection(); |
|
| 535 | 535 | $error = ''; |
| 536 | - // Add tables |
|
| 537 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 538 | - try { |
|
| 539 | - $sth = $Connection->db->prepare($query); |
|
| 540 | - $sth->execute(); |
|
| 541 | - } catch(PDOException $e) { |
|
| 542 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 543 | - } |
|
| 536 | + // Add tables |
|
| 537 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 538 | + try { |
|
| 539 | + $sth = $Connection->db->prepare($query); |
|
| 540 | + $sth->execute(); |
|
| 541 | + } catch(PDOException $e) { |
|
| 542 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 543 | + } |
|
| 544 | 544 | if ($error != '') return $error; |
| 545 | 545 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 546 | - try { |
|
| 547 | - $sth = $Connection->db->prepare($query); |
|
| 548 | - $sth->execute(); |
|
| 549 | - } catch(PDOException $e) { |
|
| 550 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 551 | - } |
|
| 546 | + try { |
|
| 547 | + $sth = $Connection->db->prepare($query); |
|
| 548 | + $sth->execute(); |
|
| 549 | + } catch(PDOException $e) { |
|
| 550 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 551 | + } |
|
| 552 | 552 | return $error; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | private static function update_from_16() { |
| 556 | - $Connection = new Connection(); |
|
| 556 | + $Connection = new Connection(); |
|
| 557 | 557 | $error = ''; |
| 558 | - // Add tables |
|
| 558 | + // Add tables |
|
| 559 | 559 | $error .= create_db::import_file('../db/stats_registration.sql'); |
| 560 | 560 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
| 561 | 561 | if ($error != '') return $error; |
| 562 | 562 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
| 563 | - try { |
|
| 564 | - $sth = $Connection->db->prepare($query); |
|
| 565 | - $sth->execute(); |
|
| 566 | - } catch(PDOException $e) { |
|
| 567 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 568 | - } |
|
| 563 | + try { |
|
| 564 | + $sth = $Connection->db->prepare($query); |
|
| 565 | + $sth->execute(); |
|
| 566 | + } catch(PDOException $e) { |
|
| 567 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 568 | + } |
|
| 569 | 569 | return $error; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | private static function update_from_17() { |
| 573 | - $Connection = new Connection(); |
|
| 573 | + $Connection = new Connection(); |
|
| 574 | 574 | $error = ''; |
| 575 | - // Add tables |
|
| 575 | + // Add tables |
|
| 576 | 576 | $error .= create_db::import_file('../db/stats_country.sql'); |
| 577 | 577 | if ($error != '') return $error; |
| 578 | 578 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
| 579 | - try { |
|
| 580 | - $sth = $Connection->db->prepare($query); |
|
| 581 | - $sth->execute(); |
|
| 582 | - } catch(PDOException $e) { |
|
| 583 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 584 | - } |
|
| 579 | + try { |
|
| 580 | + $sth = $Connection->db->prepare($query); |
|
| 581 | + $sth->execute(); |
|
| 582 | + } catch(PDOException $e) { |
|
| 583 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 584 | + } |
|
| 585 | 585 | return $error; |
| 586 | 586 | } |
| 587 | 587 | private static function update_from_18() { |
| 588 | - $Connection = new Connection(); |
|
| 588 | + $Connection = new Connection(); |
|
| 589 | 589 | $error = ''; |
| 590 | - // Modify stats_airport table |
|
| 591 | - $query = "ALTER TABLE `stats_airport` ADD `type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
| 592 | - try { |
|
| 593 | - $sth = $Connection->db->prepare($query); |
|
| 594 | - $sth->execute(); |
|
| 595 | - } catch(PDOException $e) { |
|
| 596 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 597 | - } |
|
| 590 | + // Modify stats_airport table |
|
| 591 | + $query = "ALTER TABLE `stats_airport` ADD `type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
| 592 | + try { |
|
| 593 | + $sth = $Connection->db->prepare($query); |
|
| 594 | + $sth->execute(); |
|
| 595 | + } catch(PDOException $e) { |
|
| 596 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 597 | + } |
|
| 598 | 598 | if ($error != '') return $error; |
| 599 | 599 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 600 | - try { |
|
| 601 | - $sth = $Connection->db->prepare($query); |
|
| 602 | - $sth->execute(); |
|
| 603 | - } catch(PDOException $e) { |
|
| 604 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 605 | - } |
|
| 600 | + try { |
|
| 601 | + $sth = $Connection->db->prepare($query); |
|
| 602 | + $sth->execute(); |
|
| 603 | + } catch(PDOException $e) { |
|
| 604 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 605 | + } |
|
| 606 | 606 | return $error; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | private static function update_from_19() { |
| 610 | - $Connection = new Connection(); |
|
| 610 | + $Connection = new Connection(); |
|
| 611 | 611 | $error = ''; |
| 612 | - // Update airport table |
|
| 612 | + // Update airport table |
|
| 613 | 613 | $error .= create_db::import_file('../db/airport.sql'); |
| 614 | 614 | if ($error != '') return 'Import airport.sql : '.$error; |
| 615 | 615 | // Remove primary key on Spotter_Archive |
| 616 | 616 | $query = "alter table spotter_archive drop column spotter_archive_id, add spotter_archive_id INT(11)"; |
| 617 | - try { |
|
| 618 | - $sth = $Connection->db->prepare($query); |
|
| 619 | - $sth->execute(); |
|
| 620 | - } catch(PDOException $e) { |
|
| 621 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 622 | - } |
|
| 617 | + try { |
|
| 618 | + $sth = $Connection->db->prepare($query); |
|
| 619 | + $sth->execute(); |
|
| 620 | + } catch(PDOException $e) { |
|
| 621 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - // Add column over_country |
|
| 625 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL;ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL;"; |
|
| 626 | - try { |
|
| 627 | - $sth = $Connection->db->prepare($query); |
|
| 628 | - $sth->execute(); |
|
| 629 | - } catch(PDOException $e) { |
|
| 630 | - return "error (add over_country) : ".$e->getMessage()."\n"; |
|
| 631 | - } |
|
| 632 | - // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
|
| 633 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
| 634 | - try { |
|
| 635 | - $sth = $Connection->db->prepare($query); |
|
| 636 | - $sth->execute(); |
|
| 637 | - } catch(PDOException $e) { |
|
| 638 | - return "error (add source_name column) : ".$e->getMessage()."\n"; |
|
| 639 | - } |
|
| 624 | + // Add column over_country |
|
| 625 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL;ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL;"; |
|
| 626 | + try { |
|
| 627 | + $sth = $Connection->db->prepare($query); |
|
| 628 | + $sth->execute(); |
|
| 629 | + } catch(PDOException $e) { |
|
| 630 | + return "error (add over_country) : ".$e->getMessage()."\n"; |
|
| 631 | + } |
|
| 632 | + // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
|
| 633 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
| 634 | + try { |
|
| 635 | + $sth = $Connection->db->prepare($query); |
|
| 636 | + $sth->execute(); |
|
| 637 | + } catch(PDOException $e) { |
|
| 638 | + return "error (add source_name column) : ".$e->getMessage()."\n"; |
|
| 639 | + } |
|
| 640 | 640 | if ($error != '') return $error; |
| 641 | 641 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
| 642 | - try { |
|
| 643 | - $sth = $Connection->db->prepare($query); |
|
| 644 | - $sth->execute(); |
|
| 645 | - } catch(PDOException $e) { |
|
| 646 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 647 | - } |
|
| 642 | + try { |
|
| 643 | + $sth = $Connection->db->prepare($query); |
|
| 644 | + $sth->execute(); |
|
| 645 | + } catch(PDOException $e) { |
|
| 646 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 647 | + } |
|
| 648 | 648 | return $error; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | private static function update_from_20() { |
| 652 | 652 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
| 653 | - $Connection = new Connection(); |
|
| 653 | + $Connection = new Connection(); |
|
| 654 | 654 | $error = ''; |
| 655 | - // Update airline table |
|
| 656 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
| 655 | + // Update airline table |
|
| 656 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
| 657 | 657 | $error .= create_db::import_file('../db/airlines.sql'); |
| 658 | 658 | if ($error != '') return 'Import airlinesport.sql : '.$error; |
| 659 | 659 | } |
| 660 | - // Add column over_country |
|
| 661 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
| 662 | - try { |
|
| 663 | - $sth = $Connection->db->prepare($query); |
|
| 664 | - $sth->execute(); |
|
| 665 | - } catch(PDOException $e) { |
|
| 666 | - return "error (add over_country) : ".$e->getMessage()."\n"; |
|
| 667 | - } |
|
| 660 | + // Add column over_country |
|
| 661 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
| 662 | + try { |
|
| 663 | + $sth = $Connection->db->prepare($query); |
|
| 664 | + $sth->execute(); |
|
| 665 | + } catch(PDOException $e) { |
|
| 666 | + return "error (add over_country) : ".$e->getMessage()."\n"; |
|
| 667 | + } |
|
| 668 | 668 | if ($error != '') return $error; |
| 669 | 669 | /* |
| 670 | 670 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -674,40 +674,40 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | */ |
| 676 | 676 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
| 677 | - try { |
|
| 678 | - $sth = $Connection->db->prepare($query); |
|
| 679 | - $sth->execute(); |
|
| 680 | - } catch(PDOException $e) { |
|
| 681 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 682 | - } |
|
| 677 | + try { |
|
| 678 | + $sth = $Connection->db->prepare($query); |
|
| 679 | + $sth->execute(); |
|
| 680 | + } catch(PDOException $e) { |
|
| 681 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 682 | + } |
|
| 683 | 683 | return $error; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | private static function update_from_21() { |
| 687 | - $Connection = new Connection(); |
|
| 687 | + $Connection = new Connection(); |
|
| 688 | 688 | $error = ''; |
| 689 | 689 | // Rename type to stats_type |
| 690 | 690 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
| 691 | - try { |
|
| 692 | - $sth = $Connection->db->prepare($query); |
|
| 693 | - $sth->execute(); |
|
| 694 | - } catch(PDOException $e) { |
|
| 695 | - return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
|
| 696 | - } |
|
| 691 | + try { |
|
| 692 | + $sth = $Connection->db->prepare($query); |
|
| 693 | + $sth->execute(); |
|
| 694 | + } catch(PDOException $e) { |
|
| 695 | + return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
|
| 696 | + } |
|
| 697 | 697 | if ($error != '') return $error; |
| 698 | 698 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 699 | - try { |
|
| 700 | - $sth = $Connection->db->prepare($query); |
|
| 701 | - $sth->execute(); |
|
| 702 | - } catch(PDOException $e) { |
|
| 703 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 704 | - } |
|
| 699 | + try { |
|
| 700 | + $sth = $Connection->db->prepare($query); |
|
| 701 | + $sth->execute(); |
|
| 702 | + } catch(PDOException $e) { |
|
| 703 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 704 | + } |
|
| 705 | 705 | return $error; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | private static function update_from_22() { |
| 709 | 709 | global $globalDBdriver; |
| 710 | - $Connection = new Connection(); |
|
| 710 | + $Connection = new Connection(); |
|
| 711 | 711 | $error = ''; |
| 712 | 712 | // Add table stats polar |
| 713 | 713 | if ($globalDBdriver == 'mysql') { |
@@ -717,128 +717,128 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | if ($error != '') return $error; |
| 719 | 719 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
| 720 | - try { |
|
| 721 | - $sth = $Connection->db->prepare($query); |
|
| 722 | - $sth->execute(); |
|
| 723 | - } catch(PDOException $e) { |
|
| 724 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 725 | - } |
|
| 720 | + try { |
|
| 721 | + $sth = $Connection->db->prepare($query); |
|
| 722 | + $sth->execute(); |
|
| 723 | + } catch(PDOException $e) { |
|
| 724 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 725 | + } |
|
| 726 | 726 | return $error; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
| 730 | 730 | |
| 731 | - public static function check_version($update = false) { |
|
| 732 | - global $globalDBname; |
|
| 733 | - $version = 0; |
|
| 734 | - $Connection = new Connection(); |
|
| 735 | - if ($Connection->tableExists('aircraft')) { |
|
| 736 | - if (!$Connection->tableExists('config')) { |
|
| 737 | - $version = '1'; |
|
| 738 | - if ($update) return self::update_from_1(); |
|
| 739 | - else return $version; |
|
| 731 | + public static function check_version($update = false) { |
|
| 732 | + global $globalDBname; |
|
| 733 | + $version = 0; |
|
| 734 | + $Connection = new Connection(); |
|
| 735 | + if ($Connection->tableExists('aircraft')) { |
|
| 736 | + if (!$Connection->tableExists('config')) { |
|
| 737 | + $version = '1'; |
|
| 738 | + if ($update) return self::update_from_1(); |
|
| 739 | + else return $version; |
|
| 740 | 740 | } else { |
| 741 | - $Connection = new Connection(); |
|
| 742 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
| 743 | - try { |
|
| 744 | - $sth = $Connection->db->prepare($query); |
|
| 745 | - $sth->execute(); |
|
| 746 | - } catch(PDOException $e) { |
|
| 741 | + $Connection = new Connection(); |
|
| 742 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
| 743 | + try { |
|
| 744 | + $sth = $Connection->db->prepare($query); |
|
| 745 | + $sth->execute(); |
|
| 746 | + } catch(PDOException $e) { |
|
| 747 | 747 | return "error : ".$e->getMessage()."\n"; |
| 748 | - } |
|
| 749 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 750 | - if ($update) { |
|
| 751 | - if ($result['value'] == '2') { |
|
| 752 | - $error = self::update_from_2(); |
|
| 753 | - if ($error != '') return $error; |
|
| 754 | - else return self::check_version(true); |
|
| 755 | - } elseif ($result['value'] == '3') { |
|
| 756 | - $error = self::update_from_3(); |
|
| 757 | - if ($error != '') return $error; |
|
| 758 | - else return self::check_version(true); |
|
| 759 | - } elseif ($result['value'] == '4') { |
|
| 760 | - $error = self::update_from_4(); |
|
| 761 | - if ($error != '') return $error; |
|
| 762 | - else return self::check_version(true); |
|
| 763 | - } elseif ($result['value'] == '5') { |
|
| 764 | - $error = self::update_from_5(); |
|
| 765 | - if ($error != '') return $error; |
|
| 766 | - else return self::check_version(true); |
|
| 767 | - } elseif ($result['value'] == '6') { |
|
| 768 | - $error = self::update_from_6(); |
|
| 769 | - if ($error != '') return $error; |
|
| 770 | - else return self::check_version(true); |
|
| 771 | - } elseif ($result['value'] == '7') { |
|
| 772 | - $error = self::update_from_7(); |
|
| 773 | - if ($error != '') return $error; |
|
| 774 | - else return self::check_version(true); |
|
| 775 | - } elseif ($result['value'] == '8') { |
|
| 776 | - $error = self::update_from_8(); |
|
| 777 | - if ($error != '') return $error; |
|
| 778 | - else return self::check_version(true); |
|
| 779 | - } elseif ($result['value'] == '9') { |
|
| 780 | - $error = self::update_from_9(); |
|
| 781 | - if ($error != '') return $error; |
|
| 782 | - else return self::check_version(true); |
|
| 783 | - } elseif ($result['value'] == '10') { |
|
| 784 | - $error = self::update_from_10(); |
|
| 785 | - if ($error != '') return $error; |
|
| 786 | - else return self::check_version(true); |
|
| 787 | - } elseif ($result['value'] == '11') { |
|
| 788 | - $error = self::update_from_11(); |
|
| 789 | - if ($error != '') return $error; |
|
| 790 | - else return self::check_version(true); |
|
| 791 | - } elseif ($result['value'] == '12') { |
|
| 792 | - $error = self::update_from_12(); |
|
| 793 | - if ($error != '') return $error; |
|
| 794 | - else return self::check_version(true); |
|
| 795 | - } elseif ($result['value'] == '13') { |
|
| 796 | - $error = self::update_from_13(); |
|
| 797 | - if ($error != '') return $error; |
|
| 798 | - else return self::check_version(true); |
|
| 799 | - } elseif ($result['value'] == '14') { |
|
| 800 | - $error = self::update_from_14(); |
|
| 801 | - if ($error != '') return $error; |
|
| 802 | - else return self::check_version(true); |
|
| 803 | - } elseif ($result['value'] == '15') { |
|
| 804 | - $error = self::update_from_15(); |
|
| 805 | - if ($error != '') return $error; |
|
| 806 | - else return self::check_version(true); |
|
| 807 | - } elseif ($result['value'] == '16') { |
|
| 808 | - $error = self::update_from_16(); |
|
| 809 | - if ($error != '') return $error; |
|
| 810 | - else return self::check_version(true); |
|
| 811 | - } elseif ($result['value'] == '17') { |
|
| 812 | - $error = self::update_from_17(); |
|
| 813 | - if ($error != '') return $error; |
|
| 814 | - else return self::check_version(true); |
|
| 815 | - } elseif ($result['value'] == '18') { |
|
| 816 | - $error = self::update_from_18(); |
|
| 817 | - if ($error != '') return $error; |
|
| 818 | - else return self::check_version(true); |
|
| 819 | - } elseif ($result['value'] == '19') { |
|
| 820 | - $error = self::update_from_19(); |
|
| 821 | - if ($error != '') return $error; |
|
| 822 | - else return self::check_version(true); |
|
| 823 | - } elseif ($result['value'] == '20') { |
|
| 824 | - $error = self::update_from_20(); |
|
| 825 | - if ($error != '') return $error; |
|
| 826 | - else return self::check_version(true); |
|
| 827 | - } elseif ($result['value'] == '21') { |
|
| 828 | - $error = self::update_from_21(); |
|
| 829 | - if ($error != '') return $error; |
|
| 830 | - else return self::check_version(true); |
|
| 831 | - } elseif ($result['value'] == '22') { |
|
| 832 | - $error = self::update_from_22(); |
|
| 833 | - if ($error != '') return $error; |
|
| 834 | - else return self::check_version(true); |
|
| 835 | - } else return ''; |
|
| 836 | - } |
|
| 837 | - else return $result['value']; |
|
| 748 | + } |
|
| 749 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 750 | + if ($update) { |
|
| 751 | + if ($result['value'] == '2') { |
|
| 752 | + $error = self::update_from_2(); |
|
| 753 | + if ($error != '') return $error; |
|
| 754 | + else return self::check_version(true); |
|
| 755 | + } elseif ($result['value'] == '3') { |
|
| 756 | + $error = self::update_from_3(); |
|
| 757 | + if ($error != '') return $error; |
|
| 758 | + else return self::check_version(true); |
|
| 759 | + } elseif ($result['value'] == '4') { |
|
| 760 | + $error = self::update_from_4(); |
|
| 761 | + if ($error != '') return $error; |
|
| 762 | + else return self::check_version(true); |
|
| 763 | + } elseif ($result['value'] == '5') { |
|
| 764 | + $error = self::update_from_5(); |
|
| 765 | + if ($error != '') return $error; |
|
| 766 | + else return self::check_version(true); |
|
| 767 | + } elseif ($result['value'] == '6') { |
|
| 768 | + $error = self::update_from_6(); |
|
| 769 | + if ($error != '') return $error; |
|
| 770 | + else return self::check_version(true); |
|
| 771 | + } elseif ($result['value'] == '7') { |
|
| 772 | + $error = self::update_from_7(); |
|
| 773 | + if ($error != '') return $error; |
|
| 774 | + else return self::check_version(true); |
|
| 775 | + } elseif ($result['value'] == '8') { |
|
| 776 | + $error = self::update_from_8(); |
|
| 777 | + if ($error != '') return $error; |
|
| 778 | + else return self::check_version(true); |
|
| 779 | + } elseif ($result['value'] == '9') { |
|
| 780 | + $error = self::update_from_9(); |
|
| 781 | + if ($error != '') return $error; |
|
| 782 | + else return self::check_version(true); |
|
| 783 | + } elseif ($result['value'] == '10') { |
|
| 784 | + $error = self::update_from_10(); |
|
| 785 | + if ($error != '') return $error; |
|
| 786 | + else return self::check_version(true); |
|
| 787 | + } elseif ($result['value'] == '11') { |
|
| 788 | + $error = self::update_from_11(); |
|
| 789 | + if ($error != '') return $error; |
|
| 790 | + else return self::check_version(true); |
|
| 791 | + } elseif ($result['value'] == '12') { |
|
| 792 | + $error = self::update_from_12(); |
|
| 793 | + if ($error != '') return $error; |
|
| 794 | + else return self::check_version(true); |
|
| 795 | + } elseif ($result['value'] == '13') { |
|
| 796 | + $error = self::update_from_13(); |
|
| 797 | + if ($error != '') return $error; |
|
| 798 | + else return self::check_version(true); |
|
| 799 | + } elseif ($result['value'] == '14') { |
|
| 800 | + $error = self::update_from_14(); |
|
| 801 | + if ($error != '') return $error; |
|
| 802 | + else return self::check_version(true); |
|
| 803 | + } elseif ($result['value'] == '15') { |
|
| 804 | + $error = self::update_from_15(); |
|
| 805 | + if ($error != '') return $error; |
|
| 806 | + else return self::check_version(true); |
|
| 807 | + } elseif ($result['value'] == '16') { |
|
| 808 | + $error = self::update_from_16(); |
|
| 809 | + if ($error != '') return $error; |
|
| 810 | + else return self::check_version(true); |
|
| 811 | + } elseif ($result['value'] == '17') { |
|
| 812 | + $error = self::update_from_17(); |
|
| 813 | + if ($error != '') return $error; |
|
| 814 | + else return self::check_version(true); |
|
| 815 | + } elseif ($result['value'] == '18') { |
|
| 816 | + $error = self::update_from_18(); |
|
| 817 | + if ($error != '') return $error; |
|
| 818 | + else return self::check_version(true); |
|
| 819 | + } elseif ($result['value'] == '19') { |
|
| 820 | + $error = self::update_from_19(); |
|
| 821 | + if ($error != '') return $error; |
|
| 822 | + else return self::check_version(true); |
|
| 823 | + } elseif ($result['value'] == '20') { |
|
| 824 | + $error = self::update_from_20(); |
|
| 825 | + if ($error != '') return $error; |
|
| 826 | + else return self::check_version(true); |
|
| 827 | + } elseif ($result['value'] == '21') { |
|
| 828 | + $error = self::update_from_21(); |
|
| 829 | + if ($error != '') return $error; |
|
| 830 | + else return self::check_version(true); |
|
| 831 | + } elseif ($result['value'] == '22') { |
|
| 832 | + $error = self::update_from_22(); |
|
| 833 | + if ($error != '') return $error; |
|
| 834 | + else return self::check_version(true); |
|
| 835 | + } else return ''; |
|
| 836 | + } |
|
| 837 | + else return $result['value']; |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - } else return $version; |
|
| 841 | - } |
|
| 840 | + } else return $version; |
|
| 841 | + } |
|
| 842 | 842 | |
| 843 | 843 | } |
| 844 | 844 | //echo update_schema::check_version(); |
@@ -1,30 +1,30 @@ |
||
| 1 | 1 | #!/usr/bin/php |
| 2 | 2 | <?php |
| 3 | - require_once('../require/settings.php'); |
|
| 4 | - if ($globalInstalled) { |
|
| 5 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | - exit; |
|
| 7 | - } |
|
| 8 | - require('class.create_db.php'); |
|
| 9 | - echo "Create and import all tables..."; |
|
| 10 | - create_db::import_all_db('../db/'); |
|
| 11 | - echo "Done !\n"; |
|
| 3 | + require_once('../require/settings.php'); |
|
| 4 | + if ($globalInstalled) { |
|
| 5 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | + exit; |
|
| 7 | + } |
|
| 8 | + require('class.create_db.php'); |
|
| 9 | + echo "Create and import all tables..."; |
|
| 10 | + create_db::import_all_db('../db/'); |
|
| 11 | + echo "Done !\n"; |
|
| 12 | 12 | |
| 13 | - require('class.update_db.php'); |
|
| 14 | - echo "Populate all tables...\n"; |
|
| 15 | - update_db::update_all(); |
|
| 16 | - echo "\nInstall waypoints...(VERY slow!)"; |
|
| 17 | - update_db::update_waypoints(); |
|
| 18 | - echo "Done !\n"; |
|
| 19 | - echo "Install airspace..."; |
|
| 20 | - update_db::update_airspace(); |
|
| 21 | - echo "Done !\n"; |
|
| 22 | - echo 'All is now installed ! Thanks'."\n"; |
|
| 23 | - if ($globalSBS1) { |
|
| 24 | - echo 'You need to run cron-sbs.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
| 25 | - } |
|
| 26 | - if ($globalACARS) { |
|
| 27 | - echo 'You need to run cron-acars.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
| 28 | - } |
|
| 13 | + require('class.update_db.php'); |
|
| 14 | + echo "Populate all tables...\n"; |
|
| 15 | + update_db::update_all(); |
|
| 16 | + echo "\nInstall waypoints...(VERY slow!)"; |
|
| 17 | + update_db::update_waypoints(); |
|
| 18 | + echo "Done !\n"; |
|
| 19 | + echo "Install airspace..."; |
|
| 20 | + update_db::update_airspace(); |
|
| 21 | + echo "Done !\n"; |
|
| 22 | + echo 'All is now installed ! Thanks'."\n"; |
|
| 23 | + if ($globalSBS1) { |
|
| 24 | + echo 'You need to run cron-sbs.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
| 25 | + } |
|
| 26 | + if ($globalACARS) { |
|
| 27 | + echo 'You need to run cron-acars.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | ?> |
| 31 | 31 | \ No newline at end of file |
@@ -1,37 +1,37 @@ |
||
| 1 | 1 | #!/usr/bin/php |
| 2 | 2 | <?php |
| 3 | - require_once('../require/settings.php'); |
|
| 4 | - if ($globalInstalled) { |
|
| 5 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | - exit; |
|
| 7 | - } |
|
| 8 | - require('class.update_db.php'); |
|
| 9 | - echo "Populate all tables...\n"; |
|
| 10 | - update_db::update_all(); |
|
| 11 | - echo "\nInstall waypoints...(VERY slow!)"; |
|
| 12 | - update_db::update_waypoints(); |
|
| 13 | - echo "Done !\n"; |
|
| 14 | - echo "Install airspace..."; |
|
| 15 | - update_db::update_airspace(); |
|
| 16 | - echo "Done !\n"; |
|
| 17 | - echo "Install countries..."; |
|
| 18 | - update_db::update_countries(); |
|
| 19 | - echo "Done !\n"; |
|
| 20 | - if (isset($globalOwner) && $globalOwner) { |
|
| 3 | + require_once('../require/settings.php'); |
|
| 4 | + if ($globalInstalled) { |
|
| 5 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | + exit; |
|
| 7 | + } |
|
| 8 | + require('class.update_db.php'); |
|
| 9 | + echo "Populate all tables...\n"; |
|
| 10 | + update_db::update_all(); |
|
| 11 | + echo "\nInstall waypoints...(VERY slow!)"; |
|
| 12 | + update_db::update_waypoints(); |
|
| 13 | + echo "Done !\n"; |
|
| 14 | + echo "Install airspace..."; |
|
| 15 | + update_db::update_airspace(); |
|
| 16 | + echo "Done !\n"; |
|
| 17 | + echo "Install countries..."; |
|
| 18 | + update_db::update_countries(); |
|
| 19 | + echo "Done !\n"; |
|
| 20 | + if (isset($globalOwner) && $globalOwner) { |
|
| 21 | 21 | echo "Install private owners..."; |
| 22 | 22 | update_db::update_owner(); |
| 23 | - echo "Done !\n"; |
|
| 24 | - } |
|
| 25 | - /* |
|
| 23 | + echo "Done !\n"; |
|
| 24 | + } |
|
| 25 | + /* |
|
| 26 | 26 | if (isset($globalIVAO) && $globalIVAO) { |
| 27 | 27 | echo "Install IVAO airlines and logos..."; |
| 28 | 28 | update_db::update_IVAO(); |
| 29 | 29 | echo "Done !\n"; |
| 30 | 30 | } |
| 31 | 31 | */ |
| 32 | - if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
| 32 | + if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
| 33 | 33 | echo "Install NOTAM from notaminfo.com..."; |
| 34 | - update_db:update_notam(); |
|
| 35 | - echo "Done !\n"; |
|
| 36 | - } |
|
| 34 | + update_db:update_notam(); |
|
| 35 | + echo "Done !\n"; |
|
| 36 | + } |
|
| 37 | 37 | ?> |
| 38 | 38 | \ No newline at end of file |
@@ -1,23 +1,23 @@ |
||
| 1 | 1 | #!/usr/bin/php |
| 2 | 2 | <?php |
| 3 | - require_once('../require/settings.php'); |
|
| 4 | - if ($globalInstalled) { |
|
| 5 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | - exit; |
|
| 7 | - } |
|
| 8 | - require('class.update_db.php'); |
|
| 9 | - if (isset($globalVATSIM) && $globalVATSIM) { |
|
| 3 | + require_once('../require/settings.php'); |
|
| 4 | + if ($globalInstalled) { |
|
| 5 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 6 | + exit; |
|
| 7 | + } |
|
| 8 | + require('class.update_db.php'); |
|
| 9 | + if (isset($globalVATSIM) && $globalVATSIM) { |
|
| 10 | 10 | echo "Install VATSIM airlines..."; |
| 11 | 11 | update_db::update_vatsim(); |
| 12 | 12 | echo "Done !\n"; |
| 13 | - } |
|
| 14 | - if (isset($globalIVAO) && $globalIVAO) { |
|
| 13 | + } |
|
| 14 | + if (isset($globalIVAO) && $globalIVAO) { |
|
| 15 | 15 | if (!file_exists('tmp/ivae_feb2013.zip')) { |
| 16 | 16 | echo "You have to download the file ivae_feb2013.zip from https://www.ivao.aero/softdev/mirrors.asp?software=IvAeDataUp and put it in install/tmp directory"; |
| 17 | 17 | } else { |
| 18 | - echo "Install IVAO airlines and logos..."; |
|
| 19 | - update_db::update_IVAO(); |
|
| 18 | + echo "Install IVAO airlines and logos..."; |
|
| 19 | + update_db::update_IVAO(); |
|
| 20 | 20 | echo "Done !\n"; |
| 21 | 21 | } |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | ?> |
| 24 | 24 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | <meta property="og:site_name" content="<?php print $globalName; ?>"/> |
| 40 | 40 | |
| 41 | 41 | <?php |
| 42 | - if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
| 42 | + if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
| 43 | 43 | ?> |
| 44 | 44 | <script language="JavaScript" type="text/javascript"> |
| 45 | 45 | function datasource_js() { |
@@ -120,22 +120,22 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | </script> |
| 122 | 122 | <?php |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | ?> |
| 125 | 125 | |
| 126 | 126 | </head> |
| 127 | 127 | |
| 128 | 128 | <?php |
| 129 | - if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
| 129 | + if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
| 130 | 130 | ?> |
| 131 | 131 | |
| 132 | 132 | <body class="page-<?php print strtolower($current_page); ?>" onload="datasource_js(); metarcycle_js(); create_database_js(); daemon_js(); schedule_js()"> |
| 133 | 133 | <?php |
| 134 | - } else { |
|
| 134 | + } else { |
|
| 135 | 135 | ?> |
| 136 | 136 | <body class="page-<?php print strtolower($current_page); ?>"> |
| 137 | 137 | <?php |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | ?> |
| 140 | 140 | <div class="navbar navbar-fixed-top" role="navigation"> |
| 141 | 141 | <div class="container"> |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | <?php |
| 156 | 156 | if (isset($top_header)) { |
| 157 | - if ($top_header != "") |
|
| 158 | - { |
|
| 157 | + if ($top_header != "") |
|
| 158 | + { |
|
| 159 | 159 | print '<div class="top-header container clear" role="main">'; |
| 160 | 160 | print '<img src="../images/'.$top_header.'" alt="'.$title.'" title="'.$title.'" />'; |
| 161 | 161 | print '</div>'; |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | ?> |
| 165 | 165 | |
@@ -6,27 +6,27 @@ discard block |
||
| 6 | 6 | public static function import_file($filename) { |
| 7 | 7 | $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
| 8 | 8 | $Connection = new Connection(); |
| 9 | - //Connection::$db->beginTransaction(); |
|
| 10 | - $templine = ''; |
|
| 11 | - $lines = file($filename); |
|
| 12 | - foreach ($lines as $line) |
|
| 13 | - { |
|
| 14 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
| 15 | - $templine .= $line; |
|
| 16 | - if (substr(trim($line), -1,1) == ';') |
|
| 17 | - { |
|
| 18 | - try { |
|
| 19 | - $sth = $Connection->db->prepare($templine); |
|
| 9 | + //Connection::$db->beginTransaction(); |
|
| 10 | + $templine = ''; |
|
| 11 | + $lines = file($filename); |
|
| 12 | + foreach ($lines as $line) |
|
| 13 | + { |
|
| 14 | + if (substr($line,0,2) == '--' || $line == '') continue; |
|
| 15 | + $templine .= $line; |
|
| 16 | + if (substr(trim($line), -1,1) == ';') |
|
| 17 | + { |
|
| 18 | + try { |
|
| 19 | + $sth = $Connection->db->prepare($templine); |
|
| 20 | 20 | $sth->execute(); |
| 21 | - } catch(PDOException $e) { |
|
| 21 | + } catch(PDOException $e) { |
|
| 22 | 22 | return "error (import ".$filename.") : ".$e->getMessage()."\n"; |
| 23 | - } |
|
| 24 | - $templine = ''; |
|
| 25 | - } |
|
| 23 | + } |
|
| 24 | + $templine = ''; |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | - //Connection::$db->commit(); |
|
| 28 | - $Connection->db = null; |
|
| 29 | - return ''; |
|
| 27 | + //Connection::$db->commit(); |
|
| 28 | + $Connection->db = null; |
|
| 29 | + return ''; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public static function import_all_db($directory) { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
| 36 | 36 | while(false !== ($filename = readdir($dh))) |
| 37 | 37 | { |
| 38 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
| 38 | + if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
| 39 | 39 | } |
| 40 | 40 | return $error; |
| 41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $host = filter_var($host,FILTER_SANITIZE_STRING); |
| 51 | 51 | // Dirty hack |
| 52 | 52 | if ($host != 'localhost' && $host != '127.0.0.1') { |
| 53 | - $grantright = $_SERVER['SERVER_ADDR']; |
|
| 53 | + $grantright = $_SERVER['SERVER_ADDR']; |
|
| 54 | 54 | } else $grantright = 'localhost'; |
| 55 | 55 | try { |
| 56 | 56 | $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |