@@ -13,10 +13,14 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct($dbc = null) { |
| 15 | 15 | global $globalFilterName; |
| 16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 16 | + if (isset($globalFilterName)) { |
|
| 17 | + $this->filter_name = $globalFilterName; |
|
| 18 | + } |
|
| 17 | 19 | $Connection = new Connection($dbc); |
| 18 | 20 | $this->db = $Connection->db(); |
| 19 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 21 | + if ($this->db === null) { |
|
| 22 | + die('Error: No DB connection.'); |
|
| 23 | + } |
|
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | |
| 85 | 89 | public function getAllAirlineNames($filter_name = '') { |
| 86 | 90 | global $globalStatsFilters; |
| 87 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 91 | + if ($filter_name == '') { |
|
| 92 | + $filter_name = $this->filter_name; |
|
| 93 | + } |
|
| 88 | 94 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 89 | 95 | try { |
| 90 | 96 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | return $all; |
| 105 | 111 | } |
| 106 | 112 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 113 | + if ($filter_name == '') { |
|
| 114 | + $filter_name = $this->filter_name; |
|
| 115 | + } |
|
| 108 | 116 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 109 | 117 | try { |
| 110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | return $all; |
| 117 | 125 | } |
| 118 | 126 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 127 | + if ($filter_name == '') { |
|
| 128 | + $filter_name = $this->filter_name; |
|
| 129 | + } |
|
| 120 | 130 | $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"; |
| 121 | 131 | try { |
| 122 | 132 | $sth = $this->db->prepare($query); |
@@ -128,7 +138,9 @@ discard block |
||
| 128 | 138 | return $all; |
| 129 | 139 | } |
| 130 | 140 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 131 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 141 | + if ($filter_name == '') { |
|
| 142 | + $filter_name = $this->filter_name; |
|
| 143 | + } |
|
| 132 | 144 | $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"; |
| 133 | 145 | try { |
| 134 | 146 | $sth = $this->db->prepare($query); |
@@ -141,7 +153,9 @@ discard block |
||
| 141 | 153 | } |
| 142 | 154 | |
| 143 | 155 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 144 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 156 | + if ($filter_name == '') { |
|
| 157 | + $filter_name = $this->filter_name; |
|
| 158 | + } |
|
| 145 | 159 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 146 | 160 | try { |
| 147 | 161 | $sth = $this->db->prepare($query); |
@@ -154,7 +168,9 @@ discard block |
||
| 154 | 168 | } |
| 155 | 169 | |
| 156 | 170 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 171 | + if ($filter_name == '') { |
|
| 172 | + $filter_name = $this->filter_name; |
|
| 173 | + } |
|
| 158 | 174 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 159 | 175 | try { |
| 160 | 176 | $sth = $this->db->prepare($query); |
@@ -169,7 +185,9 @@ discard block |
||
| 169 | 185 | |
| 170 | 186 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 171 | 187 | global $globalStatsFilters; |
| 172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 188 | + if ($filter_name == '') { |
|
| 189 | + $filter_name = $this->filter_name; |
|
| 190 | + } |
|
| 173 | 191 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 174 | 192 | $Spotter = new Spotter($this->db); |
| 175 | 193 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -178,8 +196,11 @@ discard block |
||
| 178 | 196 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 179 | 197 | } |
| 180 | 198 | if ($year == '' && $month == '') { |
| 181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 199 | + if ($limit) { |
|
| 200 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 201 | + } else { |
|
| 202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 203 | + } |
|
| 183 | 204 | try { |
| 184 | 205 | $sth = $this->db->prepare($query); |
| 185 | 206 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -187,11 +208,16 @@ discard block |
||
| 187 | 208 | echo "error : ".$e->getMessage(); |
| 188 | 209 | } |
| 189 | 210 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 190 | - } else $all = array(); |
|
| 211 | + } else { |
|
| 212 | + $all = array(); |
|
| 213 | + } |
|
| 191 | 214 | } else { |
| 192 | 215 | if ($year == '' && $month == '') { |
| 193 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
| 194 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
| 216 | + if ($limit) { |
|
| 217 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
| 218 | + } else { |
|
| 219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
| 220 | + } |
|
| 195 | 221 | try { |
| 196 | 222 | $sth = $this->db->prepare($query); |
| 197 | 223 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,7 +225,9 @@ discard block |
||
| 199 | 225 | echo "error : ".$e->getMessage(); |
| 200 | 226 | } |
| 201 | 227 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 202 | - } else $all = array(); |
|
| 228 | + } else { |
|
| 229 | + $all = array(); |
|
| 230 | + } |
|
| 203 | 231 | } |
| 204 | 232 | if (empty($all)) { |
| 205 | 233 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -218,10 +246,15 @@ discard block |
||
| 218 | 246 | } |
| 219 | 247 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 220 | 248 | global $globalStatsFilters; |
| 221 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 249 | + if ($filter_name == '') { |
|
| 250 | + $filter_name = $this->filter_name; |
|
| 251 | + } |
|
| 222 | 252 | if ($year == '' && $month == '') { |
| 223 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 224 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 253 | + if ($limit) { |
|
| 254 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 255 | + } else { |
|
| 256 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 257 | + } |
|
| 225 | 258 | try { |
| 226 | 259 | $sth = $this->db->prepare($query); |
| 227 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -229,7 +262,9 @@ discard block |
||
| 229 | 262 | echo "error : ".$e->getMessage(); |
| 230 | 263 | } |
| 231 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 232 | - } else $all = array(); |
|
| 265 | + } else { |
|
| 266 | + $all = array(); |
|
| 267 | + } |
|
| 233 | 268 | if (empty($all)) { |
| 234 | 269 | $Spotter = new Spotter($this->db); |
| 235 | 270 | $filters = array(); |
@@ -244,7 +279,9 @@ discard block |
||
| 244 | 279 | } |
| 245 | 280 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 246 | 281 | global $globalStatsFilters; |
| 247 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 282 | + if ($filter_name == '') { |
|
| 283 | + $filter_name = $this->filter_name; |
|
| 284 | + } |
|
| 248 | 285 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 249 | 286 | $Spotter = new Spotter($this->db); |
| 250 | 287 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -253,8 +290,11 @@ discard block |
||
| 253 | 290 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 254 | 291 | } |
| 255 | 292 | if ($year == '' && $month == '') { |
| 256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 293 | + if ($limit) { |
|
| 294 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 295 | + } else { |
|
| 296 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 297 | + } |
|
| 258 | 298 | try { |
| 259 | 299 | $sth = $this->db->prepare($query); |
| 260 | 300 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -262,11 +302,16 @@ discard block |
||
| 262 | 302 | echo "error : ".$e->getMessage(); |
| 263 | 303 | } |
| 264 | 304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 265 | - } else $all = array(); |
|
| 305 | + } else { |
|
| 306 | + $all = array(); |
|
| 307 | + } |
|
| 266 | 308 | } else { |
| 267 | 309 | if ($year == '' && $month == '') { |
| 268 | - 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"; |
|
| 269 | - 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"; |
|
| 310 | + if ($limit) { |
|
| 311 | + $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"; |
|
| 312 | + } else { |
|
| 313 | + $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"; |
|
| 314 | + } |
|
| 270 | 315 | try { |
| 271 | 316 | $sth = $this->db->prepare($query); |
| 272 | 317 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,7 +319,9 @@ discard block |
||
| 274 | 319 | echo "error : ".$e->getMessage(); |
| 275 | 320 | } |
| 276 | 321 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 277 | - } else $all = array(); |
|
| 322 | + } else { |
|
| 323 | + $all = array(); |
|
| 324 | + } |
|
| 278 | 325 | } |
| 279 | 326 | if (empty($all)) { |
| 280 | 327 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -294,7 +341,9 @@ discard block |
||
| 294 | 341 | |
| 295 | 342 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 296 | 343 | global $globalStatsFilters; |
| 297 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 344 | + if ($filter_name == '') { |
|
| 345 | + $filter_name = $this->filter_name; |
|
| 346 | + } |
|
| 298 | 347 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 299 | 348 | $Spotter = new Spotter($this->db); |
| 300 | 349 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -303,8 +352,11 @@ discard block |
||
| 303 | 352 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 304 | 353 | } |
| 305 | 354 | if ($year == '' && $month == '') { |
| 306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 355 | + if ($limit) { |
|
| 356 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 357 | + } else { |
|
| 358 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 359 | + } |
|
| 308 | 360 | try { |
| 309 | 361 | $sth = $this->db->prepare($query); |
| 310 | 362 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -312,11 +364,16 @@ discard block |
||
| 312 | 364 | echo "error : ".$e->getMessage(); |
| 313 | 365 | } |
| 314 | 366 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 315 | - } else $all = array(); |
|
| 367 | + } else { |
|
| 368 | + $all = array(); |
|
| 369 | + } |
|
| 316 | 370 | } else { |
| 317 | 371 | if ($year == '' && $month == '') { |
| 318 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 319 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 372 | + if ($limit) { |
|
| 373 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 374 | + } else { |
|
| 375 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 376 | + } |
|
| 320 | 377 | try { |
| 321 | 378 | $sth = $this->db->prepare($query); |
| 322 | 379 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -324,7 +381,9 @@ discard block |
||
| 324 | 381 | echo "error : ".$e->getMessage(); |
| 325 | 382 | } |
| 326 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 327 | - } else $all = array(); |
|
| 384 | + } else { |
|
| 385 | + $all = array(); |
|
| 386 | + } |
|
| 328 | 387 | } |
| 329 | 388 | if (empty($all)) { |
| 330 | 389 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -343,7 +402,9 @@ discard block |
||
| 343 | 402 | } |
| 344 | 403 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 345 | 404 | global $globalStatsFilters; |
| 346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 405 | + if ($filter_name == '') { |
|
| 406 | + $filter_name = $this->filter_name; |
|
| 407 | + } |
|
| 347 | 408 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 348 | 409 | $Spotter = new Spotter($this->db); |
| 349 | 410 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -351,12 +412,18 @@ discard block |
||
| 351 | 412 | foreach ($airlines as $airline) { |
| 352 | 413 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 353 | 414 | } |
| 354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 415 | + if ($limit) { |
|
| 416 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 417 | + } else { |
|
| 418 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 419 | + } |
|
| 356 | 420 | $query_values = array(':filter_name' => $filter_name); |
| 357 | 421 | } else { |
| 358 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 359 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 422 | + if ($limit) { |
|
| 423 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 424 | + } else { |
|
| 425 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 426 | + } |
|
| 360 | 427 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 361 | 428 | } |
| 362 | 429 | try { |
@@ -384,17 +451,29 @@ discard block |
||
| 384 | 451 | |
| 385 | 452 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 386 | 453 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 387 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 454 | + if ($filter_name == '') { |
|
| 455 | + $filter_name = $this->filter_name; |
|
| 456 | + } |
|
| 388 | 457 | if ($year == '' && $month == '') { |
| 389 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 390 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 458 | + if ($globalVATSIM) { |
|
| 459 | + $forsource = 'vatsim'; |
|
| 460 | + } |
|
| 461 | + if ($globalIVAO) { |
|
| 462 | + $forsource = 'ivao'; |
|
| 463 | + } |
|
| 391 | 464 | if (isset($forsource)) { |
| 392 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 393 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 465 | + if ($limit) { |
|
| 466 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 467 | + } else { |
|
| 468 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 469 | + } |
|
| 394 | 470 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 395 | 471 | } else { |
| 396 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 397 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 472 | + if ($limit) { |
|
| 473 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 474 | + } else { |
|
| 475 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 476 | + } |
|
| 398 | 477 | $query_values = array(':filter_name' => $filter_name); |
| 399 | 478 | } |
| 400 | 479 | try { |
@@ -404,7 +483,9 @@ discard block |
||
| 404 | 483 | echo "error : ".$e->getMessage(); |
| 405 | 484 | } |
| 406 | 485 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 407 | - } else $all = array(); |
|
| 486 | + } else { |
|
| 487 | + $all = array(); |
|
| 488 | + } |
|
| 408 | 489 | if (empty($all)) { |
| 409 | 490 | $Spotter = new Spotter($this->db); |
| 410 | 491 | $filters = array(); |
@@ -419,7 +500,9 @@ discard block |
||
| 419 | 500 | } |
| 420 | 501 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 421 | 502 | global $globalStatsFilters; |
| 422 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 503 | + if ($filter_name == '') { |
|
| 504 | + $filter_name = $this->filter_name; |
|
| 505 | + } |
|
| 423 | 506 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 424 | 507 | $Spotter = new Spotter($this->db); |
| 425 | 508 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -428,8 +511,11 @@ discard block |
||
| 428 | 511 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 429 | 512 | } |
| 430 | 513 | if ($year == '' && $month == '') { |
| 431 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 514 | + if ($limit) { |
|
| 515 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 516 | + } else { |
|
| 517 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 518 | + } |
|
| 433 | 519 | try { |
| 434 | 520 | $sth = $this->db->prepare($query); |
| 435 | 521 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -437,11 +523,16 @@ discard block |
||
| 437 | 523 | echo "error : ".$e->getMessage(); |
| 438 | 524 | } |
| 439 | 525 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 440 | - } else $all = array(); |
|
| 526 | + } else { |
|
| 527 | + $all = array(); |
|
| 528 | + } |
|
| 441 | 529 | } else { |
| 442 | 530 | if ($year == '' && $month == '') { |
| 443 | - 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"; |
|
| 444 | - 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"; |
|
| 531 | + if ($limit) { |
|
| 532 | + $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"; |
|
| 533 | + } else { |
|
| 534 | + $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"; |
|
| 535 | + } |
|
| 445 | 536 | try { |
| 446 | 537 | $sth = $this->db->prepare($query); |
| 447 | 538 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -449,7 +540,9 @@ discard block |
||
| 449 | 540 | echo "error : ".$e->getMessage(); |
| 450 | 541 | } |
| 451 | 542 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 452 | - } else $all = array(); |
|
| 543 | + } else { |
|
| 544 | + $all = array(); |
|
| 545 | + } |
|
| 453 | 546 | } |
| 454 | 547 | if (empty($all)) { |
| 455 | 548 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -468,7 +561,9 @@ discard block |
||
| 468 | 561 | } |
| 469 | 562 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 470 | 563 | global $globalStatsFilters; |
| 471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 564 | + if ($filter_name == '') { |
|
| 565 | + $filter_name = $this->filter_name; |
|
| 566 | + } |
|
| 472 | 567 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 473 | 568 | $Spotter = new Spotter($this->db); |
| 474 | 569 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -477,8 +572,11 @@ discard block |
||
| 477 | 572 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 478 | 573 | } |
| 479 | 574 | if ($year == '' && $month == '') { |
| 480 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 575 | + if ($limit) { |
|
| 576 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 577 | + } else { |
|
| 578 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 579 | + } |
|
| 482 | 580 | try { |
| 483 | 581 | $sth = $this->db->prepare($query); |
| 484 | 582 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -486,11 +584,16 @@ discard block |
||
| 486 | 584 | echo "error : ".$e->getMessage(); |
| 487 | 585 | } |
| 488 | 586 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 489 | - } else $all = array(); |
|
| 587 | + } else { |
|
| 588 | + $all = array(); |
|
| 589 | + } |
|
| 490 | 590 | } else { |
| 491 | 591 | if ($year == '' && $month == '') { |
| 492 | - 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"; |
|
| 493 | - 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"; |
|
| 592 | + if ($limit) { |
|
| 593 | + $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"; |
|
| 594 | + } else { |
|
| 595 | + $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"; |
|
| 596 | + } |
|
| 494 | 597 | try { |
| 495 | 598 | $sth = $this->db->prepare($query); |
| 496 | 599 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -498,7 +601,9 @@ discard block |
||
| 498 | 601 | echo "error : ".$e->getMessage(); |
| 499 | 602 | } |
| 500 | 603 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 501 | - } else $all = array(); |
|
| 604 | + } else { |
|
| 605 | + $all = array(); |
|
| 606 | + } |
|
| 502 | 607 | } |
| 503 | 608 | if (empty($all)) { |
| 504 | 609 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -517,7 +622,9 @@ discard block |
||
| 517 | 622 | } |
| 518 | 623 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 519 | 624 | $Connection = new Connection($this->db); |
| 520 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 625 | + if ($filter_name == '') { |
|
| 626 | + $filter_name = $this->filter_name; |
|
| 627 | + } |
|
| 521 | 628 | if ($Connection->tableExists('countries')) { |
| 522 | 629 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 523 | 630 | $Spotter = new Spotter($this->db); |
@@ -527,8 +634,11 @@ discard block |
||
| 527 | 634 | foreach ($airlines as $airline) { |
| 528 | 635 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 529 | 636 | } |
| 530 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 637 | + if ($limit) { |
|
| 638 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 639 | + } else { |
|
| 640 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 641 | + } |
|
| 532 | 642 | try { |
| 533 | 643 | $sth = $this->db->prepare($query); |
| 534 | 644 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -537,11 +647,16 @@ discard block |
||
| 537 | 647 | } |
| 538 | 648 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 539 | 649 | return $all; |
| 540 | - } else return array(); |
|
| 650 | + } else { |
|
| 651 | + return array(); |
|
| 652 | + } |
|
| 541 | 653 | } else { |
| 542 | 654 | if ($year == '' && $month == '') { |
| 543 | - 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"; |
|
| 544 | - 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"; |
|
| 655 | + if ($limit) { |
|
| 656 | + $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"; |
|
| 657 | + } else { |
|
| 658 | + $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"; |
|
| 659 | + } |
|
| 545 | 660 | try { |
| 546 | 661 | $sth = $this->db->prepare($query); |
| 547 | 662 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -550,7 +665,9 @@ discard block |
||
| 550 | 665 | } |
| 551 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 552 | 667 | return $all; |
| 553 | - } else return array(); |
|
| 668 | + } else { |
|
| 669 | + return array(); |
|
| 670 | + } |
|
| 554 | 671 | } |
| 555 | 672 | } else { |
| 556 | 673 | /* |
@@ -564,10 +681,15 @@ discard block |
||
| 564 | 681 | } |
| 565 | 682 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 566 | 683 | global $globalStatsFilters; |
| 567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 684 | + if ($filter_name == '') { |
|
| 685 | + $filter_name = $this->filter_name; |
|
| 686 | + } |
|
| 568 | 687 | if ($year == '' && $month == '') { |
| 569 | - 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"; |
|
| 570 | - 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"; |
|
| 688 | + if ($limit) { |
|
| 689 | + $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"; |
|
| 690 | + } else { |
|
| 691 | + $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"; |
|
| 692 | + } |
|
| 571 | 693 | try { |
| 572 | 694 | $sth = $this->db->prepare($query); |
| 573 | 695 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -575,7 +697,9 @@ discard block |
||
| 575 | 697 | echo "error : ".$e->getMessage(); |
| 576 | 698 | } |
| 577 | 699 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 578 | - } else $all = array(); |
|
| 700 | + } else { |
|
| 701 | + $all = array(); |
|
| 702 | + } |
|
| 579 | 703 | if (empty($all)) { |
| 580 | 704 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 581 | 705 | if ($filter_name != '') { |
@@ -590,7 +714,9 @@ discard block |
||
| 590 | 714 | |
| 591 | 715 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 592 | 716 | global $globalStatsFilters; |
| 593 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 717 | + if ($filter_name == '') { |
|
| 718 | + $filter_name = $this->filter_name; |
|
| 719 | + } |
|
| 594 | 720 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 595 | 721 | $Spotter = new Spotter($this->db); |
| 596 | 722 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -599,8 +725,11 @@ discard block |
||
| 599 | 725 | foreach ($airlines as $airline) { |
| 600 | 726 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 601 | 727 | } |
| 602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 728 | + if ($limit) { |
|
| 729 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 730 | + } else { |
|
| 731 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 732 | + } |
|
| 604 | 733 | try { |
| 605 | 734 | $sth = $this->db->prepare($query); |
| 606 | 735 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,11 +737,16 @@ discard block |
||
| 608 | 737 | echo "error : ".$e->getMessage(); |
| 609 | 738 | } |
| 610 | 739 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 611 | - } else $all = array(); |
|
| 740 | + } else { |
|
| 741 | + $all = array(); |
|
| 742 | + } |
|
| 612 | 743 | } else { |
| 613 | 744 | if ($year == '' && $month == '') { |
| 614 | - 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"; |
|
| 615 | - 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"; |
|
| 745 | + if ($limit) { |
|
| 746 | + $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"; |
|
| 747 | + } else { |
|
| 748 | + $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"; |
|
| 749 | + } |
|
| 616 | 750 | try { |
| 617 | 751 | $sth = $this->db->prepare($query); |
| 618 | 752 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -620,7 +754,9 @@ discard block |
||
| 620 | 754 | echo "error : ".$e->getMessage(); |
| 621 | 755 | } |
| 622 | 756 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | - } else $all = array(); |
|
| 757 | + } else { |
|
| 758 | + $all = array(); |
|
| 759 | + } |
|
| 624 | 760 | } |
| 625 | 761 | if (empty($all)) { |
| 626 | 762 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -639,7 +775,9 @@ discard block |
||
| 639 | 775 | } |
| 640 | 776 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 641 | 777 | global $globalStatsFilters; |
| 642 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 778 | + if ($filter_name == '') { |
|
| 779 | + $filter_name = $this->filter_name; |
|
| 780 | + } |
|
| 643 | 781 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 644 | 782 | $Spotter = new Spotter($this->db); |
| 645 | 783 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -648,8 +786,11 @@ discard block |
||
| 648 | 786 | foreach ($airlines as $airline) { |
| 649 | 787 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 650 | 788 | } |
| 651 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 789 | + if ($limit) { |
|
| 790 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 791 | + } else { |
|
| 792 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 793 | + } |
|
| 653 | 794 | try { |
| 654 | 795 | $sth = $this->db->prepare($query); |
| 655 | 796 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -657,11 +798,16 @@ discard block |
||
| 657 | 798 | echo "error : ".$e->getMessage(); |
| 658 | 799 | } |
| 659 | 800 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 660 | - } else $all = array(); |
|
| 801 | + } else { |
|
| 802 | + $all = array(); |
|
| 803 | + } |
|
| 661 | 804 | } else { |
| 662 | 805 | if ($year == '' && $month == '') { |
| 663 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
| 664 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 806 | + if ($limit) { |
|
| 807 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
| 808 | + } else { |
|
| 809 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 810 | + } |
|
| 665 | 811 | try { |
| 666 | 812 | $sth = $this->db->prepare($query); |
| 667 | 813 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -669,7 +815,9 @@ discard block |
||
| 669 | 815 | echo "error : ".$e->getMessage(); |
| 670 | 816 | } |
| 671 | 817 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | - } else $all = array(); |
|
| 818 | + } else { |
|
| 819 | + $all = array(); |
|
| 820 | + } |
|
| 673 | 821 | } |
| 674 | 822 | if (empty($all)) { |
| 675 | 823 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -694,7 +842,9 @@ discard block |
||
| 694 | 842 | $icao = $value['airport_departure_icao']; |
| 695 | 843 | if (isset($all[$icao])) { |
| 696 | 844 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 697 | - } else $all[$icao] = $value; |
|
| 845 | + } else { |
|
| 846 | + $all[$icao] = $value; |
|
| 847 | + } |
|
| 698 | 848 | } |
| 699 | 849 | $count = array(); |
| 700 | 850 | foreach ($all as $key => $row) { |
@@ -706,7 +856,9 @@ discard block |
||
| 706 | 856 | } |
| 707 | 857 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 708 | 858 | global $globalStatsFilters; |
| 709 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 859 | + if ($filter_name == '') { |
|
| 860 | + $filter_name = $this->filter_name; |
|
| 861 | + } |
|
| 710 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 711 | 863 | $Spotter = new Spotter($this->db); |
| 712 | 864 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -715,8 +867,11 @@ discard block |
||
| 715 | 867 | foreach ($airlines as $airline) { |
| 716 | 868 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 717 | 869 | } |
| 718 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 870 | + if ($limit) { |
|
| 871 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 872 | + } else { |
|
| 873 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 874 | + } |
|
| 720 | 875 | try { |
| 721 | 876 | $sth = $this->db->prepare($query); |
| 722 | 877 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -724,11 +879,16 @@ discard block |
||
| 724 | 879 | echo "error : ".$e->getMessage(); |
| 725 | 880 | } |
| 726 | 881 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 727 | - } else $all = array(); |
|
| 882 | + } else { |
|
| 883 | + $all = array(); |
|
| 884 | + } |
|
| 728 | 885 | } else { |
| 729 | 886 | if ($year == '' && $month == '') { |
| 730 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
| 731 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 887 | + if ($limit) { |
|
| 888 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
| 889 | + } else { |
|
| 890 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 891 | + } |
|
| 732 | 892 | try { |
| 733 | 893 | $sth = $this->db->prepare($query); |
| 734 | 894 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -736,7 +896,9 @@ discard block |
||
| 736 | 896 | echo "error : ".$e->getMessage(); |
| 737 | 897 | } |
| 738 | 898 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 739 | - } else $all = array(); |
|
| 899 | + } else { |
|
| 900 | + $all = array(); |
|
| 901 | + } |
|
| 740 | 902 | } |
| 741 | 903 | if (empty($all)) { |
| 742 | 904 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -761,7 +923,9 @@ discard block |
||
| 761 | 923 | $icao = $value['airport_arrival_icao']; |
| 762 | 924 | if (isset($all[$icao])) { |
| 763 | 925 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 764 | - } else $all[$icao] = $value; |
|
| 926 | + } else { |
|
| 927 | + $all[$icao] = $value; |
|
| 928 | + } |
|
| 765 | 929 | } |
| 766 | 930 | $count = array(); |
| 767 | 931 | foreach ($all as $key => $row) { |
@@ -773,7 +937,9 @@ discard block |
||
| 773 | 937 | } |
| 774 | 938 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 775 | 939 | global $globalDBdriver, $globalStatsFilters; |
| 776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 940 | + if ($filter_name == '') { |
|
| 941 | + $filter_name = $this->filter_name; |
|
| 942 | + } |
|
| 777 | 943 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 778 | 944 | $Spotter = new Spotter($this->db); |
| 779 | 945 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -782,20 +948,32 @@ discard block |
||
| 782 | 948 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 783 | 949 | } |
| 784 | 950 | if ($globalDBdriver == 'mysql') { |
| 785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 951 | + if ($limit) { |
|
| 952 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 953 | + } else { |
|
| 954 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 955 | + } |
|
| 787 | 956 | } else { |
| 788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 957 | + if ($limit) { |
|
| 958 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 959 | + } else { |
|
| 960 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 961 | + } |
|
| 790 | 962 | } |
| 791 | 963 | $query_data = array(':filter_name' => $filter_name); |
| 792 | 964 | } else { |
| 793 | 965 | if ($globalDBdriver == 'mysql') { |
| 794 | - 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"; |
|
| 795 | - 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"; |
|
| 966 | + if ($limit) { |
|
| 967 | + $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"; |
|
| 968 | + } else { |
|
| 969 | + $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"; |
|
| 970 | + } |
|
| 796 | 971 | } else { |
| 797 | - 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"; |
|
| 798 | - 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"; |
|
| 972 | + if ($limit) { |
|
| 973 | + $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"; |
|
| 974 | + } else { |
|
| 975 | + $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"; |
|
| 976 | + } |
|
| 799 | 977 | } |
| 800 | 978 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 801 | 979 | } |
@@ -823,7 +1001,9 @@ discard block |
||
| 823 | 1001 | |
| 824 | 1002 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 825 | 1003 | global $globalStatsFilters; |
| 826 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1004 | + if ($filter_name == '') { |
|
| 1005 | + $filter_name = $this->filter_name; |
|
| 1006 | + } |
|
| 827 | 1007 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 828 | 1008 | $Spotter = new Spotter($this->db); |
| 829 | 1009 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -860,7 +1040,9 @@ discard block |
||
| 860 | 1040 | } |
| 861 | 1041 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 862 | 1042 | global $globalDBdriver, $globalStatsFilters; |
| 863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1043 | + if ($filter_name == '') { |
|
| 1044 | + $filter_name = $this->filter_name; |
|
| 1045 | + } |
|
| 864 | 1046 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 865 | 1047 | $Spotter = new Spotter($this->db); |
| 866 | 1048 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -905,7 +1087,9 @@ discard block |
||
| 905 | 1087 | } |
| 906 | 1088 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 907 | 1089 | global $globalStatsFilters; |
| 908 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1090 | + if ($filter_name == '') { |
|
| 1091 | + $filter_name = $this->filter_name; |
|
| 1092 | + } |
|
| 909 | 1093 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 910 | 1094 | $Spotter = new Spotter($this->db); |
| 911 | 1095 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -942,7 +1126,9 @@ discard block |
||
| 942 | 1126 | } |
| 943 | 1127 | public function countAllDatesByAirlines($filter_name = '') { |
| 944 | 1128 | global $globalStatsFilters; |
| 945 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1129 | + if ($filter_name == '') { |
|
| 1130 | + $filter_name = $this->filter_name; |
|
| 1131 | + } |
|
| 946 | 1132 | $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"; |
| 947 | 1133 | $query_data = array('filter_name' => $filter_name); |
| 948 | 1134 | try { |
@@ -964,7 +1150,9 @@ discard block |
||
| 964 | 1150 | } |
| 965 | 1151 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 966 | 1152 | global $globalStatsFilters, $globalDBdriver; |
| 967 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1153 | + if ($filter_name == '') { |
|
| 1154 | + $filter_name = $this->filter_name; |
|
| 1155 | + } |
|
| 968 | 1156 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 969 | 1157 | $Spotter = new Spotter($this->db); |
| 970 | 1158 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1049,7 +1237,9 @@ discard block |
||
| 1049 | 1237 | } |
| 1050 | 1238 | public function countAllMilitaryMonths($filter_name = '') { |
| 1051 | 1239 | global $globalStatsFilters; |
| 1052 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1240 | + if ($filter_name == '') { |
|
| 1241 | + $filter_name = $this->filter_name; |
|
| 1242 | + } |
|
| 1053 | 1243 | $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"; |
| 1054 | 1244 | try { |
| 1055 | 1245 | $sth = $this->db->prepare($query); |
@@ -1070,7 +1260,9 @@ discard block |
||
| 1070 | 1260 | } |
| 1071 | 1261 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 1072 | 1262 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1073 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1263 | + if ($filter_name == '') { |
|
| 1264 | + $filter_name = $this->filter_name; |
|
| 1265 | + } |
|
| 1074 | 1266 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1075 | 1267 | $Spotter = new Spotter($this->db); |
| 1076 | 1268 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1078,12 +1270,18 @@ discard block |
||
| 1078 | 1270 | foreach ($airlines as $airline) { |
| 1079 | 1271 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 1080 | 1272 | } |
| 1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1273 | + if ($limit) { |
|
| 1274 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1275 | + } else { |
|
| 1276 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1277 | + } |
|
| 1083 | 1278 | $query_data = array(':filter_name' => $filter_name); |
| 1084 | 1279 | } else { |
| 1085 | - 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"; |
|
| 1086 | - 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"; |
|
| 1280 | + if ($limit) { |
|
| 1281 | + $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"; |
|
| 1282 | + } else { |
|
| 1283 | + $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"; |
|
| 1284 | + } |
|
| 1087 | 1285 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 1088 | 1286 | } |
| 1089 | 1287 | if ($orderby == 'hour') { |
@@ -1093,7 +1291,9 @@ discard block |
||
| 1093 | 1291 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 1094 | 1292 | } |
| 1095 | 1293 | } |
| 1096 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1294 | + if ($orderby == 'count') { |
|
| 1295 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1296 | + } |
|
| 1097 | 1297 | try { |
| 1098 | 1298 | $sth = $this->db->prepare($query); |
| 1099 | 1299 | $sth->execute($query_data); |
@@ -1117,8 +1317,12 @@ discard block |
||
| 1117 | 1317 | } |
| 1118 | 1318 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 1119 | 1319 | global $globalStatsFilters; |
| 1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1121 | - if ($year == '') $year = date('Y'); |
|
| 1320 | + if ($filter_name == '') { |
|
| 1321 | + $filter_name = $this->filter_name; |
|
| 1322 | + } |
|
| 1323 | + if ($year == '') { |
|
| 1324 | + $year = date('Y'); |
|
| 1325 | + } |
|
| 1122 | 1326 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1123 | 1327 | if (empty($all)) { |
| 1124 | 1328 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1137,8 +1341,12 @@ discard block |
||
| 1137 | 1341 | } |
| 1138 | 1342 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 1139 | 1343 | global $globalStatsFilters; |
| 1140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1141 | - if ($year == '') $year = date('Y'); |
|
| 1344 | + if ($filter_name == '') { |
|
| 1345 | + $filter_name = $this->filter_name; |
|
| 1346 | + } |
|
| 1347 | + if ($year == '') { |
|
| 1348 | + $year = date('Y'); |
|
| 1349 | + } |
|
| 1142 | 1350 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 1143 | 1351 | if (empty($all)) { |
| 1144 | 1352 | $filters = array(); |
@@ -1154,8 +1362,12 @@ discard block |
||
| 1154 | 1362 | } |
| 1155 | 1363 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 1156 | 1364 | global $globalStatsFilters; |
| 1157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1158 | - if ($year == '') $year = date('Y'); |
|
| 1365 | + if ($filter_name == '') { |
|
| 1366 | + $filter_name = $this->filter_name; |
|
| 1367 | + } |
|
| 1368 | + if ($year == '') { |
|
| 1369 | + $year = date('Y'); |
|
| 1370 | + } |
|
| 1159 | 1371 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1160 | 1372 | if (empty($all)) { |
| 1161 | 1373 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1174,7 +1386,9 @@ discard block |
||
| 1174 | 1386 | } |
| 1175 | 1387 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1176 | 1388 | global $globalStatsFilters; |
| 1177 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1389 | + if ($filter_name == '') { |
|
| 1390 | + $filter_name = $this->filter_name; |
|
| 1391 | + } |
|
| 1178 | 1392 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1179 | 1393 | $Spotter = new Spotter($this->db); |
| 1180 | 1394 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1192,7 +1406,9 @@ discard block |
||
| 1192 | 1406 | } |
| 1193 | 1407 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1194 | 1408 | $all = $result[0]['nb']; |
| 1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1409 | + } else { |
|
| 1410 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1411 | + } |
|
| 1196 | 1412 | } else { |
| 1197 | 1413 | if ($year == '' && $month == '') { |
| 1198 | 1414 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1204,7 +1420,9 @@ discard block |
||
| 1204 | 1420 | } |
| 1205 | 1421 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1206 | 1422 | $all = $result[0]['nb']; |
| 1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1423 | + } else { |
|
| 1424 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1425 | + } |
|
| 1208 | 1426 | } |
| 1209 | 1427 | if (empty($all)) { |
| 1210 | 1428 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1223,7 +1441,9 @@ discard block |
||
| 1223 | 1441 | } |
| 1224 | 1442 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 1225 | 1443 | global $globalStatsFilters; |
| 1226 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1444 | + if ($filter_name == '') { |
|
| 1445 | + $filter_name = $this->filter_name; |
|
| 1446 | + } |
|
| 1227 | 1447 | if ($year == '' && $month == '') { |
| 1228 | 1448 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 1229 | 1449 | try { |
@@ -1234,7 +1454,9 @@ discard block |
||
| 1234 | 1454 | } |
| 1235 | 1455 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1236 | 1456 | $all = $result[0]['nb_airline']; |
| 1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1457 | + } else { |
|
| 1458 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1459 | + } |
|
| 1238 | 1460 | if (empty($all)) { |
| 1239 | 1461 | $filters = array(); |
| 1240 | 1462 | $filters = array('year' => $year,'month' => $month); |
@@ -1249,7 +1471,9 @@ discard block |
||
| 1249 | 1471 | } |
| 1250 | 1472 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1251 | 1473 | global $globalStatsFilters; |
| 1252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1474 | + if ($filter_name == '') { |
|
| 1475 | + $filter_name = $this->filter_name; |
|
| 1476 | + } |
|
| 1253 | 1477 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1254 | 1478 | $Spotter = new Spotter($this->db); |
| 1255 | 1479 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1304,7 +1528,9 @@ discard block |
||
| 1304 | 1528 | } |
| 1305 | 1529 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 1306 | 1530 | global $globalStatsFilters; |
| 1307 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1531 | + if ($filter_name == '') { |
|
| 1532 | + $filter_name = $this->filter_name; |
|
| 1533 | + } |
|
| 1308 | 1534 | //if ($year == '') $year = date('Y'); |
| 1309 | 1535 | if ($year == '' && $month == '') { |
| 1310 | 1536 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1333,7 +1559,9 @@ discard block |
||
| 1333 | 1559 | } |
| 1334 | 1560 | |
| 1335 | 1561 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 1336 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1562 | + if ($filter_name == '') { |
|
| 1563 | + $filter_name = $this->filter_name; |
|
| 1564 | + } |
|
| 1337 | 1565 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1338 | 1566 | $Spotter = new Spotter($this->db); |
| 1339 | 1567 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1357,7 +1585,9 @@ discard block |
||
| 1357 | 1585 | return $all; |
| 1358 | 1586 | } |
| 1359 | 1587 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 1360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1588 | + if ($filter_name == '') { |
|
| 1589 | + $filter_name = $this->filter_name; |
|
| 1590 | + } |
|
| 1361 | 1591 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1362 | 1592 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1363 | 1593 | try { |
@@ -1370,7 +1600,9 @@ discard block |
||
| 1370 | 1600 | return $all; |
| 1371 | 1601 | } |
| 1372 | 1602 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
| 1373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1603 | + if ($filter_name == '') { |
|
| 1604 | + $filter_name = $this->filter_name; |
|
| 1605 | + } |
|
| 1374 | 1606 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1375 | 1607 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1376 | 1608 | try { |
@@ -1381,7 +1613,9 @@ discard block |
||
| 1381 | 1613 | } |
| 1382 | 1614 | } |
| 1383 | 1615 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 1384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1616 | + if ($filter_name == '') { |
|
| 1617 | + $filter_name = $this->filter_name; |
|
| 1618 | + } |
|
| 1385 | 1619 | global $globalArchiveMonths, $globalDBdriver; |
| 1386 | 1620 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1387 | 1621 | $Spotter = new Spotter($this->db); |
@@ -1437,7 +1671,9 @@ discard block |
||
| 1437 | 1671 | } |
| 1438 | 1672 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1439 | 1673 | global $globalArchiveMonths, $globalDBdriver; |
| 1440 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1674 | + if ($filter_name == '') { |
|
| 1675 | + $filter_name = $this->filter_name; |
|
| 1676 | + } |
|
| 1441 | 1677 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1442 | 1678 | $Spotter = new Spotter($this->db); |
| 1443 | 1679 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1470,7 +1706,9 @@ discard block |
||
| 1470 | 1706 | } |
| 1471 | 1707 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1472 | 1708 | global $globalArchiveMonths, $globalDBdriver; |
| 1473 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1709 | + if ($filter_name == '') { |
|
| 1710 | + $filter_name = $this->filter_name; |
|
| 1711 | + } |
|
| 1474 | 1712 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1475 | 1713 | $Spotter = new Spotter($this->db); |
| 1476 | 1714 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1501,7 +1739,9 @@ discard block |
||
| 1501 | 1739 | } |
| 1502 | 1740 | public function getStatsAirlineTotal($filter_name = '') { |
| 1503 | 1741 | global $globalArchiveMonths, $globalDBdriver; |
| 1504 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1742 | + if ($filter_name == '') { |
|
| 1743 | + $filter_name = $this->filter_name; |
|
| 1744 | + } |
|
| 1505 | 1745 | if ($globalDBdriver == 'mysql') { |
| 1506 | 1746 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 1507 | 1747 | } else { |
@@ -1518,7 +1758,9 @@ discard block |
||
| 1518 | 1758 | } |
| 1519 | 1759 | public function getStatsOwnerTotal($filter_name = '') { |
| 1520 | 1760 | global $globalArchiveMonths, $globalDBdriver; |
| 1521 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1761 | + if ($filter_name == '') { |
|
| 1762 | + $filter_name = $this->filter_name; |
|
| 1763 | + } |
|
| 1522 | 1764 | if ($globalDBdriver == 'mysql') { |
| 1523 | 1765 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1524 | 1766 | } else { |
@@ -1535,7 +1777,9 @@ discard block |
||
| 1535 | 1777 | } |
| 1536 | 1778 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1537 | 1779 | global $globalArchiveMonths, $globalDBdriver; |
| 1538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1780 | + if ($filter_name == '') { |
|
| 1781 | + $filter_name = $this->filter_name; |
|
| 1782 | + } |
|
| 1539 | 1783 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1540 | 1784 | try { |
| 1541 | 1785 | $sth = $this->db->prepare($query); |
@@ -1544,12 +1788,17 @@ discard block |
||
| 1544 | 1788 | echo "error : ".$e->getMessage(); |
| 1545 | 1789 | } |
| 1546 | 1790 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1547 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1548 | - else return 0; |
|
| 1791 | + if (isset($all[0]['cnt'])) { |
|
| 1792 | + return $all[0]['cnt']; |
|
| 1793 | + } else { |
|
| 1794 | + return 0; |
|
| 1795 | + } |
|
| 1549 | 1796 | } |
| 1550 | 1797 | public function getStatsPilotTotal($filter_name = '') { |
| 1551 | 1798 | global $globalArchiveMonths, $globalDBdriver; |
| 1552 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1799 | + if ($filter_name == '') { |
|
| 1800 | + $filter_name = $this->filter_name; |
|
| 1801 | + } |
|
| 1553 | 1802 | if ($globalDBdriver == 'mysql') { |
| 1554 | 1803 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1555 | 1804 | } else { |
@@ -1566,7 +1815,9 @@ discard block |
||
| 1566 | 1815 | } |
| 1567 | 1816 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1568 | 1817 | global $globalArchiveMonths, $globalDBdriver; |
| 1569 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1818 | + if ($filter_name == '') { |
|
| 1819 | + $filter_name = $this->filter_name; |
|
| 1820 | + } |
|
| 1570 | 1821 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1571 | 1822 | try { |
| 1572 | 1823 | $sth = $this->db->prepare($query); |
@@ -1575,13 +1826,18 @@ discard block |
||
| 1575 | 1826 | echo "error : ".$e->getMessage(); |
| 1576 | 1827 | } |
| 1577 | 1828 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1578 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1579 | - else return 0; |
|
| 1829 | + if (isset($all[0]['cnt'])) { |
|
| 1830 | + return $all[0]['cnt']; |
|
| 1831 | + } else { |
|
| 1832 | + return 0; |
|
| 1833 | + } |
|
| 1580 | 1834 | } |
| 1581 | 1835 | |
| 1582 | 1836 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1583 | 1837 | global $globalDBdriver; |
| 1584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1838 | + if ($filter_name == '') { |
|
| 1839 | + $filter_name = $this->filter_name; |
|
| 1840 | + } |
|
| 1585 | 1841 | if ($globalDBdriver == 'mysql') { |
| 1586 | 1842 | $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"; |
| 1587 | 1843 | } else { |
@@ -1597,7 +1853,9 @@ discard block |
||
| 1597 | 1853 | } |
| 1598 | 1854 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1599 | 1855 | global $globalDBdriver; |
| 1600 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1856 | + if ($filter_name == '') { |
|
| 1857 | + $filter_name = $this->filter_name; |
|
| 1858 | + } |
|
| 1601 | 1859 | if ($globalDBdriver == 'mysql') { |
| 1602 | 1860 | $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"; |
| 1603 | 1861 | } else { |
@@ -1983,10 +2241,14 @@ discard block |
||
| 1983 | 2241 | $Connection = new Connection($this->db); |
| 1984 | 2242 | date_default_timezone_set('UTC'); |
| 1985 | 2243 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1986 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 2244 | + if ($globalDebug) { |
|
| 2245 | + echo 'Update stats !'."\n"; |
|
| 2246 | + } |
|
| 1987 | 2247 | if (isset($last_update[0]['value'])) { |
| 1988 | 2248 | $last_update_day = $last_update[0]['value']; |
| 1989 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2249 | + } else { |
|
| 2250 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2251 | + } |
|
| 1990 | 2252 | $reset = false; |
| 1991 | 2253 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 1992 | 2254 | if ($globalStatsResetYear) { |
@@ -1995,43 +2257,63 @@ discard block |
||
| 1995 | 2257 | } |
| 1996 | 2258 | $Spotter = new Spotter($this->db); |
| 1997 | 2259 | |
| 1998 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo 'Count all aircraft types...'."\n"; |
|
| 2262 | + } |
|
| 1999 | 2263 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 2000 | 2264 | foreach ($alldata as $number) { |
| 2001 | 2265 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 2002 | 2266 | } |
| 2003 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2267 | + if ($globalDebug) { |
|
| 2268 | + echo 'Count all airlines...'."\n"; |
|
| 2269 | + } |
|
| 2004 | 2270 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 2005 | 2271 | foreach ($alldata as $number) { |
| 2006 | 2272 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 2007 | 2273 | } |
| 2008 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 2274 | + if ($globalDebug) { |
|
| 2275 | + echo 'Count all registrations...'."\n"; |
|
| 2276 | + } |
|
| 2009 | 2277 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 2010 | 2278 | foreach ($alldata as $number) { |
| 2011 | 2279 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 2012 | 2280 | } |
| 2013 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2281 | + if ($globalDebug) { |
|
| 2282 | + echo 'Count all callsigns...'."\n"; |
|
| 2283 | + } |
|
| 2014 | 2284 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 2015 | 2285 | foreach ($alldata as $number) { |
| 2016 | 2286 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2017 | 2287 | } |
| 2018 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2288 | + if ($globalDebug) { |
|
| 2289 | + echo 'Count all owners...'."\n"; |
|
| 2290 | + } |
|
| 2019 | 2291 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 2020 | 2292 | foreach ($alldata as $number) { |
| 2021 | 2293 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 2022 | 2294 | } |
| 2023 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2295 | + if ($globalDebug) { |
|
| 2296 | + echo 'Count all pilots...'."\n"; |
|
| 2297 | + } |
|
| 2024 | 2298 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 2025 | 2299 | foreach ($alldata as $number) { |
| 2026 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
| 2300 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
| 2301 | + $number['pilot_id'] = $number['pilot_name']; |
|
| 2302 | + } |
|
| 2027 | 2303 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 2028 | 2304 | } |
| 2029 | 2305 | |
| 2030 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 2306 | + if ($globalDebug) { |
|
| 2307 | + echo 'Count all departure airports...'."\n"; |
|
| 2308 | + } |
|
| 2031 | 2309 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 2032 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo 'Count all detected departure airports...'."\n"; |
|
| 2312 | + } |
|
| 2033 | 2313 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 2034 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 2314 | + if ($globalDebug) { |
|
| 2315 | + echo 'Order departure airports...'."\n"; |
|
| 2316 | + } |
|
| 2035 | 2317 | $alldata = array(); |
| 2036 | 2318 | foreach ($pall as $value) { |
| 2037 | 2319 | $icao = $value['airport_departure_icao']; |
@@ -2041,7 +2323,9 @@ discard block |
||
| 2041 | 2323 | $icao = $value['airport_departure_icao']; |
| 2042 | 2324 | if (isset($alldata[$icao])) { |
| 2043 | 2325 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2044 | - } else $alldata[$icao] = $value; |
|
| 2326 | + } else { |
|
| 2327 | + $alldata[$icao] = $value; |
|
| 2328 | + } |
|
| 2045 | 2329 | } |
| 2046 | 2330 | $count = array(); |
| 2047 | 2331 | foreach ($alldata as $key => $row) { |
@@ -2051,11 +2335,17 @@ discard block |
||
| 2051 | 2335 | foreach ($alldata as $number) { |
| 2052 | 2336 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
| 2053 | 2337 | } |
| 2054 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2338 | + if ($globalDebug) { |
|
| 2339 | + echo 'Count all arrival airports...'."\n"; |
|
| 2340 | + } |
|
| 2055 | 2341 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 2056 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 2342 | + if ($globalDebug) { |
|
| 2343 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 2344 | + } |
|
| 2057 | 2345 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 2058 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 2346 | + if ($globalDebug) { |
|
| 2347 | + echo 'Order arrival airports...'."\n"; |
|
| 2348 | + } |
|
| 2059 | 2349 | $alldata = array(); |
| 2060 | 2350 | foreach ($pall as $value) { |
| 2061 | 2351 | $icao = $value['airport_arrival_icao']; |
@@ -2065,7 +2355,9 @@ discard block |
||
| 2065 | 2355 | $icao = $value['airport_arrival_icao']; |
| 2066 | 2356 | if (isset($alldata[$icao])) { |
| 2067 | 2357 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2068 | - } else $alldata[$icao] = $value; |
|
| 2358 | + } else { |
|
| 2359 | + $alldata[$icao] = $value; |
|
| 2360 | + } |
|
| 2069 | 2361 | } |
| 2070 | 2362 | $count = array(); |
| 2071 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2076,7 +2368,9 @@ discard block |
||
| 2076 | 2368 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
| 2077 | 2369 | } |
| 2078 | 2370 | if ($Connection->tableExists('countries')) { |
| 2079 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 2371 | + if ($globalDebug) { |
|
| 2372 | + echo 'Count all flights by countries...'."\n"; |
|
| 2373 | + } |
|
| 2080 | 2374 | //$SpotterArchive = new SpotterArchive(); |
| 2081 | 2375 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2082 | 2376 | $Spotter = new Spotter($this->db); |
@@ -2087,7 +2381,9 @@ discard block |
||
| 2087 | 2381 | } |
| 2088 | 2382 | |
| 2089 | 2383 | if (isset($globalAccidents) && $globalAccidents) { |
| 2090 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
| 2384 | + if ($globalDebug) { |
|
| 2385 | + echo 'Count fatalities stats...'."\n"; |
|
| 2386 | + } |
|
| 2091 | 2387 | $Accident = new Accident($this->db); |
| 2092 | 2388 | $this->deleteStatsByType('fatalities_byyear'); |
| 2093 | 2389 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2103,48 +2399,68 @@ discard block |
||
| 2103 | 2399 | |
| 2104 | 2400 | // Add by month using getstat if month finish... |
| 2105 | 2401 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 2106 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 2402 | + if ($globalDebug) { |
|
| 2403 | + echo 'Count all flights by months...'."\n"; |
|
| 2404 | + } |
|
| 2107 | 2405 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2108 | 2406 | $filter_last_month = array('since_date' => $last_month); |
| 2109 | 2407 | $Spotter = new Spotter($this->db); |
| 2110 | 2408 | $alldata = $Spotter->countAllMonths($filter_last_month); |
| 2111 | 2409 | $lastyear = false; |
| 2112 | 2410 | foreach ($alldata as $number) { |
| 2113 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2411 | + if ($number['year_name'] != date('Y')) { |
|
| 2412 | + $lastyear = true; |
|
| 2413 | + } |
|
| 2114 | 2414 | $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']))); |
| 2115 | 2415 | } |
| 2116 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 2416 | + if ($globalDebug) { |
|
| 2417 | + echo 'Count all military flights by months...'."\n"; |
|
| 2418 | + } |
|
| 2117 | 2419 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2118 | 2420 | foreach ($alldata as $number) { |
| 2119 | 2421 | $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']))); |
| 2120 | 2422 | } |
| 2121 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2423 | + if ($globalDebug) { |
|
| 2424 | + echo 'Count all owners by months...'."\n"; |
|
| 2425 | + } |
|
| 2122 | 2426 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2123 | 2427 | foreach ($alldata as $number) { |
| 2124 | 2428 | $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']))); |
| 2125 | 2429 | } |
| 2126 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2430 | + if ($globalDebug) { |
|
| 2431 | + echo 'Count all pilots by months...'."\n"; |
|
| 2432 | + } |
|
| 2127 | 2433 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2128 | 2434 | foreach ($alldata as $number) { |
| 2129 | 2435 | $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']))); |
| 2130 | 2436 | } |
| 2131 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo 'Count all airlines by months...'."\n"; |
|
| 2439 | + } |
|
| 2132 | 2440 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2133 | 2441 | foreach ($alldata as $number) { |
| 2134 | 2442 | $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']))); |
| 2135 | 2443 | } |
| 2136 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2444 | + if ($globalDebug) { |
|
| 2445 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2446 | + } |
|
| 2137 | 2447 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2138 | 2448 | foreach ($alldata as $number) { |
| 2139 | 2449 | $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']))); |
| 2140 | 2450 | } |
| 2141 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2451 | + if ($globalDebug) { |
|
| 2452 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2453 | + } |
|
| 2142 | 2454 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2143 | 2455 | foreach ($alldata as $number) { |
| 2144 | 2456 | $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']))); |
| 2145 | 2457 | } |
| 2146 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 2147 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2458 | + if ($globalDebug) { |
|
| 2459 | + echo 'Airports data...'."\n"; |
|
| 2460 | + } |
|
| 2461 | + if ($globalDebug) { |
|
| 2462 | + echo '...Departure'."\n"; |
|
| 2463 | + } |
|
| 2148 | 2464 | $this->deleteStatAirport('daily'); |
| 2149 | 2465 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 2150 | 2466 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2262,7 +2578,9 @@ discard block |
||
| 2262 | 2578 | // Count by airlines |
| 2263 | 2579 | echo '--- Stats by airlines ---'."\n"; |
| 2264 | 2580 | if ($Connection->tableExists('countries')) { |
| 2265 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2581 | + if ($globalDebug) { |
|
| 2582 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2583 | + } |
|
| 2266 | 2584 | $SpotterArchive = new SpotterArchive($this->db); |
| 2267 | 2585 | //$Spotter = new Spotter($this->db); |
| 2268 | 2586 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2271,37 +2589,53 @@ discard block |
||
| 2271 | 2589 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 2272 | 2590 | } |
| 2273 | 2591 | } |
| 2274 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2592 | + if ($globalDebug) { |
|
| 2593 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2594 | + } |
|
| 2275 | 2595 | $Spotter = new Spotter($this->db); |
| 2276 | 2596 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 2277 | 2597 | foreach ($alldata as $number) { |
| 2278 | 2598 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 2279 | 2599 | } |
| 2280 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2600 | + if ($globalDebug) { |
|
| 2601 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2602 | + } |
|
| 2281 | 2603 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 2282 | 2604 | foreach ($alldata as $number) { |
| 2283 | 2605 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 2284 | 2606 | } |
| 2285 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 2607 | + if ($globalDebug) { |
|
| 2608 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 2609 | + } |
|
| 2286 | 2610 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 2287 | 2611 | foreach ($alldata as $number) { |
| 2288 | 2612 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2289 | 2613 | } |
| 2290 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 2614 | + if ($globalDebug) { |
|
| 2615 | + echo 'Count all owners by airlines...'."\n"; |
|
| 2616 | + } |
|
| 2291 | 2617 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 2292 | 2618 | foreach ($alldata as $number) { |
| 2293 | 2619 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 2294 | 2620 | } |
| 2295 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 2621 | + if ($globalDebug) { |
|
| 2622 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 2623 | + } |
|
| 2296 | 2624 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 2297 | 2625 | foreach ($alldata as $number) { |
| 2298 | 2626 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 2299 | 2627 | } |
| 2300 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 2628 | + if ($globalDebug) { |
|
| 2629 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 2630 | + } |
|
| 2301 | 2631 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2302 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2632 | + if ($globalDebug) { |
|
| 2633 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2634 | + } |
|
| 2303 | 2635 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2304 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2636 | + if ($globalDebug) { |
|
| 2637 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2638 | + } |
|
| 2305 | 2639 | //$alldata = array(); |
| 2306 | 2640 | foreach ($dall as $value) { |
| 2307 | 2641 | $icao = $value['airport_departure_icao']; |
@@ -2322,11 +2656,17 @@ discard block |
||
| 2322 | 2656 | foreach ($alldata as $number) { |
| 2323 | 2657 | 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'],'',$reset); |
| 2324 | 2658 | } |
| 2325 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2659 | + if ($globalDebug) { |
|
| 2660 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2661 | + } |
|
| 2326 | 2662 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2327 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2663 | + if ($globalDebug) { |
|
| 2664 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2665 | + } |
|
| 2328 | 2666 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2329 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 2667 | + if ($globalDebug) { |
|
| 2668 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 2669 | + } |
|
| 2330 | 2670 | //$alldata = array(); |
| 2331 | 2671 | foreach ($dall as $value) { |
| 2332 | 2672 | $icao = $value['airport_arrival_icao']; |
@@ -2345,37 +2685,53 @@ discard block |
||
| 2345 | 2685 | } |
| 2346 | 2686 | $alldata = $pall; |
| 2347 | 2687 | foreach ($alldata as $number) { |
| 2348 | - if ($number['airline_icao'] != '') 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'],'',$reset); |
|
| 2688 | + if ($number['airline_icao'] != '') { |
|
| 2689 | + 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'],'',$reset); |
|
| 2690 | + } |
|
| 2691 | + } |
|
| 2692 | + if ($globalDebug) { |
|
| 2693 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 2349 | 2694 | } |
| 2350 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 2351 | 2695 | $Spotter = new Spotter($this->db); |
| 2352 | 2696 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
| 2353 | 2697 | $lastyear = false; |
| 2354 | 2698 | foreach ($alldata as $number) { |
| 2355 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2699 | + if ($number['year_name'] != date('Y')) { |
|
| 2700 | + $lastyear = true; |
|
| 2701 | + } |
|
| 2356 | 2702 | $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']); |
| 2357 | 2703 | } |
| 2358 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 2704 | + if ($globalDebug) { |
|
| 2705 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2706 | + } |
|
| 2359 | 2707 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2360 | 2708 | foreach ($alldata as $number) { |
| 2361 | 2709 | $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']); |
| 2362 | 2710 | } |
| 2363 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2713 | + } |
|
| 2364 | 2714 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2365 | 2715 | foreach ($alldata as $number) { |
| 2366 | 2716 | $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']); |
| 2367 | 2717 | } |
| 2368 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2718 | + if ($globalDebug) { |
|
| 2719 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2720 | + } |
|
| 2369 | 2721 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2370 | 2722 | foreach ($alldata as $number) { |
| 2371 | 2723 | $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']); |
| 2372 | 2724 | } |
| 2373 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2725 | + if ($globalDebug) { |
|
| 2726 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2727 | + } |
|
| 2374 | 2728 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2375 | 2729 | foreach ($alldata as $number) { |
| 2376 | 2730 | $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']); |
| 2377 | 2731 | } |
| 2378 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2732 | + if ($globalDebug) { |
|
| 2733 | + echo '...Departure'."\n"; |
|
| 2734 | + } |
|
| 2379 | 2735 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 2380 | 2736 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 2381 | 2737 | foreach ($dall as $value) { |
@@ -2398,7 +2754,9 @@ discard block |
||
| 2398 | 2754 | foreach ($alldata as $number) { |
| 2399 | 2755 | $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']); |
| 2400 | 2756 | } |
| 2401 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2757 | + if ($globalDebug) { |
|
| 2758 | + echo '...Arrival'."\n"; |
|
| 2759 | + } |
|
| 2402 | 2760 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 2403 | 2761 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 2404 | 2762 | foreach ($dall as $value) { |
@@ -2422,13 +2780,19 @@ discard block |
||
| 2422 | 2780 | $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']); |
| 2423 | 2781 | } |
| 2424 | 2782 | |
| 2425 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 2426 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2783 | + if ($globalDebug) { |
|
| 2784 | + echo 'Flights data...'."\n"; |
|
| 2785 | + } |
|
| 2786 | + if ($globalDebug) { |
|
| 2787 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2788 | + } |
|
| 2427 | 2789 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2428 | 2790 | foreach ($alldata as $number) { |
| 2429 | 2791 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 2430 | 2792 | } |
| 2431 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2793 | + if ($globalDebug) { |
|
| 2794 | + echo '-> countAllDates...'."\n"; |
|
| 2795 | + } |
|
| 2432 | 2796 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2433 | 2797 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
| 2434 | 2798 | $values = array(); |
@@ -2441,14 +2805,18 @@ discard block |
||
| 2441 | 2805 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 2442 | 2806 | } |
| 2443 | 2807 | |
| 2444 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2808 | + if ($globalDebug) { |
|
| 2809 | + echo '-> countAllHours...'."\n"; |
|
| 2810 | + } |
|
| 2445 | 2811 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
| 2446 | 2812 | foreach ($alldata as $number) { |
| 2447 | 2813 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 2448 | 2814 | } |
| 2449 | 2815 | |
| 2450 | 2816 | // Stats by filters |
| 2451 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2817 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2818 | + $globalStatsFilters = array(); |
|
| 2819 | + } |
|
| 2452 | 2820 | foreach ($globalStatsFilters as $name => $filter) { |
| 2453 | 2821 | if (!empty($filter)) { |
| 2454 | 2822 | //$filter_name = $filter['name']; |
@@ -2456,7 +2824,9 @@ discard block |
||
| 2456 | 2824 | $reset = false; |
| 2457 | 2825 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 2458 | 2826 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 2459 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2827 | + if ($globalDebug) { |
|
| 2828 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2829 | + } |
|
| 2460 | 2830 | $this->deleteOldStats($filter_name); |
| 2461 | 2831 | unset($last_update); |
| 2462 | 2832 | } |
@@ -2473,39 +2843,55 @@ discard block |
||
| 2473 | 2843 | $reset = true; |
| 2474 | 2844 | } |
| 2475 | 2845 | // Count by filter |
| 2476 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2846 | + if ($globalDebug) { |
|
| 2847 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2848 | + } |
|
| 2477 | 2849 | $Spotter = new Spotter($this->db); |
| 2478 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2850 | + if ($globalDebug) { |
|
| 2851 | + echo 'Count all aircraft types...'."\n"; |
|
| 2852 | + } |
|
| 2479 | 2853 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 2480 | 2854 | foreach ($alldata as $number) { |
| 2481 | 2855 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
| 2482 | 2856 | } |
| 2483 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2857 | + if ($globalDebug) { |
|
| 2858 | + echo 'Count all airlines...'."\n"; |
|
| 2859 | + } |
|
| 2484 | 2860 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
| 2485 | 2861 | foreach ($alldata as $number) { |
| 2486 | 2862 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
| 2487 | 2863 | } |
| 2488 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
| 2864 | + if ($globalDebug) { |
|
| 2865 | + echo 'Count all aircraft registrations...'."\n"; |
|
| 2866 | + } |
|
| 2489 | 2867 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
| 2490 | 2868 | foreach ($alldata as $number) { |
| 2491 | 2869 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
| 2492 | 2870 | } |
| 2493 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2871 | + if ($globalDebug) { |
|
| 2872 | + echo 'Count all callsigns...'."\n"; |
|
| 2873 | + } |
|
| 2494 | 2874 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
| 2495 | 2875 | foreach ($alldata as $number) { |
| 2496 | 2876 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
| 2497 | 2877 | } |
| 2498 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2878 | + if ($globalDebug) { |
|
| 2879 | + echo 'Count all owners...'."\n"; |
|
| 2880 | + } |
|
| 2499 | 2881 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
| 2500 | 2882 | foreach ($alldata as $number) { |
| 2501 | 2883 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
| 2502 | 2884 | } |
| 2503 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2885 | + if ($globalDebug) { |
|
| 2886 | + echo 'Count all pilots...'."\n"; |
|
| 2887 | + } |
|
| 2504 | 2888 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
| 2505 | 2889 | foreach ($alldata as $number) { |
| 2506 | 2890 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
| 2507 | 2891 | } |
| 2508 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
| 2892 | + if ($globalDebug) { |
|
| 2893 | + echo 'Count departure airports...'."\n"; |
|
| 2894 | + } |
|
| 2509 | 2895 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
| 2510 | 2896 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
| 2511 | 2897 | $alldata = array(); |
@@ -2517,7 +2903,9 @@ discard block |
||
| 2517 | 2903 | $icao = $value['airport_departure_icao']; |
| 2518 | 2904 | if (isset($alldata[$icao])) { |
| 2519 | 2905 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2520 | - } else $alldata[$icao] = $value; |
|
| 2906 | + } else { |
|
| 2907 | + $alldata[$icao] = $value; |
|
| 2908 | + } |
|
| 2521 | 2909 | } |
| 2522 | 2910 | $count = array(); |
| 2523 | 2911 | foreach ($alldata as $key => $row) { |
@@ -2527,7 +2915,9 @@ discard block |
||
| 2527 | 2915 | foreach ($alldata as $number) { |
| 2528 | 2916 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
| 2529 | 2917 | } |
| 2530 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2918 | + if ($globalDebug) { |
|
| 2919 | + echo 'Count all arrival airports...'."\n"; |
|
| 2920 | + } |
|
| 2531 | 2921 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2532 | 2922 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2533 | 2923 | $alldata = array(); |
@@ -2539,7 +2929,9 @@ discard block |
||
| 2539 | 2929 | $icao = $value['airport_arrival_icao']; |
| 2540 | 2930 | if (isset($alldata[$icao])) { |
| 2541 | 2931 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2542 | - } else $alldata[$icao] = $value; |
|
| 2932 | + } else { |
|
| 2933 | + $alldata[$icao] = $value; |
|
| 2934 | + } |
|
| 2543 | 2935 | } |
| 2544 | 2936 | $count = array(); |
| 2545 | 2937 | foreach ($alldata as $key => $row) { |
@@ -2549,35 +2941,49 @@ discard block |
||
| 2549 | 2941 | foreach ($alldata as $number) { |
| 2550 | 2942 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
| 2551 | 2943 | } |
| 2552 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
| 2944 | + if ($globalDebug) { |
|
| 2945 | + echo 'Count all months...'."\n"; |
|
| 2946 | + } |
|
| 2553 | 2947 | $Spotter = new Spotter($this->db); |
| 2554 | 2948 | $alldata = $Spotter->countAllMonths($filter); |
| 2555 | 2949 | $lastyear = false; |
| 2556 | 2950 | foreach ($alldata as $number) { |
| 2557 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2951 | + if ($number['year_name'] != date('Y')) { |
|
| 2952 | + $lastyear = true; |
|
| 2953 | + } |
|
| 2558 | 2954 | $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); |
| 2559 | 2955 | } |
| 2560 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2956 | + if ($globalDebug) { |
|
| 2957 | + echo 'Count all owners by months...'."\n"; |
|
| 2958 | + } |
|
| 2561 | 2959 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 2562 | 2960 | foreach ($alldata as $number) { |
| 2563 | 2961 | $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'])),'',$filter_name); |
| 2564 | 2962 | } |
| 2565 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2963 | + if ($globalDebug) { |
|
| 2964 | + echo 'Count all pilots by months...'."\n"; |
|
| 2965 | + } |
|
| 2566 | 2966 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 2567 | 2967 | foreach ($alldata as $number) { |
| 2568 | 2968 | $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'])),'',$filter_name); |
| 2569 | 2969 | } |
| 2570 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
| 2970 | + if ($globalDebug) { |
|
| 2971 | + echo 'Count all military by months...'."\n"; |
|
| 2972 | + } |
|
| 2571 | 2973 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 2572 | 2974 | foreach ($alldata as $number) { |
| 2573 | 2975 | $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'])),'',$filter_name); |
| 2574 | 2976 | } |
| 2575 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2977 | + if ($globalDebug) { |
|
| 2978 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2979 | + } |
|
| 2576 | 2980 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2577 | 2981 | foreach ($alldata as $number) { |
| 2578 | 2982 | $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'])),'',$filter_name); |
| 2579 | 2983 | } |
| 2580 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2984 | + if ($globalDebug) { |
|
| 2985 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2986 | + } |
|
| 2581 | 2987 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 2582 | 2988 | foreach ($alldata as $number) { |
| 2583 | 2989 | $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'])),'',$filter_name); |
@@ -7,7 +7,9 @@ discard block |
||
| 7 | 7 | public function __construct($dbc = null) { |
| 8 | 8 | $Connection = new Connection($dbc); |
| 9 | 9 | $this->db = $Connection->db; |
| 10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 10 | + if ($this->db === null) { |
|
| 11 | + die('Error: No DB connection.'); |
|
| 12 | + } |
|
| 11 | 13 | } |
| 12 | 14 | |
| 13 | 15 | public function getAllLocationInfo() { |
@@ -72,7 +74,9 @@ discard block |
||
| 72 | 74 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
| 73 | 75 | } |
| 74 | 76 | $query .= " ORDER BY last_seen DESC"; |
| 75 | - if ($limit) $query .= " LIMIT 200"; |
|
| 77 | + if ($limit) { |
|
| 78 | + $query .= " LIMIT 200"; |
|
| 79 | + } |
|
| 76 | 80 | $query_values = array(':type' => $type); |
| 77 | 81 | try { |
| 78 | 82 | $sth = $this->db->prepare($query); |
@@ -111,7 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
| 114 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 118 | + if ($last_seen == '') { |
|
| 119 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 120 | + } |
|
| 115 | 121 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
| 116 | 122 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 117 | 123 | try { |
@@ -123,7 +129,9 @@ discard block |
||
| 123 | 129 | } |
| 124 | 130 | |
| 125 | 131 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
| 126 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 132 | + if ($last_seen == '') { |
|
| 133 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 134 | + } |
|
| 127 | 135 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
| 128 | 136 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 129 | 137 | try { |
@@ -146,7 +154,9 @@ discard block |
||
| 146 | 154 | } |
| 147 | 155 | |
| 148 | 156 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
| 149 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 157 | + if ($last_seen == '') { |
|
| 158 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 159 | + } |
|
| 150 | 160 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
| 151 | 161 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 152 | 162 | try { |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection.'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
| 27 | 29 | if (isset($filter[0]['source'])) { |
| 28 | 30 | $filters = array_merge($filters,$filter); |
| 29 | 31 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 31 | 35 | $filter_query_join = ''; |
| 32 | 36 | $filter_query_where = ''; |
| 33 | 37 | foreach($filters as $flt) { |
@@ -112,8 +116,11 @@ discard block |
||
| 112 | 116 | } |
| 113 | 117 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 114 | 118 | } |
| 115 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 116 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 119 | + if ($filter_query_where == '' && $where) { |
|
| 120 | + $filter_query_where = ' WHERE'; |
|
| 121 | + } elseif ($filter_query_where != '' && $and) { |
|
| 122 | + $filter_query_where .= ' AND'; |
|
| 123 | + } |
|
| 117 | 124 | if ($filter_query_where != '') { |
| 118 | 125 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 119 | 126 | } |
@@ -127,10 +134,17 @@ discard block |
||
| 127 | 134 | if ($over_country == '') { |
| 128 | 135 | $Spotter = new Spotter($this->db); |
| 129 | 136 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 130 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 131 | - else $country = ''; |
|
| 132 | - } else $country = $over_country; |
|
| 133 | - if ($airline_type === NULL) $airline_type =''; |
|
| 137 | + if (!empty($data_country)) { |
|
| 138 | + $country = $data_country['iso2']; |
|
| 139 | + } else { |
|
| 140 | + $country = ''; |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + $country = $over_country; |
|
| 144 | + } |
|
| 145 | + if ($airline_type === NULL) { |
|
| 146 | + $airline_type =''; |
|
| 147 | + } |
|
| 134 | 148 | |
| 135 | 149 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 136 | 150 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -626,7 +640,9 @@ discard block |
||
| 626 | 640 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 627 | 641 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 628 | 642 | $translate = $Translation->ident2icao($q_item); |
| 629 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | + if ($translate != $q_item) { |
|
| 644 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 645 | + } |
|
| 630 | 646 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 631 | 647 | $additional_query .= ")"; |
| 632 | 648 | } |
@@ -842,7 +858,9 @@ discard block |
||
| 842 | 858 | date_default_timezone_set($globalTimezone); |
| 843 | 859 | $datetime = new DateTime(); |
| 844 | 860 | $offset = $datetime->format('P'); |
| 845 | - } else $offset = '+00:00'; |
|
| 861 | + } else { |
|
| 862 | + $offset = '+00:00'; |
|
| 863 | + } |
|
| 846 | 864 | if ($date_array[1] != "") |
| 847 | 865 | { |
| 848 | 866 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1108,9 +1126,13 @@ discard block |
||
| 1108 | 1126 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1109 | 1127 | } |
| 1110 | 1128 | } |
| 1111 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1129 | + if ($sincedate != '') { |
|
| 1130 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1131 | + } |
|
| 1112 | 1132 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1113 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1133 | + if ($limit) { |
|
| 1134 | + $query .= " LIMIT 0,10"; |
|
| 1135 | + } |
|
| 1114 | 1136 | |
| 1115 | 1137 | |
| 1116 | 1138 | $sth = $this->db->prepare($query); |
@@ -1154,9 +1176,13 @@ discard block |
||
| 1154 | 1176 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1177 | } |
| 1156 | 1178 | } |
| 1157 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1179 | + if ($sincedate != '') { |
|
| 1180 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1181 | + } |
|
| 1158 | 1182 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1183 | + if ($limit) { |
|
| 1184 | + $query .= " LIMIT 0,10"; |
|
| 1185 | + } |
|
| 1160 | 1186 | |
| 1161 | 1187 | |
| 1162 | 1188 | $sth = $this->db->prepare($query); |
@@ -79,7 +79,9 @@ |
||
| 79 | 79 | $output .= '"type": "'.$spotter_item['type'].'",'; |
| 80 | 80 | if ($spotter_item['type'] == 'wx') { |
| 81 | 81 | $weather = json_decode($spotter_item['description'],true); |
| 82 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
| 82 | + if (isset($weather['temp'])) { |
|
| 83 | + $output.= '"temp": "'.$weather['temp'].'",'; |
|
| 84 | + } |
|
| 83 | 85 | } |
| 84 | 86 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
| 85 | 87 | $output .= '},'; |