@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | global $globalFilterName; |
| 15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 15 | + if (isset($globalFilterName)) { |
|
| 16 | + $this->filter_name = $globalFilterName; |
|
| 17 | + } |
|
| 16 | 18 | $Connection = new Connection($dbc); |
| 17 | 19 | $this->db = $Connection->db(); |
| 18 | 20 | } |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | return $all; |
| 42 | 44 | } |
| 43 | 45 | public function getAllAirlineNames($filter_name = '') { |
| 44 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 46 | + if ($filter_name == '') { |
|
| 47 | + $filter_name = $this->filter_name; |
|
| 48 | + } |
|
| 45 | 49 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 46 | 50 | try { |
| 47 | 51 | $sth = $this->db->prepare($query); |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | return $all; |
| 54 | 58 | } |
| 55 | 59 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 56 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 60 | + if ($filter_name == '') { |
|
| 61 | + $filter_name = $this->filter_name; |
|
| 62 | + } |
|
| 57 | 63 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 58 | 64 | try { |
| 59 | 65 | $sth = $this->db->prepare($query); |
@@ -65,7 +71,9 @@ discard block |
||
| 65 | 71 | return $all; |
| 66 | 72 | } |
| 67 | 73 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 68 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 74 | + if ($filter_name == '') { |
|
| 75 | + $filter_name = $this->filter_name; |
|
| 76 | + } |
|
| 69 | 77 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 70 | 78 | try { |
| 71 | 79 | $sth = $this->db->prepare($query); |
@@ -77,7 +85,9 @@ discard block |
||
| 77 | 85 | return $all; |
| 78 | 86 | } |
| 79 | 87 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 88 | + if ($filter_name == '') { |
|
| 89 | + $filter_name = $this->filter_name; |
|
| 90 | + } |
|
| 81 | 91 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 82 | 92 | try { |
| 83 | 93 | $sth = $this->db->prepare($query); |
@@ -92,9 +102,14 @@ discard block |
||
| 92 | 102 | |
| 93 | 103 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
| 94 | 104 | global $globalStatsFilters; |
| 95 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 96 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 97 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 105 | + if ($filter_name == '') { |
|
| 106 | + $filter_name = $this->filter_name; |
|
| 107 | + } |
|
| 108 | + if ($limit) { |
|
| 109 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 110 | + } else { |
|
| 111 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 112 | + } |
|
| 98 | 113 | try { |
| 99 | 114 | $sth = $this->db->prepare($query); |
| 100 | 115 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -114,9 +129,14 @@ discard block |
||
| 114 | 129 | } |
| 115 | 130 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
| 116 | 131 | global $globalStatsFilters; |
| 117 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 118 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 119 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 132 | + if ($filter_name == '') { |
|
| 133 | + $filter_name = $this->filter_name; |
|
| 134 | + } |
|
| 135 | + if ($limit) { |
|
| 136 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 137 | + } else { |
|
| 138 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 139 | + } |
|
| 120 | 140 | try { |
| 121 | 141 | $sth = $this->db->prepare($query); |
| 122 | 142 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -136,9 +156,14 @@ discard block |
||
| 136 | 156 | } |
| 137 | 157 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
| 138 | 158 | global $globalStatsFilters; |
| 139 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 140 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 141 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 159 | + if ($filter_name == '') { |
|
| 160 | + $filter_name = $this->filter_name; |
|
| 161 | + } |
|
| 162 | + if ($limit) { |
|
| 163 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 164 | + } else { |
|
| 165 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 166 | + } |
|
| 142 | 167 | try { |
| 143 | 168 | $sth = $this->db->prepare($query); |
| 144 | 169 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -159,9 +184,14 @@ discard block |
||
| 159 | 184 | |
| 160 | 185 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
| 161 | 186 | global $globalStatsFilters; |
| 162 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 163 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 164 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 187 | + if ($filter_name == '') { |
|
| 188 | + $filter_name = $this->filter_name; |
|
| 189 | + } |
|
| 190 | + if ($limit) { |
|
| 191 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 192 | + } else { |
|
| 193 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 194 | + } |
|
| 165 | 195 | try { |
| 166 | 196 | $sth = $this->db->prepare($query); |
| 167 | 197 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -181,9 +211,14 @@ discard block |
||
| 181 | 211 | } |
| 182 | 212 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
| 183 | 213 | global $globalStatsFilters; |
| 184 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 185 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 186 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 214 | + if ($filter_name == '') { |
|
| 215 | + $filter_name = $this->filter_name; |
|
| 216 | + } |
|
| 217 | + if ($limit) { |
|
| 218 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 219 | + } else { |
|
| 220 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 221 | + } |
|
| 187 | 222 | try { |
| 188 | 223 | $sth = $this->db->prepare($query); |
| 189 | 224 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -204,9 +239,14 @@ discard block |
||
| 204 | 239 | |
| 205 | 240 | public function countAllAirlines($limit = true,$filter_name = '') { |
| 206 | 241 | global $globalStatsFilters; |
| 207 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 208 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 209 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
| 242 | + if ($filter_name == '') { |
|
| 243 | + $filter_name = $this->filter_name; |
|
| 244 | + } |
|
| 245 | + if ($limit) { |
|
| 246 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 247 | + } else { |
|
| 248 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
| 249 | + } |
|
| 210 | 250 | try { |
| 211 | 251 | $sth = $this->db->prepare($query); |
| 212 | 252 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -227,9 +267,14 @@ discard block |
||
| 227 | 267 | } |
| 228 | 268 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
| 229 | 269 | global $globalStatsFilters; |
| 230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 231 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 232 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 270 | + if ($filter_name == '') { |
|
| 271 | + $filter_name = $this->filter_name; |
|
| 272 | + } |
|
| 273 | + if ($limit) { |
|
| 274 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 275 | + } else { |
|
| 276 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 277 | + } |
|
| 233 | 278 | try { |
| 234 | 279 | $sth = $this->db->prepare($query); |
| 235 | 280 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -249,9 +294,14 @@ discard block |
||
| 249 | 294 | } |
| 250 | 295 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
| 251 | 296 | global $globalStatsFilters; |
| 252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 253 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 254 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 297 | + if ($filter_name == '') { |
|
| 298 | + $filter_name = $this->filter_name; |
|
| 299 | + } |
|
| 300 | + if ($limit) { |
|
| 301 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 302 | + } else { |
|
| 303 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 304 | + } |
|
| 255 | 305 | try { |
| 256 | 306 | $sth = $this->db->prepare($query); |
| 257 | 307 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -271,10 +321,15 @@ discard block |
||
| 271 | 321 | } |
| 272 | 322 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
| 273 | 323 | $Connection = new Connection(); |
| 274 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 324 | + if ($filter_name == '') { |
|
| 325 | + $filter_name = $this->filter_name; |
|
| 326 | + } |
|
| 275 | 327 | if ($Connection->tableExists('countries')) { |
| 276 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 277 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 328 | + if ($limit) { |
|
| 329 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 330 | + } else { |
|
| 331 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 332 | + } |
|
| 278 | 333 | try { |
| 279 | 334 | $sth = $this->db->prepare($query); |
| 280 | 335 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -295,9 +350,14 @@ discard block |
||
| 295 | 350 | } |
| 296 | 351 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
| 297 | 352 | global $globalStatsFilters; |
| 298 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 299 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 300 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 353 | + if ($filter_name == '') { |
|
| 354 | + $filter_name = $this->filter_name; |
|
| 355 | + } |
|
| 356 | + if ($limit) { |
|
| 357 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 358 | + } else { |
|
| 359 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 360 | + } |
|
| 301 | 361 | try { |
| 302 | 362 | $sth = $this->db->prepare($query); |
| 303 | 363 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -317,9 +377,14 @@ discard block |
||
| 317 | 377 | } |
| 318 | 378 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
| 319 | 379 | global $globalStatsFilters; |
| 320 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 321 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 322 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 380 | + if ($filter_name == '') { |
|
| 381 | + $filter_name = $this->filter_name; |
|
| 382 | + } |
|
| 383 | + if ($limit) { |
|
| 384 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 385 | + } else { |
|
| 386 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 387 | + } |
|
| 323 | 388 | try { |
| 324 | 389 | $sth = $this->db->prepare($query); |
| 325 | 390 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -339,9 +404,14 @@ discard block |
||
| 339 | 404 | } |
| 340 | 405 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
| 341 | 406 | global $globalStatsFilters; |
| 342 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 343 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 344 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 407 | + if ($filter_name == '') { |
|
| 408 | + $filter_name = $this->filter_name; |
|
| 409 | + } |
|
| 410 | + if ($limit) { |
|
| 411 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 412 | + } else { |
|
| 413 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 414 | + } |
|
| 345 | 415 | try { |
| 346 | 416 | $sth = $this->db->prepare($query); |
| 347 | 417 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -367,7 +437,9 @@ discard block |
||
| 367 | 437 | $icao = $value['airport_departure_icao']; |
| 368 | 438 | if (isset($all[$icao])) { |
| 369 | 439 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 370 | - } else $all[$icao] = $value; |
|
| 440 | + } else { |
|
| 441 | + $all[$icao] = $value; |
|
| 442 | + } |
|
| 371 | 443 | } |
| 372 | 444 | $count = array(); |
| 373 | 445 | foreach ($all as $key => $row) { |
@@ -379,9 +451,14 @@ discard block |
||
| 379 | 451 | } |
| 380 | 452 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
| 381 | 453 | global $globalStatsFilters; |
| 382 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 383 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 384 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 454 | + if ($filter_name == '') { |
|
| 455 | + $filter_name = $this->filter_name; |
|
| 456 | + } |
|
| 457 | + if ($limit) { |
|
| 458 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 459 | + } else { |
|
| 460 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 461 | + } |
|
| 385 | 462 | try { |
| 386 | 463 | $sth = $this->db->prepare($query); |
| 387 | 464 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -407,7 +484,9 @@ discard block |
||
| 407 | 484 | $icao = $value['airport_arrival_icao']; |
| 408 | 485 | if (isset($all[$icao])) { |
| 409 | 486 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 410 | - } else $all[$icao] = $value; |
|
| 487 | + } else { |
|
| 488 | + $all[$icao] = $value; |
|
| 489 | + } |
|
| 411 | 490 | } |
| 412 | 491 | $count = array(); |
| 413 | 492 | foreach ($all as $key => $row) { |
@@ -420,13 +499,21 @@ discard block |
||
| 420 | 499 | } |
| 421 | 500 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 422 | 501 | global $globalDBdriver, $globalStatsFilters; |
| 423 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 502 | + if ($filter_name == '') { |
|
| 503 | + $filter_name = $this->filter_name; |
|
| 504 | + } |
|
| 424 | 505 | if ($globalDBdriver == 'mysql') { |
| 425 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 426 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 506 | + if ($limit) { |
|
| 507 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 508 | + } else { |
|
| 509 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 510 | + } |
|
| 427 | 511 | } else { |
| 428 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 429 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 512 | + if ($limit) { |
|
| 513 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 514 | + } else { |
|
| 515 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 516 | + } |
|
| 430 | 517 | } |
| 431 | 518 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 432 | 519 | try { |
@@ -450,7 +537,9 @@ discard block |
||
| 450 | 537 | |
| 451 | 538 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 452 | 539 | global $globalStatsFilters; |
| 453 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 540 | + if ($filter_name == '') { |
|
| 541 | + $filter_name = $this->filter_name; |
|
| 542 | + } |
|
| 454 | 543 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 455 | 544 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 456 | 545 | try { |
@@ -472,7 +561,9 @@ discard block |
||
| 472 | 561 | } |
| 473 | 562 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 474 | 563 | global $globalDBdriver, $globalStatsFilters; |
| 475 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 564 | + if ($filter_name == '') { |
|
| 565 | + $filter_name = $this->filter_name; |
|
| 566 | + } |
|
| 476 | 567 | if ($globalDBdriver == 'mysql') { |
| 477 | 568 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 478 | 569 | } else { |
@@ -498,7 +589,9 @@ discard block |
||
| 498 | 589 | } |
| 499 | 590 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 500 | 591 | global $globalStatsFilters; |
| 501 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 592 | + if ($filter_name == '') { |
|
| 593 | + $filter_name = $this->filter_name; |
|
| 594 | + } |
|
| 502 | 595 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 503 | 596 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 504 | 597 | try { |
@@ -520,7 +613,9 @@ discard block |
||
| 520 | 613 | } |
| 521 | 614 | public function countAllDatesByAirlines($filter_name = '') { |
| 522 | 615 | global $globalStatsFilters; |
| 523 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 616 | + if ($filter_name == '') { |
|
| 617 | + $filter_name = $this->filter_name; |
|
| 618 | + } |
|
| 524 | 619 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
| 525 | 620 | $query_data = array('filter_name' => $filter_name); |
| 526 | 621 | try { |
@@ -542,7 +637,9 @@ discard block |
||
| 542 | 637 | } |
| 543 | 638 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 544 | 639 | global $globalStatsFilters; |
| 545 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 640 | + if ($filter_name == '') { |
|
| 641 | + $filter_name = $this->filter_name; |
|
| 642 | + } |
|
| 546 | 643 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 547 | 644 | try { |
| 548 | 645 | $sth = $this->db->prepare($query); |
@@ -563,7 +660,9 @@ discard block |
||
| 563 | 660 | } |
| 564 | 661 | public function countAllMilitaryMonths($filter_name = '') { |
| 565 | 662 | global $globalStatsFilters; |
| 566 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 663 | + if ($filter_name == '') { |
|
| 664 | + $filter_name = $this->filter_name; |
|
| 665 | + } |
|
| 567 | 666 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
| 568 | 667 | try { |
| 569 | 668 | $sth = $this->db->prepare($query); |
@@ -584,9 +683,14 @@ discard block |
||
| 584 | 683 | } |
| 585 | 684 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 586 | 685 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 587 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 588 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 589 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 686 | + if ($filter_name == '') { |
|
| 687 | + $filter_name = $this->filter_name; |
|
| 688 | + } |
|
| 689 | + if ($limit) { |
|
| 690 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 691 | + } else { |
|
| 692 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 693 | + } |
|
| 590 | 694 | if ($orderby == 'hour') { |
| 591 | 695 | /* |
| 592 | 696 | if ($globalDBdriver == 'mysql') { |
@@ -595,7 +699,9 @@ discard block |
||
| 595 | 699 | */ |
| 596 | 700 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 597 | 701 | } |
| 598 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 702 | + if ($orderby == 'count') { |
|
| 703 | + $query .= " ORDER BY hour_count DESC"; |
|
| 704 | + } |
|
| 599 | 705 | try { |
| 600 | 706 | $sth = $this->db->prepare($query); |
| 601 | 707 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -616,7 +722,9 @@ discard block |
||
| 616 | 722 | |
| 617 | 723 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
| 618 | 724 | global $globalStatsFilters; |
| 619 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 725 | + if ($filter_name == '') { |
|
| 726 | + $filter_name = $this->filter_name; |
|
| 727 | + } |
|
| 620 | 728 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
| 621 | 729 | if (empty($all)) { |
| 622 | 730 | $filters = array('airlines' => array($stats_airline)); |
@@ -630,7 +738,9 @@ discard block |
||
| 630 | 738 | } |
| 631 | 739 | public function countOverallMilitaryFlights($filter_name = '') { |
| 632 | 740 | global $globalStatsFilters; |
| 633 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 741 | + if ($filter_name == '') { |
|
| 742 | + $filter_name = $this->filter_name; |
|
| 743 | + } |
|
| 634 | 744 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
| 635 | 745 | if (empty($all)) { |
| 636 | 746 | $filters = array(); |
@@ -644,7 +754,9 @@ discard block |
||
| 644 | 754 | } |
| 645 | 755 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
| 646 | 756 | global $globalStatsFilters; |
| 647 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 757 | + if ($filter_name == '') { |
|
| 758 | + $filter_name = $this->filter_name; |
|
| 759 | + } |
|
| 648 | 760 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
| 649 | 761 | if (empty($all)) { |
| 650 | 762 | $filters = array('airlines' => array($stats_airline)); |
@@ -658,7 +770,9 @@ discard block |
||
| 658 | 770 | } |
| 659 | 771 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
| 660 | 772 | global $globalStatsFilters; |
| 661 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 773 | + if ($filter_name == '') { |
|
| 774 | + $filter_name = $this->filter_name; |
|
| 775 | + } |
|
| 662 | 776 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
| 663 | 777 | if (empty($all)) { |
| 664 | 778 | $filters = array('airlines' => array($stats_airline)); |
@@ -672,7 +786,9 @@ discard block |
||
| 672 | 786 | } |
| 673 | 787 | public function countOverallAirlines($filter_name = '') { |
| 674 | 788 | global $globalStatsFilters; |
| 675 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 789 | + if ($filter_name == '') { |
|
| 790 | + $filter_name = $this->filter_name; |
|
| 791 | + } |
|
| 676 | 792 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 677 | 793 | try { |
| 678 | 794 | $sth = $this->db->prepare($query); |
@@ -695,7 +811,9 @@ discard block |
||
| 695 | 811 | } |
| 696 | 812 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
| 697 | 813 | global $globalStatsFilters; |
| 698 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 814 | + if ($filter_name == '') { |
|
| 815 | + $filter_name = $this->filter_name; |
|
| 816 | + } |
|
| 699 | 817 | /* |
| 700 | 818 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
| 701 | 819 | try { |
@@ -720,7 +838,9 @@ discard block |
||
| 720 | 838 | } |
| 721 | 839 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
| 722 | 840 | global $globalStatsFilters; |
| 723 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 841 | + if ($filter_name == '') { |
|
| 842 | + $filter_name = $this->filter_name; |
|
| 843 | + } |
|
| 724 | 844 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
| 725 | 845 | if (empty($all)) { |
| 726 | 846 | $filters = array('airlines' => array($stats_airline)); |
@@ -734,7 +854,9 @@ discard block |
||
| 734 | 854 | } |
| 735 | 855 | |
| 736 | 856 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 737 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 857 | + if ($filter_name == '') { |
|
| 858 | + $filter_name = $this->filter_name; |
|
| 859 | + } |
|
| 738 | 860 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 739 | 861 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 740 | 862 | try { |
@@ -747,7 +869,9 @@ discard block |
||
| 747 | 869 | return $all; |
| 748 | 870 | } |
| 749 | 871 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 750 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 872 | + if ($filter_name == '') { |
|
| 873 | + $filter_name = $this->filter_name; |
|
| 874 | + } |
|
| 751 | 875 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 752 | 876 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 753 | 877 | try { |
@@ -760,7 +884,9 @@ discard block |
||
| 760 | 884 | return $all; |
| 761 | 885 | } |
| 762 | 886 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
| 763 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 887 | + if ($filter_name == '') { |
|
| 888 | + $filter_name = $this->filter_name; |
|
| 889 | + } |
|
| 764 | 890 | global $globalArchiveMonths, $globalDBdriver; |
| 765 | 891 | if ($globalDBdriver == 'mysql') { |
| 766 | 892 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -779,7 +905,9 @@ discard block |
||
| 779 | 905 | } |
| 780 | 906 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 781 | 907 | global $globalArchiveMonths, $globalDBdriver; |
| 782 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 908 | + if ($filter_name == '') { |
|
| 909 | + $filter_name = $this->filter_name; |
|
| 910 | + } |
|
| 783 | 911 | if ($globalDBdriver == 'mysql') { |
| 784 | 912 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 785 | 913 | } else { |
@@ -797,7 +925,9 @@ discard block |
||
| 797 | 925 | } |
| 798 | 926 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 799 | 927 | global $globalArchiveMonths, $globalDBdriver; |
| 800 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 928 | + if ($filter_name == '') { |
|
| 929 | + $filter_name = $this->filter_name; |
|
| 930 | + } |
|
| 801 | 931 | if ($globalDBdriver == 'mysql') { |
| 802 | 932 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 803 | 933 | } else { |
@@ -814,7 +944,9 @@ discard block |
||
| 814 | 944 | } |
| 815 | 945 | public function getStatsAirlineTotal($filter_name = '') { |
| 816 | 946 | global $globalArchiveMonths, $globalDBdriver; |
| 817 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 947 | + if ($filter_name == '') { |
|
| 948 | + $filter_name = $this->filter_name; |
|
| 949 | + } |
|
| 818 | 950 | if ($globalDBdriver == 'mysql') { |
| 819 | 951 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 820 | 952 | } else { |
@@ -831,7 +963,9 @@ discard block |
||
| 831 | 963 | } |
| 832 | 964 | public function getStatsOwnerTotal($filter_name = '') { |
| 833 | 965 | global $globalArchiveMonths, $globalDBdriver; |
| 834 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 966 | + if ($filter_name == '') { |
|
| 967 | + $filter_name = $this->filter_name; |
|
| 968 | + } |
|
| 835 | 969 | if ($globalDBdriver == 'mysql') { |
| 836 | 970 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 837 | 971 | } else { |
@@ -848,7 +982,9 @@ discard block |
||
| 848 | 982 | } |
| 849 | 983 | public function getStatsPilotTotal($filter_name = '') { |
| 850 | 984 | global $globalArchiveMonths, $globalDBdriver; |
| 851 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 985 | + if ($filter_name == '') { |
|
| 986 | + $filter_name = $this->filter_name; |
|
| 987 | + } |
|
| 852 | 988 | if ($globalDBdriver == 'mysql') { |
| 853 | 989 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 854 | 990 | } else { |
@@ -866,7 +1002,9 @@ discard block |
||
| 866 | 1002 | |
| 867 | 1003 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 868 | 1004 | global $globalDBdriver; |
| 869 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1005 | + if ($filter_name == '') { |
|
| 1006 | + $filter_name = $this->filter_name; |
|
| 1007 | + } |
|
| 870 | 1008 | if ($globalDBdriver == 'mysql') { |
| 871 | 1009 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
| 872 | 1010 | } else { |
@@ -882,7 +1020,9 @@ discard block |
||
| 882 | 1020 | } |
| 883 | 1021 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 884 | 1022 | global $globalDBdriver; |
| 885 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1023 | + if ($filter_name == '') { |
|
| 1024 | + $filter_name = $this->filter_name; |
|
| 1025 | + } |
|
| 886 | 1026 | if ($globalDBdriver == 'mysql') { |
| 887 | 1027 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 888 | 1028 | } else { |
@@ -1365,47 +1505,69 @@ discard block |
||
| 1365 | 1505 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
| 1366 | 1506 | } else { |
| 1367 | 1507 | */ |
| 1368 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 1369 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 1508 | + if ($globalDebug) { |
|
| 1509 | + echo 'Update stats !'."\n"; |
|
| 1510 | + } |
|
| 1511 | + if ($globalDebug) { |
|
| 1512 | + echo 'Count all aircraft types...'."\n"; |
|
| 1513 | + } |
|
| 1370 | 1514 | if (isset($last_update[0]['value'])) { |
| 1371 | 1515 | $last_update_day = $last_update[0]['value']; |
| 1372 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 1516 | + } else { |
|
| 1517 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 1518 | + } |
|
| 1373 | 1519 | $Spotter = new Spotter($this->db); |
| 1374 | 1520 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 1375 | 1521 | foreach ($alldata as $number) { |
| 1376 | 1522 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
| 1377 | 1523 | } |
| 1378 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 1524 | + if ($globalDebug) { |
|
| 1525 | + echo 'Count all airlines...'."\n"; |
|
| 1526 | + } |
|
| 1379 | 1527 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 1380 | 1528 | foreach ($alldata as $number) { |
| 1381 | 1529 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
| 1382 | 1530 | } |
| 1383 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 1531 | + if ($globalDebug) { |
|
| 1532 | + echo 'Count all registrations...'."\n"; |
|
| 1533 | + } |
|
| 1384 | 1534 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 1385 | 1535 | foreach ($alldata as $number) { |
| 1386 | 1536 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
| 1387 | 1537 | } |
| 1388 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 1538 | + if ($globalDebug) { |
|
| 1539 | + echo 'Count all callsigns...'."\n"; |
|
| 1540 | + } |
|
| 1389 | 1541 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 1390 | 1542 | foreach ($alldata as $number) { |
| 1391 | 1543 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
| 1392 | 1544 | } |
| 1393 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 1545 | + if ($globalDebug) { |
|
| 1546 | + echo 'Count all owners...'."\n"; |
|
| 1547 | + } |
|
| 1394 | 1548 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 1395 | 1549 | foreach ($alldata as $number) { |
| 1396 | 1550 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
| 1397 | 1551 | } |
| 1398 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 1552 | + if ($globalDebug) { |
|
| 1553 | + echo 'Count all pilots...'."\n"; |
|
| 1554 | + } |
|
| 1399 | 1555 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 1400 | 1556 | foreach ($alldata as $number) { |
| 1401 | 1557 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
| 1402 | 1558 | } |
| 1403 | 1559 | |
| 1404 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 1560 | + if ($globalDebug) { |
|
| 1561 | + echo 'Count all departure airports...'."\n"; |
|
| 1562 | + } |
|
| 1405 | 1563 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 1406 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 1564 | + if ($globalDebug) { |
|
| 1565 | + echo 'Count all detected departure airports...'."\n"; |
|
| 1566 | + } |
|
| 1407 | 1567 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 1408 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 1568 | + if ($globalDebug) { |
|
| 1569 | + echo 'Order departure airports...'."\n"; |
|
| 1570 | + } |
|
| 1409 | 1571 | $alldata = array(); |
| 1410 | 1572 | |
| 1411 | 1573 | foreach ($pall as $value) { |
@@ -1416,7 +1578,9 @@ discard block |
||
| 1416 | 1578 | $icao = $value['airport_departure_icao']; |
| 1417 | 1579 | if (isset($alldata[$icao])) { |
| 1418 | 1580 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1419 | - } else $alldata[$icao] = $value; |
|
| 1581 | + } else { |
|
| 1582 | + $alldata[$icao] = $value; |
|
| 1583 | + } |
|
| 1420 | 1584 | } |
| 1421 | 1585 | $count = array(); |
| 1422 | 1586 | foreach ($alldata as $key => $row) { |
@@ -1426,11 +1590,17 @@ discard block |
||
| 1426 | 1590 | foreach ($alldata as $number) { |
| 1427 | 1591 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
| 1428 | 1592 | } |
| 1429 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 1593 | + if ($globalDebug) { |
|
| 1594 | + echo 'Count all arrival airports...'."\n"; |
|
| 1595 | + } |
|
| 1430 | 1596 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 1431 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 1597 | + if ($globalDebug) { |
|
| 1598 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 1599 | + } |
|
| 1432 | 1600 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 1433 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 1601 | + if ($globalDebug) { |
|
| 1602 | + echo 'Order arrival airports...'."\n"; |
|
| 1603 | + } |
|
| 1434 | 1604 | $alldata = array(); |
| 1435 | 1605 | foreach ($pall as $value) { |
| 1436 | 1606 | $icao = $value['airport_arrival_icao']; |
@@ -1440,7 +1610,9 @@ discard block |
||
| 1440 | 1610 | $icao = $value['airport_arrival_icao']; |
| 1441 | 1611 | if (isset($alldata[$icao])) { |
| 1442 | 1612 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1443 | - } else $alldata[$icao] = $value; |
|
| 1613 | + } else { |
|
| 1614 | + $alldata[$icao] = $value; |
|
| 1615 | + } |
|
| 1444 | 1616 | } |
| 1445 | 1617 | $count = array(); |
| 1446 | 1618 | foreach ($alldata as $key => $row) { |
@@ -1451,7 +1623,9 @@ discard block |
||
| 1451 | 1623 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
| 1452 | 1624 | } |
| 1453 | 1625 | if ($Connection->tableExists('countries')) { |
| 1454 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 1626 | + if ($globalDebug) { |
|
| 1627 | + echo 'Count all flights by countries...'."\n"; |
|
| 1628 | + } |
|
| 1455 | 1629 | $SpotterArchive = new SpotterArchive(); |
| 1456 | 1630 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 1457 | 1631 | foreach ($alldata as $number) { |
@@ -1463,46 +1637,66 @@ discard block |
||
| 1463 | 1637 | // Add by month using getstat if month finish... |
| 1464 | 1638 | |
| 1465 | 1639 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 1466 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 1640 | + if ($globalDebug) { |
|
| 1641 | + echo 'Count all flights by months...'."\n"; |
|
| 1642 | + } |
|
| 1467 | 1643 | $Spotter = new Spotter($this->db); |
| 1468 | 1644 | $alldata = $Spotter->countAllMonths(); |
| 1469 | 1645 | $lastyear = false; |
| 1470 | 1646 | foreach ($alldata as $number) { |
| 1471 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1647 | + if ($number['year_name'] != date('Y')) { |
|
| 1648 | + $lastyear = true; |
|
| 1649 | + } |
|
| 1472 | 1650 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1473 | 1651 | } |
| 1474 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 1652 | + if ($globalDebug) { |
|
| 1653 | + echo 'Count all military flights by months...'."\n"; |
|
| 1654 | + } |
|
| 1475 | 1655 | $alldata = $Spotter->countAllMilitaryMonths(); |
| 1476 | 1656 | foreach ($alldata as $number) { |
| 1477 | 1657 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1478 | 1658 | } |
| 1479 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 1659 | + if ($globalDebug) { |
|
| 1660 | + echo 'Count all owners by months...'."\n"; |
|
| 1661 | + } |
|
| 1480 | 1662 | $alldata = $Spotter->countAllMonthsOwners(); |
| 1481 | 1663 | foreach ($alldata as $number) { |
| 1482 | 1664 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1483 | 1665 | } |
| 1484 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 1666 | + if ($globalDebug) { |
|
| 1667 | + echo 'Count all pilots by months...'."\n"; |
|
| 1668 | + } |
|
| 1485 | 1669 | $alldata = $Spotter->countAllMonthsPilots(); |
| 1486 | 1670 | foreach ($alldata as $number) { |
| 1487 | 1671 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1488 | 1672 | } |
| 1489 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 1673 | + if ($globalDebug) { |
|
| 1674 | + echo 'Count all airlines by months...'."\n"; |
|
| 1675 | + } |
|
| 1490 | 1676 | $alldata = $Spotter->countAllMonthsAirlines(); |
| 1491 | 1677 | foreach ($alldata as $number) { |
| 1492 | 1678 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1493 | 1679 | } |
| 1494 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 1680 | + if ($globalDebug) { |
|
| 1681 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 1682 | + } |
|
| 1495 | 1683 | $alldata = $Spotter->countAllMonthsAircrafts(); |
| 1496 | 1684 | foreach ($alldata as $number) { |
| 1497 | 1685 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1498 | 1686 | } |
| 1499 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 1687 | + if ($globalDebug) { |
|
| 1688 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 1689 | + } |
|
| 1500 | 1690 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
| 1501 | 1691 | foreach ($alldata as $number) { |
| 1502 | 1692 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1503 | 1693 | } |
| 1504 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 1505 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 1694 | + if ($globalDebug) { |
|
| 1695 | + echo 'Airports data...'."\n"; |
|
| 1696 | + } |
|
| 1697 | + if ($globalDebug) { |
|
| 1698 | + echo '...Departure'."\n"; |
|
| 1699 | + } |
|
| 1506 | 1700 | $this->deleteStatAirport('daily'); |
| 1507 | 1701 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1508 | 1702 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1622,37 +1816,53 @@ discard block |
||
| 1622 | 1816 | |
| 1623 | 1817 | // Count by airlines |
| 1624 | 1818 | echo '--- Stats by airlines ---'."\n"; |
| 1625 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1819 | + if ($globalDebug) { |
|
| 1820 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1821 | + } |
|
| 1626 | 1822 | $Spotter = new Spotter($this->db); |
| 1627 | 1823 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 1628 | 1824 | foreach ($alldata as $number) { |
| 1629 | 1825 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
| 1630 | 1826 | } |
| 1631 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1827 | + if ($globalDebug) { |
|
| 1828 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1829 | + } |
|
| 1632 | 1830 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 1633 | 1831 | foreach ($alldata as $number) { |
| 1634 | 1832 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
| 1635 | 1833 | } |
| 1636 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 1834 | + if ($globalDebug) { |
|
| 1835 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 1836 | + } |
|
| 1637 | 1837 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 1638 | 1838 | foreach ($alldata as $number) { |
| 1639 | 1839 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
| 1640 | 1840 | } |
| 1641 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 1841 | + if ($globalDebug) { |
|
| 1842 | + echo 'Count all owners by airlines...'."\n"; |
|
| 1843 | + } |
|
| 1642 | 1844 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 1643 | 1845 | foreach ($alldata as $number) { |
| 1644 | 1846 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
| 1645 | 1847 | } |
| 1646 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 1848 | + if ($globalDebug) { |
|
| 1849 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 1850 | + } |
|
| 1647 | 1851 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 1648 | 1852 | foreach ($alldata as $number) { |
| 1649 | 1853 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
| 1650 | 1854 | } |
| 1651 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 1855 | + if ($globalDebug) { |
|
| 1856 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 1857 | + } |
|
| 1652 | 1858 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1653 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 1859 | + if ($globalDebug) { |
|
| 1860 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 1861 | + } |
|
| 1654 | 1862 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1655 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 1863 | + if ($globalDebug) { |
|
| 1864 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 1865 | + } |
|
| 1656 | 1866 | //$alldata = array(); |
| 1657 | 1867 | foreach ($dall as $value) { |
| 1658 | 1868 | $icao = $value['airport_departure_icao']; |
@@ -1673,11 +1883,17 @@ discard block |
||
| 1673 | 1883 | foreach ($alldata as $number) { |
| 1674 | 1884 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
| 1675 | 1885 | } |
| 1676 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 1886 | + if ($globalDebug) { |
|
| 1887 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 1888 | + } |
|
| 1677 | 1889 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1678 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 1890 | + if ($globalDebug) { |
|
| 1891 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 1892 | + } |
|
| 1679 | 1893 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1680 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 1894 | + if ($globalDebug) { |
|
| 1895 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 1896 | + } |
|
| 1681 | 1897 | //$alldata = array(); |
| 1682 | 1898 | foreach ($dall as $value) { |
| 1683 | 1899 | $icao = $value['airport_arrival_icao']; |
@@ -1698,35 +1914,49 @@ discard block |
||
| 1698 | 1914 | foreach ($alldata as $number) { |
| 1699 | 1915 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
| 1700 | 1916 | } |
| 1701 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 1917 | + if ($globalDebug) { |
|
| 1918 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 1919 | + } |
|
| 1702 | 1920 | $Spotter = new Spotter($this->db); |
| 1703 | 1921 | $alldata = $Spotter->countAllMonthsByAirlines(); |
| 1704 | 1922 | $lastyear = false; |
| 1705 | 1923 | foreach ($alldata as $number) { |
| 1706 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1924 | + if ($number['year_name'] != date('Y')) { |
|
| 1925 | + $lastyear = true; |
|
| 1926 | + } |
|
| 1707 | 1927 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1708 | 1928 | } |
| 1709 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 1929 | + if ($globalDebug) { |
|
| 1930 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 1931 | + } |
|
| 1710 | 1932 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
| 1711 | 1933 | foreach ($alldata as $number) { |
| 1712 | 1934 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1713 | 1935 | } |
| 1714 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 1936 | + if ($globalDebug) { |
|
| 1937 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 1938 | + } |
|
| 1715 | 1939 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
| 1716 | 1940 | foreach ($alldata as $number) { |
| 1717 | 1941 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1718 | 1942 | } |
| 1719 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 1943 | + if ($globalDebug) { |
|
| 1944 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 1945 | + } |
|
| 1720 | 1946 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
| 1721 | 1947 | foreach ($alldata as $number) { |
| 1722 | 1948 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1723 | 1949 | } |
| 1724 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 1950 | + if ($globalDebug) { |
|
| 1951 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 1952 | + } |
|
| 1725 | 1953 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
| 1726 | 1954 | foreach ($alldata as $number) { |
| 1727 | 1955 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1728 | 1956 | } |
| 1729 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 1957 | + if ($globalDebug) { |
|
| 1958 | + echo '...Departure'."\n"; |
|
| 1959 | + } |
|
| 1730 | 1960 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 1731 | 1961 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 1732 | 1962 | foreach ($dall as $value) { |
@@ -1749,7 +1979,9 @@ discard block |
||
| 1749 | 1979 | foreach ($alldata as $number) { |
| 1750 | 1980 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
| 1751 | 1981 | } |
| 1752 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 1982 | + if ($globalDebug) { |
|
| 1983 | + echo '...Arrival'."\n"; |
|
| 1984 | + } |
|
| 1753 | 1985 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 1754 | 1986 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 1755 | 1987 | foreach ($dall as $value) { |
@@ -1773,13 +2005,19 @@ discard block |
||
| 1773 | 2005 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
| 1774 | 2006 | } |
| 1775 | 2007 | |
| 1776 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 1777 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2008 | + if ($globalDebug) { |
|
| 2009 | + echo 'Flights data...'."\n"; |
|
| 2010 | + } |
|
| 2011 | + if ($globalDebug) { |
|
| 2012 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2013 | + } |
|
| 1778 | 2014 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
| 1779 | 2015 | foreach ($alldata as $number) { |
| 1780 | 2016 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 1781 | 2017 | } |
| 1782 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2018 | + if ($globalDebug) { |
|
| 2019 | + echo '-> countAllDates...'."\n"; |
|
| 2020 | + } |
|
| 1783 | 2021 | //$previousdata = $this->countAllDatesByAirlines(); |
| 1784 | 2022 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
| 1785 | 2023 | $values = array(); |
@@ -1792,19 +2030,25 @@ discard block |
||
| 1792 | 2030 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 1793 | 2031 | } |
| 1794 | 2032 | |
| 1795 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2033 | + if ($globalDebug) { |
|
| 2034 | + echo '-> countAllHours...'."\n"; |
|
| 2035 | + } |
|
| 1796 | 2036 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
| 1797 | 2037 | foreach ($alldata as $number) { |
| 1798 | 2038 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 1799 | 2039 | } |
| 1800 | 2040 | |
| 1801 | 2041 | |
| 1802 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2042 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2043 | + $globalStatsFilters = array(); |
|
| 2044 | + } |
|
| 1803 | 2045 | foreach ($globalStatsFilters as $name => $filter) { |
| 1804 | 2046 | //$filter_name = $filter['name']; |
| 1805 | 2047 | $filter_name = $name; |
| 1806 | 2048 | // Count by filter |
| 1807 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2049 | + if ($globalDebug) { |
|
| 2050 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2051 | + } |
|
| 1808 | 2052 | $Spotter = new Spotter($this->db); |
| 1809 | 2053 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 1810 | 2054 | foreach ($alldata as $number) { |
@@ -1842,7 +2086,9 @@ discard block |
||
| 1842 | 2086 | $icao = $value['airport_departure_icao']; |
| 1843 | 2087 | if (isset($alldata[$icao])) { |
| 1844 | 2088 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1845 | - } else $alldata[$icao] = $value; |
|
| 2089 | + } else { |
|
| 2090 | + $alldata[$icao] = $value; |
|
| 2091 | + } |
|
| 1846 | 2092 | } |
| 1847 | 2093 | $count = array(); |
| 1848 | 2094 | foreach ($alldata as $key => $row) { |
@@ -1863,7 +2109,9 @@ discard block |
||
| 1863 | 2109 | $icao = $value['airport_arrival_icao']; |
| 1864 | 2110 | if (isset($alldata[$icao])) { |
| 1865 | 2111 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1866 | - } else $alldata[$icao] = $value; |
|
| 2112 | + } else { |
|
| 2113 | + $alldata[$icao] = $value; |
|
| 2114 | + } |
|
| 1867 | 2115 | } |
| 1868 | 2116 | $count = array(); |
| 1869 | 2117 | foreach ($alldata as $key => $row) { |
@@ -1877,7 +2125,9 @@ discard block |
||
| 1877 | 2125 | $alldata = $Spotter->countAllMonths($filter); |
| 1878 | 2126 | $lastyear = false; |
| 1879 | 2127 | foreach ($alldata as $number) { |
| 1880 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2128 | + if ($number['year_name'] != date('Y')) { |
|
| 2129 | + $lastyear = true; |
|
| 2130 | + } |
|
| 1881 | 2131 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 1882 | 2132 | } |
| 1883 | 2133 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -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); |
|
| 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 | 289 | $sth->execute(); |
| 290 | - } catch(PDOException $e) { |
|
| 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,76 +398,76 @@ 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 | 411 | global $globalDBdriver, $globalDBname; |
| 412 | - $Connection = new Connection(); |
|
| 413 | - $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)"; |
|
| 414 | - try { |
|
| 415 | - $sth = $Connection->db->prepare($query); |
|
| 416 | - $sth->execute(); |
|
| 417 | - } catch(PDOException $e) { |
|
| 418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
| 419 | - } |
|
| 420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 421 | - try { |
|
| 422 | - $sth = $Connection->db->prepare($query); |
|
| 423 | - $sth->execute(); |
|
| 424 | - } catch(PDOException $e) { |
|
| 425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 426 | - } |
|
| 427 | - if ($globalDBdriver == 'mysql') { |
|
| 428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 429 | - try { |
|
| 430 | - $sth = $Connection->db->prepare($query); |
|
| 412 | + $Connection = new Connection(); |
|
| 413 | + $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)"; |
|
| 414 | + try { |
|
| 415 | + $sth = $Connection->db->prepare($query); |
|
| 416 | + $sth->execute(); |
|
| 417 | + } catch(PDOException $e) { |
|
| 418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
| 419 | + } |
|
| 420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 421 | + try { |
|
| 422 | + $sth = $Connection->db->prepare($query); |
|
| 423 | + $sth->execute(); |
|
| 424 | + } catch(PDOException $e) { |
|
| 425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
| 426 | + } |
|
| 427 | + if ($globalDBdriver == 'mysql') { |
|
| 428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
| 429 | + try { |
|
| 430 | + $sth = $Connection->db->prepare($query); |
|
| 431 | 431 | $sth->execute(); |
| 432 | - } catch(PDOException $e) { |
|
| 432 | + } catch(PDOException $e) { |
|
| 433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 434 | - } |
|
| 435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 436 | - if ($row['engine'] == 'ARCHIVE') { |
|
| 434 | + } |
|
| 435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 436 | + if ($row['engine'] == 'ARCHIVE') { |
|
| 437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
| 438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
| 439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
| 440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
| 441 | 441 | DROP TABLE spotter_archive; |
| 442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
| 443 | - } else { |
|
| 444 | - $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"; |
|
| 445 | - } |
|
| 446 | - } else { |
|
| 447 | - $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"; |
|
| 448 | - } |
|
| 449 | - try { |
|
| 450 | - $sth = $Connection->db->prepare($query); |
|
| 451 | - $sth->execute(); |
|
| 452 | - } catch(PDOException $e) { |
|
| 453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 454 | - } |
|
| 443 | + } else { |
|
| 444 | + $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"; |
|
| 445 | + } |
|
| 446 | + } else { |
|
| 447 | + $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"; |
|
| 448 | + } |
|
| 449 | + try { |
|
| 450 | + $sth = $Connection->db->prepare($query); |
|
| 451 | + $sth->execute(); |
|
| 452 | + } catch(PDOException $e) { |
|
| 453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | 456 | $error = ''; |
| 457 | 457 | |
| 458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
| 459 | - try { |
|
| 460 | - $sth = $Connection->db->prepare($query); |
|
| 461 | - $sth->execute(); |
|
| 462 | - } catch(PDOException $e) { |
|
| 463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 464 | - } |
|
| 459 | + try { |
|
| 460 | + $sth = $Connection->db->prepare($query); |
|
| 461 | + $sth->execute(); |
|
| 462 | + } catch(PDOException $e) { |
|
| 463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 464 | + } |
|
| 465 | 465 | return $error; |
| 466 | 466 | } |
| 467 | 467 | private static function update_from_12() { |
| 468 | - $Connection = new Connection(); |
|
| 468 | + $Connection = new Connection(); |
|
| 469 | 469 | $error = ''; |
| 470 | - // Add tables |
|
| 470 | + // Add tables |
|
| 471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
| 472 | 472 | if ($error != '') return $error; |
| 473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
| 484 | 484 | if ($error != '') return $error; |
| 485 | 485 | |
| 486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
| 487 | - try { |
|
| 488 | - $sth = $Connection->db->prepare($query); |
|
| 489 | - $sth->execute(); |
|
| 490 | - } catch(PDOException $e) { |
|
| 491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 492 | - } |
|
| 487 | + try { |
|
| 488 | + $sth = $Connection->db->prepare($query); |
|
| 489 | + $sth->execute(); |
|
| 490 | + } catch(PDOException $e) { |
|
| 491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 492 | + } |
|
| 493 | 493 | return $error; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | private static function update_from_13() { |
| 497 | - $Connection = new Connection(); |
|
| 498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
| 499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 497 | + $Connection = new Connection(); |
|
| 498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
| 499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 500 | 500 | try { |
| 501 | 501 | $sth = $Connection->db->prepare($query); |
| 502 | 502 | $sth->execute(); |
| 503 | - } catch(PDOException $e) { |
|
| 503 | + } catch(PDOException $e) { |
|
| 504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
| 505 | - } |
|
| 505 | + } |
|
| 506 | 506 | } |
| 507 | - $error = ''; |
|
| 507 | + $error = ''; |
|
| 508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
| 509 | - try { |
|
| 510 | - $sth = $Connection->db->prepare($query); |
|
| 511 | - $sth->execute(); |
|
| 512 | - } catch(PDOException $e) { |
|
| 513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 514 | - } |
|
| 509 | + try { |
|
| 510 | + $sth = $Connection->db->prepare($query); |
|
| 511 | + $sth->execute(); |
|
| 512 | + } catch(PDOException $e) { |
|
| 513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 514 | + } |
|
| 515 | 515 | return $error; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | private static function update_from_14() { |
| 519 | - $Connection = new Connection(); |
|
| 519 | + $Connection = new Connection(); |
|
| 520 | 520 | $error = ''; |
| 521 | - // Add tables |
|
| 522 | - if (!$Connection->tableExists('stats_flight')) { |
|
| 521 | + // Add tables |
|
| 522 | + if (!$Connection->tableExists('stats_flight')) { |
|
| 523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
| 524 | 524 | if ($error != '') return $error; |
| 525 | 525 | } |
| 526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
| 527 | - try { |
|
| 528 | - $sth = $Connection->db->prepare($query); |
|
| 529 | - $sth->execute(); |
|
| 530 | - } catch(PDOException $e) { |
|
| 531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 532 | - } |
|
| 527 | + try { |
|
| 528 | + $sth = $Connection->db->prepare($query); |
|
| 529 | + $sth->execute(); |
|
| 530 | + } catch(PDOException $e) { |
|
| 531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 532 | + } |
|
| 533 | 533 | return $error; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 | private static function update_from_15() { |
| 538 | - $Connection = new Connection(); |
|
| 538 | + $Connection = new Connection(); |
|
| 539 | 539 | $error = ''; |
| 540 | - // Add tables |
|
| 541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 542 | - try { |
|
| 543 | - $sth = $Connection->db->prepare($query); |
|
| 544 | - $sth->execute(); |
|
| 545 | - } catch(PDOException $e) { |
|
| 546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 547 | - } |
|
| 540 | + // Add tables |
|
| 541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 542 | + try { |
|
| 543 | + $sth = $Connection->db->prepare($query); |
|
| 544 | + $sth->execute(); |
|
| 545 | + } catch(PDOException $e) { |
|
| 546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 547 | + } |
|
| 548 | 548 | if ($error != '') return $error; |
| 549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 550 | - try { |
|
| 551 | - $sth = $Connection->db->prepare($query); |
|
| 552 | - $sth->execute(); |
|
| 553 | - } catch(PDOException $e) { |
|
| 554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 555 | - } |
|
| 550 | + try { |
|
| 551 | + $sth = $Connection->db->prepare($query); |
|
| 552 | + $sth->execute(); |
|
| 553 | + } catch(PDOException $e) { |
|
| 554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 555 | + } |
|
| 556 | 556 | return $error; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | private static function update_from_16() { |
| 560 | - $Connection = new Connection(); |
|
| 560 | + $Connection = new Connection(); |
|
| 561 | 561 | $error = ''; |
| 562 | - // Add tables |
|
| 563 | - if (!$Connection->tableExists('stats_registration')) { |
|
| 562 | + // Add tables |
|
| 563 | + if (!$Connection->tableExists('stats_registration')) { |
|
| 564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
| 565 | 565 | } |
| 566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
| 566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
| 567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
| 568 | 568 | } |
| 569 | 569 | if ($error != '') return $error; |
| 570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
| 571 | - try { |
|
| 572 | - $sth = $Connection->db->prepare($query); |
|
| 573 | - $sth->execute(); |
|
| 574 | - } catch(PDOException $e) { |
|
| 575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 576 | - } |
|
| 571 | + try { |
|
| 572 | + $sth = $Connection->db->prepare($query); |
|
| 573 | + $sth->execute(); |
|
| 574 | + } catch(PDOException $e) { |
|
| 575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 576 | + } |
|
| 577 | 577 | return $error; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | private static function update_from_17() { |
| 581 | - $Connection = new Connection(); |
|
| 581 | + $Connection = new Connection(); |
|
| 582 | 582 | $error = ''; |
| 583 | - // Add tables |
|
| 584 | - if (!$Connection->tableExists('stats_country')) { |
|
| 583 | + // Add tables |
|
| 584 | + if (!$Connection->tableExists('stats_country')) { |
|
| 585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
| 586 | 586 | } |
| 587 | 587 | if ($error != '') return $error; |
| 588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
| 589 | - try { |
|
| 590 | - $sth = $Connection->db->prepare($query); |
|
| 591 | - $sth->execute(); |
|
| 592 | - } catch(PDOException $e) { |
|
| 593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 594 | - } |
|
| 589 | + try { |
|
| 590 | + $sth = $Connection->db->prepare($query); |
|
| 591 | + $sth->execute(); |
|
| 592 | + } catch(PDOException $e) { |
|
| 593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 594 | + } |
|
| 595 | 595 | return $error; |
| 596 | 596 | } |
| 597 | 597 | private static function update_from_18() { |
| 598 | - $Connection = new Connection(); |
|
| 598 | + $Connection = new Connection(); |
|
| 599 | 599 | $error = ''; |
| 600 | - // Modify stats_airport table |
|
| 601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
| 602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_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`)"; |
|
| 603 | - try { |
|
| 604 | - $sth = $Connection->db->prepare($query); |
|
| 605 | - $sth->execute(); |
|
| 606 | - } catch(PDOException $e) { |
|
| 607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 608 | - } |
|
| 609 | - } |
|
| 600 | + // Modify stats_airport table |
|
| 601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
| 602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_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`)"; |
|
| 603 | + try { |
|
| 604 | + $sth = $Connection->db->prepare($query); |
|
| 605 | + $sth->execute(); |
|
| 606 | + } catch(PDOException $e) { |
|
| 607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | 610 | if ($error != '') return $error; |
| 611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 612 | - try { |
|
| 613 | - $sth = $Connection->db->prepare($query); |
|
| 614 | - $sth->execute(); |
|
| 615 | - } catch(PDOException $e) { |
|
| 616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 617 | - } |
|
| 612 | + try { |
|
| 613 | + $sth = $Connection->db->prepare($query); |
|
| 614 | + $sth->execute(); |
|
| 615 | + } catch(PDOException $e) { |
|
| 616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 617 | + } |
|
| 618 | 618 | return $error; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | private static function update_from_19() { |
| 622 | - $Connection = new Connection(); |
|
| 622 | + $Connection = new Connection(); |
|
| 623 | 623 | $error = ''; |
| 624 | - // Update airport table |
|
| 624 | + // Update airport table |
|
| 625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
| 626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
| 627 | 627 | // Remove primary key on Spotter_Archive |
| 628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
| 629 | - try { |
|
| 630 | - $sth = $Connection->db->prepare($query); |
|
| 631 | - $sth->execute(); |
|
| 632 | - } catch(PDOException $e) { |
|
| 633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 634 | - } |
|
| 629 | + try { |
|
| 630 | + $sth = $Connection->db->prepare($query); |
|
| 631 | + $sth->execute(); |
|
| 632 | + } catch(PDOException $e) { |
|
| 633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 634 | + } |
|
| 635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
| 636 | - try { |
|
| 637 | - $sth = $Connection->db->prepare($query); |
|
| 638 | - $sth->execute(); |
|
| 639 | - } catch(PDOException $e) { |
|
| 640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 641 | - } |
|
| 636 | + try { |
|
| 637 | + $sth = $Connection->db->prepare($query); |
|
| 638 | + $sth->execute(); |
|
| 639 | + } catch(PDOException $e) { |
|
| 640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
| 641 | + } |
|
| 642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
| 643 | 643 | // Add column over_country |
| 644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
| 644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
| 645 | 645 | try { |
| 646 | - $sth = $Connection->db->prepare($query); |
|
| 646 | + $sth = $Connection->db->prepare($query); |
|
| 647 | 647 | $sth->execute(); |
| 648 | 648 | } catch(PDOException $e) { |
| 649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | } |
| 652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
| 653 | 653 | // Add column over_country |
| 654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
| 654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
| 655 | 655 | try { |
| 656 | - $sth = $Connection->db->prepare($query); |
|
| 656 | + $sth = $Connection->db->prepare($query); |
|
| 657 | 657 | $sth->execute(); |
| 658 | 658 | } catch(PDOException $e) { |
| 659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
| 661 | 661 | } |
| 662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
| 663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 665 | 665 | try { |
| 666 | 666 | $sth = $Connection->db->prepare($query); |
| 667 | 667 | $sth->execute(); |
| 668 | 668 | } catch(PDOException $e) { |
| 669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 670 | - } |
|
| 671 | - } |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
| 673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 675 | 675 | try { |
| 676 | 676 | $sth = $Connection->db->prepare($query); |
| 677 | 677 | $sth->execute(); |
| 678 | 678 | } catch(PDOException $e) { |
| 679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 680 | - } |
|
| 681 | - } |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
| 683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
| 685 | 685 | try { |
| 686 | 686 | $sth = $Connection->db->prepare($query); |
| 687 | 687 | $sth->execute(); |
| 688 | 688 | } catch(PDOException $e) { |
| 689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 690 | - } |
|
| 691 | - } |
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
| 693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
| 694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
| 695 | 695 | try { |
| 696 | 696 | $sth = $Connection->db->prepare($query); |
| 697 | 697 | $sth->execute(); |
| 698 | 698 | } catch(PDOException $e) { |
| 699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | - } |
|
| 701 | - } |
|
| 700 | + } |
|
| 701 | + } |
|
| 702 | 702 | if ($error != '') return $error; |
| 703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
| 704 | - try { |
|
| 705 | - $sth = $Connection->db->prepare($query); |
|
| 706 | - $sth->execute(); |
|
| 707 | - } catch(PDOException $e) { |
|
| 708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 709 | - } |
|
| 704 | + try { |
|
| 705 | + $sth = $Connection->db->prepare($query); |
|
| 706 | + $sth->execute(); |
|
| 707 | + } catch(PDOException $e) { |
|
| 708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 709 | + } |
|
| 710 | 710 | return $error; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | private static function update_from_20() { |
| 714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
| 715 | - $Connection = new Connection(); |
|
| 715 | + $Connection = new Connection(); |
|
| 716 | 716 | $error = ''; |
| 717 | - // Update airline table |
|
| 718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
| 717 | + // Update airline table |
|
| 718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
| 719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
| 721 | 721 | } |
| 722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
| 723 | 723 | // Add column over_country |
| 724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
| 725 | - try { |
|
| 724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
| 725 | + try { |
|
| 726 | 726 | $sth = $Connection->db->prepare($query); |
| 727 | 727 | $sth->execute(); |
| 728 | 728 | } catch(PDOException $e) { |
| 729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | - } |
|
| 731 | - } |
|
| 730 | + } |
|
| 731 | + } |
|
| 732 | 732 | if ($error != '') return $error; |
| 733 | 733 | /* |
| 734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | */ |
| 740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
| 741 | - try { |
|
| 742 | - $sth = $Connection->db->prepare($query); |
|
| 743 | - $sth->execute(); |
|
| 744 | - } catch(PDOException $e) { |
|
| 745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 746 | - } |
|
| 741 | + try { |
|
| 742 | + $sth = $Connection->db->prepare($query); |
|
| 743 | + $sth->execute(); |
|
| 744 | + } catch(PDOException $e) { |
|
| 745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 746 | + } |
|
| 747 | 747 | return $error; |
| 748 | 748 | } |
| 749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
| 762 | 762 | if ($error != '') return $error; |
| 763 | 763 | } |
| 764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 765 | - try { |
|
| 766 | - $sth = $Connection->db->prepare($query); |
|
| 767 | - $sth->execute(); |
|
| 768 | - } catch(PDOException $e) { |
|
| 769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 770 | - } |
|
| 765 | + try { |
|
| 766 | + $sth = $Connection->db->prepare($query); |
|
| 767 | + $sth->execute(); |
|
| 768 | + } catch(PDOException $e) { |
|
| 769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 770 | + } |
|
| 771 | 771 | return $error; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | private static function update_from_22() { |
| 775 | 775 | global $globalDBdriver; |
| 776 | - $Connection = new Connection(); |
|
| 776 | + $Connection = new Connection(); |
|
| 777 | 777 | $error = ''; |
| 778 | 778 | // Add table stats polar |
| 779 | - if (!$Connection->tableExists('stats_source')) { |
|
| 779 | + if (!$Connection->tableExists('stats_source')) { |
|
| 780 | 780 | if ($globalDBdriver == 'mysql') { |
| 781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
| 781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
| 782 | 782 | } else { |
| 783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
| 784 | 784 | } |
| 785 | 785 | if ($error != '') return $error; |
| 786 | 786 | } |
| 787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
| 788 | - try { |
|
| 789 | - $sth = $Connection->db->prepare($query); |
|
| 790 | - $sth->execute(); |
|
| 791 | - } catch(PDOException $e) { |
|
| 792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 793 | - } |
|
| 788 | + try { |
|
| 789 | + $sth = $Connection->db->prepare($query); |
|
| 790 | + $sth->execute(); |
|
| 791 | + } catch(PDOException $e) { |
|
| 792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
| 793 | + } |
|
| 794 | 794 | return $error; |
| 795 | 795 | } |
| 796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
| 821 | 821 | } |
| 822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
| 823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
| 824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
| 824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
| 825 | 825 | try { |
| 826 | 826 | $sth = $Connection->db->prepare($query); |
| 827 | 827 | $sth->execute(); |
| 828 | 828 | } catch(PDOException $e) { |
| 829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
| 830 | - } |
|
| 831 | - } |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | 832 | |
| 833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
| 834 | 834 | try { |
@@ -1164,137 +1164,137 @@ discard block |
||
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | |
| 1167 | - public static function check_version($update = false) { |
|
| 1168 | - global $globalDBname; |
|
| 1169 | - $version = 0; |
|
| 1170 | - $Connection = new Connection(); |
|
| 1171 | - if ($Connection->tableExists('aircraft')) { |
|
| 1172 | - if (!$Connection->tableExists('config')) { |
|
| 1173 | - $version = '1'; |
|
| 1174 | - if ($update) return self::update_from_1(); |
|
| 1175 | - else return $version; |
|
| 1167 | + public static function check_version($update = false) { |
|
| 1168 | + global $globalDBname; |
|
| 1169 | + $version = 0; |
|
| 1170 | + $Connection = new Connection(); |
|
| 1171 | + if ($Connection->tableExists('aircraft')) { |
|
| 1172 | + if (!$Connection->tableExists('config')) { |
|
| 1173 | + $version = '1'; |
|
| 1174 | + if ($update) return self::update_from_1(); |
|
| 1175 | + else return $version; |
|
| 1176 | 1176 | } else { |
| 1177 | - $Connection = new Connection(); |
|
| 1178 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
| 1179 | - try { |
|
| 1180 | - $sth = $Connection->db->prepare($query); |
|
| 1181 | - $sth->execute(); |
|
| 1182 | - } catch(PDOException $e) { |
|
| 1177 | + $Connection = new Connection(); |
|
| 1178 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
| 1179 | + try { |
|
| 1180 | + $sth = $Connection->db->prepare($query); |
|
| 1181 | + $sth->execute(); |
|
| 1182 | + } catch(PDOException $e) { |
|
| 1183 | 1183 | return "error : ".$e->getMessage()."\n"; |
| 1184 | - } |
|
| 1185 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1186 | - if ($update) { |
|
| 1187 | - if ($result['value'] == '2') { |
|
| 1188 | - $error = self::update_from_2(); |
|
| 1189 | - if ($error != '') return $error; |
|
| 1190 | - else return self::check_version(true); |
|
| 1191 | - } elseif ($result['value'] == '3') { |
|
| 1192 | - $error = self::update_from_3(); |
|
| 1193 | - if ($error != '') return $error; |
|
| 1194 | - else return self::check_version(true); |
|
| 1195 | - } elseif ($result['value'] == '4') { |
|
| 1196 | - $error = self::update_from_4(); |
|
| 1197 | - if ($error != '') return $error; |
|
| 1198 | - else return self::check_version(true); |
|
| 1199 | - } elseif ($result['value'] == '5') { |
|
| 1200 | - $error = self::update_from_5(); |
|
| 1201 | - if ($error != '') return $error; |
|
| 1202 | - else return self::check_version(true); |
|
| 1203 | - } elseif ($result['value'] == '6') { |
|
| 1204 | - $error = self::update_from_6(); |
|
| 1205 | - if ($error != '') return $error; |
|
| 1206 | - else return self::check_version(true); |
|
| 1207 | - } elseif ($result['value'] == '7') { |
|
| 1208 | - $error = self::update_from_7(); |
|
| 1209 | - if ($error != '') return $error; |
|
| 1210 | - else return self::check_version(true); |
|
| 1211 | - } elseif ($result['value'] == '8') { |
|
| 1212 | - $error = self::update_from_8(); |
|
| 1213 | - if ($error != '') return $error; |
|
| 1214 | - else return self::check_version(true); |
|
| 1215 | - } elseif ($result['value'] == '9') { |
|
| 1216 | - $error = self::update_from_9(); |
|
| 1217 | - if ($error != '') return $error; |
|
| 1218 | - else return self::check_version(true); |
|
| 1219 | - } elseif ($result['value'] == '10') { |
|
| 1220 | - $error = self::update_from_10(); |
|
| 1221 | - if ($error != '') return $error; |
|
| 1222 | - else return self::check_version(true); |
|
| 1223 | - } elseif ($result['value'] == '11') { |
|
| 1224 | - $error = self::update_from_11(); |
|
| 1225 | - if ($error != '') return $error; |
|
| 1226 | - else return self::check_version(true); |
|
| 1227 | - } elseif ($result['value'] == '12') { |
|
| 1228 | - $error = self::update_from_12(); |
|
| 1229 | - if ($error != '') return $error; |
|
| 1230 | - else return self::check_version(true); |
|
| 1231 | - } elseif ($result['value'] == '13') { |
|
| 1232 | - $error = self::update_from_13(); |
|
| 1233 | - if ($error != '') return $error; |
|
| 1234 | - else return self::check_version(true); |
|
| 1235 | - } elseif ($result['value'] == '14') { |
|
| 1236 | - $error = self::update_from_14(); |
|
| 1237 | - if ($error != '') return $error; |
|
| 1238 | - else return self::check_version(true); |
|
| 1239 | - } elseif ($result['value'] == '15') { |
|
| 1240 | - $error = self::update_from_15(); |
|
| 1241 | - if ($error != '') return $error; |
|
| 1242 | - else return self::check_version(true); |
|
| 1243 | - } elseif ($result['value'] == '16') { |
|
| 1244 | - $error = self::update_from_16(); |
|
| 1245 | - if ($error != '') return $error; |
|
| 1246 | - else return self::check_version(true); |
|
| 1247 | - } elseif ($result['value'] == '17') { |
|
| 1248 | - $error = self::update_from_17(); |
|
| 1249 | - if ($error != '') return $error; |
|
| 1250 | - else return self::check_version(true); |
|
| 1251 | - } elseif ($result['value'] == '18') { |
|
| 1252 | - $error = self::update_from_18(); |
|
| 1253 | - if ($error != '') return $error; |
|
| 1254 | - else return self::check_version(true); |
|
| 1255 | - } elseif ($result['value'] == '19') { |
|
| 1256 | - $error = self::update_from_19(); |
|
| 1257 | - if ($error != '') return $error; |
|
| 1258 | - else return self::check_version(true); |
|
| 1259 | - } elseif ($result['value'] == '20') { |
|
| 1260 | - $error = self::update_from_20(); |
|
| 1261 | - if ($error != '') return $error; |
|
| 1262 | - else return self::check_version(true); |
|
| 1263 | - } elseif ($result['value'] == '21') { |
|
| 1264 | - $error = self::update_from_21(); |
|
| 1265 | - if ($error != '') return $error; |
|
| 1266 | - else return self::check_version(true); |
|
| 1267 | - } elseif ($result['value'] == '22') { |
|
| 1268 | - $error = self::update_from_22(); |
|
| 1269 | - if ($error != '') return $error; |
|
| 1270 | - else return self::check_version(true); |
|
| 1271 | - } elseif ($result['value'] == '23') { |
|
| 1272 | - $error = self::update_from_23(); |
|
| 1273 | - if ($error != '') return $error; |
|
| 1274 | - else return self::check_version(true); |
|
| 1275 | - } elseif ($result['value'] == '24') { |
|
| 1276 | - $error = self::update_from_24(); |
|
| 1277 | - if ($error != '') return $error; |
|
| 1278 | - else return self::check_version(true); |
|
| 1279 | - } elseif ($result['value'] == '25') { |
|
| 1280 | - $error = self::update_from_25(); |
|
| 1281 | - if ($error != '') return $error; |
|
| 1282 | - else return self::check_version(true); |
|
| 1283 | - } elseif ($result['value'] == '26') { |
|
| 1284 | - $error = self::update_from_26(); |
|
| 1285 | - if ($error != '') return $error; |
|
| 1286 | - else return self::check_version(true); |
|
| 1287 | - } elseif ($result['value'] == '27') { |
|
| 1288 | - $error = self::update_from_27(); |
|
| 1289 | - if ($error != '') return $error; |
|
| 1290 | - else return self::check_version(true); |
|
| 1291 | - } else return ''; |
|
| 1292 | - } |
|
| 1293 | - else return $result['value']; |
|
| 1184 | + } |
|
| 1185 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1186 | + if ($update) { |
|
| 1187 | + if ($result['value'] == '2') { |
|
| 1188 | + $error = self::update_from_2(); |
|
| 1189 | + if ($error != '') return $error; |
|
| 1190 | + else return self::check_version(true); |
|
| 1191 | + } elseif ($result['value'] == '3') { |
|
| 1192 | + $error = self::update_from_3(); |
|
| 1193 | + if ($error != '') return $error; |
|
| 1194 | + else return self::check_version(true); |
|
| 1195 | + } elseif ($result['value'] == '4') { |
|
| 1196 | + $error = self::update_from_4(); |
|
| 1197 | + if ($error != '') return $error; |
|
| 1198 | + else return self::check_version(true); |
|
| 1199 | + } elseif ($result['value'] == '5') { |
|
| 1200 | + $error = self::update_from_5(); |
|
| 1201 | + if ($error != '') return $error; |
|
| 1202 | + else return self::check_version(true); |
|
| 1203 | + } elseif ($result['value'] == '6') { |
|
| 1204 | + $error = self::update_from_6(); |
|
| 1205 | + if ($error != '') return $error; |
|
| 1206 | + else return self::check_version(true); |
|
| 1207 | + } elseif ($result['value'] == '7') { |
|
| 1208 | + $error = self::update_from_7(); |
|
| 1209 | + if ($error != '') return $error; |
|
| 1210 | + else return self::check_version(true); |
|
| 1211 | + } elseif ($result['value'] == '8') { |
|
| 1212 | + $error = self::update_from_8(); |
|
| 1213 | + if ($error != '') return $error; |
|
| 1214 | + else return self::check_version(true); |
|
| 1215 | + } elseif ($result['value'] == '9') { |
|
| 1216 | + $error = self::update_from_9(); |
|
| 1217 | + if ($error != '') return $error; |
|
| 1218 | + else return self::check_version(true); |
|
| 1219 | + } elseif ($result['value'] == '10') { |
|
| 1220 | + $error = self::update_from_10(); |
|
| 1221 | + if ($error != '') return $error; |
|
| 1222 | + else return self::check_version(true); |
|
| 1223 | + } elseif ($result['value'] == '11') { |
|
| 1224 | + $error = self::update_from_11(); |
|
| 1225 | + if ($error != '') return $error; |
|
| 1226 | + else return self::check_version(true); |
|
| 1227 | + } elseif ($result['value'] == '12') { |
|
| 1228 | + $error = self::update_from_12(); |
|
| 1229 | + if ($error != '') return $error; |
|
| 1230 | + else return self::check_version(true); |
|
| 1231 | + } elseif ($result['value'] == '13') { |
|
| 1232 | + $error = self::update_from_13(); |
|
| 1233 | + if ($error != '') return $error; |
|
| 1234 | + else return self::check_version(true); |
|
| 1235 | + } elseif ($result['value'] == '14') { |
|
| 1236 | + $error = self::update_from_14(); |
|
| 1237 | + if ($error != '') return $error; |
|
| 1238 | + else return self::check_version(true); |
|
| 1239 | + } elseif ($result['value'] == '15') { |
|
| 1240 | + $error = self::update_from_15(); |
|
| 1241 | + if ($error != '') return $error; |
|
| 1242 | + else return self::check_version(true); |
|
| 1243 | + } elseif ($result['value'] == '16') { |
|
| 1244 | + $error = self::update_from_16(); |
|
| 1245 | + if ($error != '') return $error; |
|
| 1246 | + else return self::check_version(true); |
|
| 1247 | + } elseif ($result['value'] == '17') { |
|
| 1248 | + $error = self::update_from_17(); |
|
| 1249 | + if ($error != '') return $error; |
|
| 1250 | + else return self::check_version(true); |
|
| 1251 | + } elseif ($result['value'] == '18') { |
|
| 1252 | + $error = self::update_from_18(); |
|
| 1253 | + if ($error != '') return $error; |
|
| 1254 | + else return self::check_version(true); |
|
| 1255 | + } elseif ($result['value'] == '19') { |
|
| 1256 | + $error = self::update_from_19(); |
|
| 1257 | + if ($error != '') return $error; |
|
| 1258 | + else return self::check_version(true); |
|
| 1259 | + } elseif ($result['value'] == '20') { |
|
| 1260 | + $error = self::update_from_20(); |
|
| 1261 | + if ($error != '') return $error; |
|
| 1262 | + else return self::check_version(true); |
|
| 1263 | + } elseif ($result['value'] == '21') { |
|
| 1264 | + $error = self::update_from_21(); |
|
| 1265 | + if ($error != '') return $error; |
|
| 1266 | + else return self::check_version(true); |
|
| 1267 | + } elseif ($result['value'] == '22') { |
|
| 1268 | + $error = self::update_from_22(); |
|
| 1269 | + if ($error != '') return $error; |
|
| 1270 | + else return self::check_version(true); |
|
| 1271 | + } elseif ($result['value'] == '23') { |
|
| 1272 | + $error = self::update_from_23(); |
|
| 1273 | + if ($error != '') return $error; |
|
| 1274 | + else return self::check_version(true); |
|
| 1275 | + } elseif ($result['value'] == '24') { |
|
| 1276 | + $error = self::update_from_24(); |
|
| 1277 | + if ($error != '') return $error; |
|
| 1278 | + else return self::check_version(true); |
|
| 1279 | + } elseif ($result['value'] == '25') { |
|
| 1280 | + $error = self::update_from_25(); |
|
| 1281 | + if ($error != '') return $error; |
|
| 1282 | + else return self::check_version(true); |
|
| 1283 | + } elseif ($result['value'] == '26') { |
|
| 1284 | + $error = self::update_from_26(); |
|
| 1285 | + if ($error != '') return $error; |
|
| 1286 | + else return self::check_version(true); |
|
| 1287 | + } elseif ($result['value'] == '27') { |
|
| 1288 | + $error = self::update_from_27(); |
|
| 1289 | + if ($error != '') return $error; |
|
| 1290 | + else return self::check_version(true); |
|
| 1291 | + } else return ''; |
|
| 1292 | + } |
|
| 1293 | + else return $result['value']; |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - } else return $version; |
|
| 1297 | - } |
|
| 1296 | + } else return $version; |
|
| 1297 | + } |
|
| 1298 | 1298 | |
| 1299 | 1299 | } |
| 1300 | 1300 | //echo update_schema::check_version(); |
@@ -258,7 +258,9 @@ discard block |
||
| 258 | 258 | // Update table countries |
| 259 | 259 | if ($Connection->tableExists('airspace')) { |
| 260 | 260 | $error .= update_db::update_countries(); |
| 261 | - if ($error != '') return $error; |
|
| 261 | + if ($error != '') { |
|
| 262 | + return $error; |
|
| 263 | + } |
|
| 262 | 264 | } |
| 263 | 265 | // Update schema_version to 7 |
| 264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
| 314 | 316 | $error = ''; |
| 315 | 317 | // Update table aircraft |
| 316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
| 317 | - if ($error != '') return $error; |
|
| 319 | + if ($error != '') { |
|
| 320 | + return $error; |
|
| 321 | + } |
|
| 318 | 322 | // Update schema_version to 6 |
| 319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
| 320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
| 331 | 335 | $error = ''; |
| 332 | 336 | // Update table aircraft |
| 333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
| 334 | - if ($error != '') return $error; |
|
| 338 | + if ($error != '') { |
|
| 339 | + return $error; |
|
| 340 | + } |
|
| 335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
| 336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
| 337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
| 365 | 371 | $error = ''; |
| 366 | 372 | // Update table atc |
| 367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
| 368 | - if ($error != '') return $error; |
|
| 374 | + if ($error != '') { |
|
| 375 | + return $error; |
|
| 376 | + } |
|
| 369 | 377 | |
| 370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
| 371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
| 389 | 397 | $error = ''; |
| 390 | 398 | // Add tables |
| 391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
| 392 | - if ($error != '') return $error; |
|
| 400 | + if ($error != '') { |
|
| 401 | + return $error; |
|
| 402 | + } |
|
| 393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
| 394 | - if ($error != '') return $error; |
|
| 404 | + if ($error != '') { |
|
| 405 | + return $error; |
|
| 406 | + } |
|
| 395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
| 396 | - if ($error != '') return $error; |
|
| 408 | + if ($error != '') { |
|
| 409 | + return $error; |
|
| 410 | + } |
|
| 397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
| 398 | - if ($error != '') return $error; |
|
| 412 | + if ($error != '') { |
|
| 413 | + return $error; |
|
| 414 | + } |
|
| 399 | 415 | |
| 400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
| 401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
| 469 | 485 | $error = ''; |
| 470 | 486 | // Add tables |
| 471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
| 472 | - if ($error != '') return $error; |
|
| 488 | + if ($error != '') { |
|
| 489 | + return $error; |
|
| 490 | + } |
|
| 473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
| 474 | - if ($error != '') return $error; |
|
| 492 | + if ($error != '') { |
|
| 493 | + return $error; |
|
| 494 | + } |
|
| 475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
| 476 | - if ($error != '') return $error; |
|
| 496 | + if ($error != '') { |
|
| 497 | + return $error; |
|
| 498 | + } |
|
| 477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
| 478 | - if ($error != '') return $error; |
|
| 500 | + if ($error != '') { |
|
| 501 | + return $error; |
|
| 502 | + } |
|
| 479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
| 480 | - if ($error != '') return $error; |
|
| 504 | + if ($error != '') { |
|
| 505 | + return $error; |
|
| 506 | + } |
|
| 481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
| 482 | - if ($error != '') return $error; |
|
| 508 | + if ($error != '') { |
|
| 509 | + return $error; |
|
| 510 | + } |
|
| 483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
| 484 | - if ($error != '') return $error; |
|
| 512 | + if ($error != '') { |
|
| 513 | + return $error; |
|
| 514 | + } |
|
| 485 | 515 | |
| 486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
| 487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
| 521 | 551 | // Add tables |
| 522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
| 523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
| 524 | - if ($error != '') return $error; |
|
| 554 | + if ($error != '') { |
|
| 555 | + return $error; |
|
| 556 | + } |
|
| 525 | 557 | } |
| 526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
| 527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
| 545 | 577 | } catch(PDOException $e) { |
| 546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 547 | 579 | } |
| 548 | - if ($error != '') return $error; |
|
| 580 | + if ($error != '') { |
|
| 581 | + return $error; |
|
| 582 | + } |
|
| 549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 550 | 584 | try { |
| 551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
| 566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
| 567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
| 568 | 602 | } |
| 569 | - if ($error != '') return $error; |
|
| 603 | + if ($error != '') { |
|
| 604 | + return $error; |
|
| 605 | + } |
|
| 570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
| 571 | 607 | try { |
| 572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
| 584 | 620 | if (!$Connection->tableExists('stats_country')) { |
| 585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
| 586 | 622 | } |
| 587 | - if ($error != '') return $error; |
|
| 623 | + if ($error != '') { |
|
| 624 | + return $error; |
|
| 625 | + } |
|
| 588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
| 589 | 627 | try { |
| 590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
| 607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 608 | 646 | } |
| 609 | 647 | } |
| 610 | - if ($error != '') return $error; |
|
| 648 | + if ($error != '') { |
|
| 649 | + return $error; |
|
| 650 | + } |
|
| 611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 612 | 652 | try { |
| 613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
| 623 | 663 | $error = ''; |
| 624 | 664 | // Update airport table |
| 625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
| 626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
| 666 | + if ($error != '') { |
|
| 667 | + return 'Import airport.sql : '.$error; |
|
| 668 | + } |
|
| 627 | 669 | // Remove primary key on Spotter_Archive |
| 628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
| 629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
| 699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | 742 | } |
| 701 | 743 | } |
| 702 | - if ($error != '') return $error; |
|
| 744 | + if ($error != '') { |
|
| 745 | + return $error; |
|
| 746 | + } |
|
| 703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
| 704 | 748 | try { |
| 705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
| 717 | 761 | // Update airline table |
| 718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 764 | + if ($error != '') { |
|
| 765 | + return 'Import airlines.sql : '.$error; |
|
| 766 | + } |
|
| 721 | 767 | } |
| 722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
| 723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
| 729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | 776 | } |
| 731 | 777 | } |
| 732 | - if ($error != '') return $error; |
|
| 778 | + if ($error != '') { |
|
| 779 | + return $error; |
|
| 780 | + } |
|
| 733 | 781 | /* |
| 734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
| 759 | 807 | } catch(PDOException $e) { |
| 760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 761 | 809 | } |
| 762 | - if ($error != '') return $error; |
|
| 810 | + if ($error != '') { |
|
| 811 | + return $error; |
|
| 812 | + } |
|
| 763 | 813 | } |
| 764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
| 782 | 832 | } else { |
| 783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
| 784 | 834 | } |
| 785 | - if ($error != '') return $error; |
|
| 835 | + if ($error != '') { |
|
| 836 | + return $error; |
|
| 837 | + } |
|
| 786 | 838 | } |
| 787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
| 788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
| 804 | 856 | if ($globalDBdriver == 'mysql') { |
| 805 | 857 | if (!$Connection->tableExists('tle')) { |
| 806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
| 807 | - if ($error != '') return $error; |
|
| 859 | + if ($error != '') { |
|
| 860 | + return $error; |
|
| 861 | + } |
|
| 808 | 862 | } |
| 809 | 863 | } else { |
| 810 | 864 | if (!$Connection->tableExists('tle')) { |
| 811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
| 812 | - if ($error != '') return $error; |
|
| 866 | + if ($error != '') { |
|
| 867 | + return $error; |
|
| 868 | + } |
|
| 813 | 869 | } |
| 814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
| 815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
| 849 | 905 | } else { |
| 850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 851 | 907 | } |
| 852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 908 | + if ($error != '') { |
|
| 909 | + return 'Import airlines.sql : '.$error; |
|
| 910 | + } |
|
| 853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
| 854 | 912 | // Add forsource to airlines |
| 855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1171,8 +1229,11 @@ discard block |
||
| 1171 | 1229 | if ($Connection->tableExists('aircraft')) { |
| 1172 | 1230 | if (!$Connection->tableExists('config')) { |
| 1173 | 1231 | $version = '1'; |
| 1174 | - if ($update) return self::update_from_1(); |
|
| 1175 | - else return $version; |
|
| 1232 | + if ($update) { |
|
| 1233 | + return self::update_from_1(); |
|
| 1234 | + } else { |
|
| 1235 | + return $version; |
|
| 1236 | + } |
|
| 1176 | 1237 | } else { |
| 1177 | 1238 | $Connection = new Connection(); |
| 1178 | 1239 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1186,114 +1247,197 @@ discard block |
||
| 1186 | 1247 | if ($update) { |
| 1187 | 1248 | if ($result['value'] == '2') { |
| 1188 | 1249 | $error = self::update_from_2(); |
| 1189 | - if ($error != '') return $error; |
|
| 1190 | - else return self::check_version(true); |
|
| 1250 | + if ($error != '') { |
|
| 1251 | + return $error; |
|
| 1252 | + } else { |
|
| 1253 | + return self::check_version(true); |
|
| 1254 | + } |
|
| 1191 | 1255 | } elseif ($result['value'] == '3') { |
| 1192 | 1256 | $error = self::update_from_3(); |
| 1193 | - if ($error != '') return $error; |
|
| 1194 | - else return self::check_version(true); |
|
| 1257 | + if ($error != '') { |
|
| 1258 | + return $error; |
|
| 1259 | + } else { |
|
| 1260 | + return self::check_version(true); |
|
| 1261 | + } |
|
| 1195 | 1262 | } elseif ($result['value'] == '4') { |
| 1196 | 1263 | $error = self::update_from_4(); |
| 1197 | - if ($error != '') return $error; |
|
| 1198 | - else return self::check_version(true); |
|
| 1264 | + if ($error != '') { |
|
| 1265 | + return $error; |
|
| 1266 | + } else { |
|
| 1267 | + return self::check_version(true); |
|
| 1268 | + } |
|
| 1199 | 1269 | } elseif ($result['value'] == '5') { |
| 1200 | 1270 | $error = self::update_from_5(); |
| 1201 | - if ($error != '') return $error; |
|
| 1202 | - else return self::check_version(true); |
|
| 1271 | + if ($error != '') { |
|
| 1272 | + return $error; |
|
| 1273 | + } else { |
|
| 1274 | + return self::check_version(true); |
|
| 1275 | + } |
|
| 1203 | 1276 | } elseif ($result['value'] == '6') { |
| 1204 | 1277 | $error = self::update_from_6(); |
| 1205 | - if ($error != '') return $error; |
|
| 1206 | - else return self::check_version(true); |
|
| 1278 | + if ($error != '') { |
|
| 1279 | + return $error; |
|
| 1280 | + } else { |
|
| 1281 | + return self::check_version(true); |
|
| 1282 | + } |
|
| 1207 | 1283 | } elseif ($result['value'] == '7') { |
| 1208 | 1284 | $error = self::update_from_7(); |
| 1209 | - if ($error != '') return $error; |
|
| 1210 | - else return self::check_version(true); |
|
| 1285 | + if ($error != '') { |
|
| 1286 | + return $error; |
|
| 1287 | + } else { |
|
| 1288 | + return self::check_version(true); |
|
| 1289 | + } |
|
| 1211 | 1290 | } elseif ($result['value'] == '8') { |
| 1212 | 1291 | $error = self::update_from_8(); |
| 1213 | - if ($error != '') return $error; |
|
| 1214 | - else return self::check_version(true); |
|
| 1292 | + if ($error != '') { |
|
| 1293 | + return $error; |
|
| 1294 | + } else { |
|
| 1295 | + return self::check_version(true); |
|
| 1296 | + } |
|
| 1215 | 1297 | } elseif ($result['value'] == '9') { |
| 1216 | 1298 | $error = self::update_from_9(); |
| 1217 | - if ($error != '') return $error; |
|
| 1218 | - else return self::check_version(true); |
|
| 1299 | + if ($error != '') { |
|
| 1300 | + return $error; |
|
| 1301 | + } else { |
|
| 1302 | + return self::check_version(true); |
|
| 1303 | + } |
|
| 1219 | 1304 | } elseif ($result['value'] == '10') { |
| 1220 | 1305 | $error = self::update_from_10(); |
| 1221 | - if ($error != '') return $error; |
|
| 1222 | - else return self::check_version(true); |
|
| 1306 | + if ($error != '') { |
|
| 1307 | + return $error; |
|
| 1308 | + } else { |
|
| 1309 | + return self::check_version(true); |
|
| 1310 | + } |
|
| 1223 | 1311 | } elseif ($result['value'] == '11') { |
| 1224 | 1312 | $error = self::update_from_11(); |
| 1225 | - if ($error != '') return $error; |
|
| 1226 | - else return self::check_version(true); |
|
| 1313 | + if ($error != '') { |
|
| 1314 | + return $error; |
|
| 1315 | + } else { |
|
| 1316 | + return self::check_version(true); |
|
| 1317 | + } |
|
| 1227 | 1318 | } elseif ($result['value'] == '12') { |
| 1228 | 1319 | $error = self::update_from_12(); |
| 1229 | - if ($error != '') return $error; |
|
| 1230 | - else return self::check_version(true); |
|
| 1320 | + if ($error != '') { |
|
| 1321 | + return $error; |
|
| 1322 | + } else { |
|
| 1323 | + return self::check_version(true); |
|
| 1324 | + } |
|
| 1231 | 1325 | } elseif ($result['value'] == '13') { |
| 1232 | 1326 | $error = self::update_from_13(); |
| 1233 | - if ($error != '') return $error; |
|
| 1234 | - else return self::check_version(true); |
|
| 1327 | + if ($error != '') { |
|
| 1328 | + return $error; |
|
| 1329 | + } else { |
|
| 1330 | + return self::check_version(true); |
|
| 1331 | + } |
|
| 1235 | 1332 | } elseif ($result['value'] == '14') { |
| 1236 | 1333 | $error = self::update_from_14(); |
| 1237 | - if ($error != '') return $error; |
|
| 1238 | - else return self::check_version(true); |
|
| 1334 | + if ($error != '') { |
|
| 1335 | + return $error; |
|
| 1336 | + } else { |
|
| 1337 | + return self::check_version(true); |
|
| 1338 | + } |
|
| 1239 | 1339 | } elseif ($result['value'] == '15') { |
| 1240 | 1340 | $error = self::update_from_15(); |
| 1241 | - if ($error != '') return $error; |
|
| 1242 | - else return self::check_version(true); |
|
| 1341 | + if ($error != '') { |
|
| 1342 | + return $error; |
|
| 1343 | + } else { |
|
| 1344 | + return self::check_version(true); |
|
| 1345 | + } |
|
| 1243 | 1346 | } elseif ($result['value'] == '16') { |
| 1244 | 1347 | $error = self::update_from_16(); |
| 1245 | - if ($error != '') return $error; |
|
| 1246 | - else return self::check_version(true); |
|
| 1348 | + if ($error != '') { |
|
| 1349 | + return $error; |
|
| 1350 | + } else { |
|
| 1351 | + return self::check_version(true); |
|
| 1352 | + } |
|
| 1247 | 1353 | } elseif ($result['value'] == '17') { |
| 1248 | 1354 | $error = self::update_from_17(); |
| 1249 | - if ($error != '') return $error; |
|
| 1250 | - else return self::check_version(true); |
|
| 1355 | + if ($error != '') { |
|
| 1356 | + return $error; |
|
| 1357 | + } else { |
|
| 1358 | + return self::check_version(true); |
|
| 1359 | + } |
|
| 1251 | 1360 | } elseif ($result['value'] == '18') { |
| 1252 | 1361 | $error = self::update_from_18(); |
| 1253 | - if ($error != '') return $error; |
|
| 1254 | - else return self::check_version(true); |
|
| 1362 | + if ($error != '') { |
|
| 1363 | + return $error; |
|
| 1364 | + } else { |
|
| 1365 | + return self::check_version(true); |
|
| 1366 | + } |
|
| 1255 | 1367 | } elseif ($result['value'] == '19') { |
| 1256 | 1368 | $error = self::update_from_19(); |
| 1257 | - if ($error != '') return $error; |
|
| 1258 | - else return self::check_version(true); |
|
| 1369 | + if ($error != '') { |
|
| 1370 | + return $error; |
|
| 1371 | + } else { |
|
| 1372 | + return self::check_version(true); |
|
| 1373 | + } |
|
| 1259 | 1374 | } elseif ($result['value'] == '20') { |
| 1260 | 1375 | $error = self::update_from_20(); |
| 1261 | - if ($error != '') return $error; |
|
| 1262 | - else return self::check_version(true); |
|
| 1376 | + if ($error != '') { |
|
| 1377 | + return $error; |
|
| 1378 | + } else { |
|
| 1379 | + return self::check_version(true); |
|
| 1380 | + } |
|
| 1263 | 1381 | } elseif ($result['value'] == '21') { |
| 1264 | 1382 | $error = self::update_from_21(); |
| 1265 | - if ($error != '') return $error; |
|
| 1266 | - else return self::check_version(true); |
|
| 1383 | + if ($error != '') { |
|
| 1384 | + return $error; |
|
| 1385 | + } else { |
|
| 1386 | + return self::check_version(true); |
|
| 1387 | + } |
|
| 1267 | 1388 | } elseif ($result['value'] == '22') { |
| 1268 | 1389 | $error = self::update_from_22(); |
| 1269 | - if ($error != '') return $error; |
|
| 1270 | - else return self::check_version(true); |
|
| 1390 | + if ($error != '') { |
|
| 1391 | + return $error; |
|
| 1392 | + } else { |
|
| 1393 | + return self::check_version(true); |
|
| 1394 | + } |
|
| 1271 | 1395 | } elseif ($result['value'] == '23') { |
| 1272 | 1396 | $error = self::update_from_23(); |
| 1273 | - if ($error != '') return $error; |
|
| 1274 | - else return self::check_version(true); |
|
| 1397 | + if ($error != '') { |
|
| 1398 | + return $error; |
|
| 1399 | + } else { |
|
| 1400 | + return self::check_version(true); |
|
| 1401 | + } |
|
| 1275 | 1402 | } elseif ($result['value'] == '24') { |
| 1276 | 1403 | $error = self::update_from_24(); |
| 1277 | - if ($error != '') return $error; |
|
| 1278 | - else return self::check_version(true); |
|
| 1404 | + if ($error != '') { |
|
| 1405 | + return $error; |
|
| 1406 | + } else { |
|
| 1407 | + return self::check_version(true); |
|
| 1408 | + } |
|
| 1279 | 1409 | } elseif ($result['value'] == '25') { |
| 1280 | 1410 | $error = self::update_from_25(); |
| 1281 | - if ($error != '') return $error; |
|
| 1282 | - else return self::check_version(true); |
|
| 1411 | + if ($error != '') { |
|
| 1412 | + return $error; |
|
| 1413 | + } else { |
|
| 1414 | + return self::check_version(true); |
|
| 1415 | + } |
|
| 1283 | 1416 | } elseif ($result['value'] == '26') { |
| 1284 | 1417 | $error = self::update_from_26(); |
| 1285 | - if ($error != '') return $error; |
|
| 1286 | - else return self::check_version(true); |
|
| 1418 | + if ($error != '') { |
|
| 1419 | + return $error; |
|
| 1420 | + } else { |
|
| 1421 | + return self::check_version(true); |
|
| 1422 | + } |
|
| 1287 | 1423 | } elseif ($result['value'] == '27') { |
| 1288 | 1424 | $error = self::update_from_27(); |
| 1289 | - if ($error != '') return $error; |
|
| 1290 | - else return self::check_version(true); |
|
| 1291 | - } else return ''; |
|
| 1425 | + if ($error != '') { |
|
| 1426 | + return $error; |
|
| 1427 | + } else { |
|
| 1428 | + return self::check_version(true); |
|
| 1429 | + } |
|
| 1430 | + } else { |
|
| 1431 | + return ''; |
|
| 1432 | + } |
|
| 1433 | + } else { |
|
| 1434 | + return $result['value']; |
|
| 1292 | 1435 | } |
| 1293 | - else return $result['value']; |
|
| 1294 | 1436 | } |
| 1295 | 1437 | |
| 1296 | - } else return $version; |
|
| 1438 | + } else { |
|
| 1439 | + return $version; |
|
| 1440 | + } |
|
| 1297 | 1441 | } |
| 1298 | 1442 | |
| 1299 | 1443 | } |