@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | $this->db = $Connection->db(); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function addLastStatsUpdate($type,$stats_date) { |
|
| 20 | + public function addLastStatsUpdate($type, $stats_date) { |
|
| 21 | 21 | $query = "DELETE FROM config WHERE name = :type; |
| 22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
| 23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
| 23 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
| 24 | 24 | try { |
| 25 | 25 | $sth = $this->db->prepare($query); |
| 26 | 26 | $sth->execute($query_values); |
| 27 | - } catch(PDOException $e) { |
|
| 27 | + } catch (PDOException $e) { |
|
| 28 | 28 | return "error : ".$e->getMessage(); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | try { |
| 35 | 35 | $sth = $this->db->prepare($query); |
| 36 | 36 | $sth->execute(array(':type' => $type)); |
| 37 | - } catch(PDOException $e) { |
|
| 37 | + } catch (PDOException $e) { |
|
| 38 | 38 | echo "error : ".$e->getMessage(); |
| 39 | 39 | } |
| 40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | try { |
| 55 | 55 | $sth = $this->db->prepare($query); |
| 56 | 56 | $sth->execute(array(':filter_name' => $filter_name)); |
| 57 | - } catch(PDOException $e) { |
|
| 57 | + } catch (PDOException $e) { |
|
| 58 | 58 | return "error : ".$e->getMessage(); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | try { |
| 65 | 65 | $sth = $this->db->prepare($query); |
| 66 | 66 | $sth->execute(); |
| 67 | - } catch(PDOException $e) { |
|
| 67 | + } catch (PDOException $e) { |
|
| 68 | 68 | return "error : ".$e->getMessage(); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | try { |
| 73 | 73 | $sth = $this->db->prepare($query); |
| 74 | 74 | $sth->execute(array(':filter_name' => $filter_name)); |
| 75 | - } catch(PDOException $e) { |
|
| 75 | + } catch (PDOException $e) { |
|
| 76 | 76 | return "error : ".$e->getMessage(); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -82,69 +82,69 @@ discard block |
||
| 82 | 82 | try { |
| 83 | 83 | $sth = $this->db->prepare($query); |
| 84 | 84 | $sth->execute(array(':filter_name' => $filter_name)); |
| 85 | - } catch(PDOException $e) { |
|
| 85 | + } catch (PDOException $e) { |
|
| 86 | 86 | echo "error : ".$e->getMessage(); |
| 87 | 87 | } |
| 88 | 88 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 89 | 89 | return $all; |
| 90 | 90 | } |
| 91 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
| 91 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
| 92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 93 | 93 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 94 | 94 | try { |
| 95 | 95 | $sth = $this->db->prepare($query); |
| 96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 97 | - } catch(PDOException $e) { |
|
| 96 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 97 | + } catch (PDOException $e) { |
|
| 98 | 98 | echo "error : ".$e->getMessage(); |
| 99 | 99 | } |
| 100 | 100 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 101 | 101 | return $all; |
| 102 | 102 | } |
| 103 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
| 103 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
| 104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 105 | 105 | $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"; |
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 109 | - } catch(PDOException $e) { |
|
| 108 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | echo "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 113 | 113 | return $all; |
| 114 | 114 | } |
| 115 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
| 115 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
| 116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 117 | 117 | $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"; |
| 118 | 118 | try { |
| 119 | 119 | $sth = $this->db->prepare($query); |
| 120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 121 | - } catch(PDOException $e) { |
|
| 120 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 121 | + } catch (PDOException $e) { |
|
| 122 | 122 | echo "error : ".$e->getMessage(); |
| 123 | 123 | } |
| 124 | 124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 125 | 125 | return $all; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
| 128 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
| 129 | 129 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 130 | 130 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 131 | 131 | try { |
| 132 | 132 | $sth = $this->db->prepare($query); |
| 133 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 134 | - } catch(PDOException $e) { |
|
| 133 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 134 | + } catch (PDOException $e) { |
|
| 135 | 135 | echo "error : ".$e->getMessage(); |
| 136 | 136 | } |
| 137 | 137 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 138 | 138 | return $all; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
| 141 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
| 142 | 142 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 143 | 143 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 147 | - } catch(PDOException $e) { |
|
| 146 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | echo "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
| 155 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 155 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 156 | 156 | global $globalStatsFilters; |
| 157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 158 | 158 | if ($year == '' && $month == '') { |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | 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"; |
| 161 | 161 | try { |
| 162 | 162 | $sth = $this->db->prepare($query); |
| 163 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 164 | - } catch(PDOException $e) { |
|
| 163 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 164 | + } catch (PDOException $e) { |
|
| 165 | 165 | echo "error : ".$e->getMessage(); |
| 166 | 166 | } |
| 167 | 167 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | if (empty($all)) { |
| 170 | 170 | $filters = array('airlines' => array($stats_airline)); |
| 171 | 171 | if ($filter_name != '') { |
| 172 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 172 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 173 | 173 | } |
| 174 | 174 | $Spotter = new Spotter($this->db); |
| 175 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
| 175 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month); |
|
| 176 | 176 | } |
| 177 | 177 | return $all; |
| 178 | 178 | } |
| 179 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 179 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 180 | 180 | global $globalStatsFilters; |
| 181 | 181 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 182 | 182 | if ($year == '' && $month == '') { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | try { |
| 186 | 186 | $sth = $this->db->prepare($query); |
| 187 | 187 | $sth->execute(array(':filter_name' => $filter_name)); |
| 188 | - } catch(PDOException $e) { |
|
| 188 | + } catch (PDOException $e) { |
|
| 189 | 189 | echo "error : ".$e->getMessage(); |
| 190 | 190 | } |
| 191 | 191 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | $Spotter = new Spotter($this->db); |
| 195 | 195 | $filters = array(); |
| 196 | 196 | if ($filter_name != '') { |
| 197 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 197 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 198 | 198 | } |
| 199 | - $all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
| 199 | + $all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month); |
|
| 200 | 200 | } |
| 201 | 201 | return $all; |
| 202 | 202 | } |
| 203 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 203 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 204 | 204 | global $globalStatsFilters; |
| 205 | 205 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 206 | 206 | if ($year == '' && $month == '') { |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | 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"; |
| 209 | 209 | try { |
| 210 | 210 | $sth = $this->db->prepare($query); |
| 211 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 212 | - } catch(PDOException $e) { |
|
| 211 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 212 | + } catch (PDOException $e) { |
|
| 213 | 213 | echo "error : ".$e->getMessage(); |
| 214 | 214 | } |
| 215 | 215 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | if (empty($all)) { |
| 218 | 218 | $filters = array('airlines' => array($stats_airline)); |
| 219 | 219 | if ($filter_name != '') { |
| 220 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 220 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 221 | 221 | } |
| 222 | 222 | $Spotter = new Spotter($this->db); |
| 223 | - $all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
|
| 223 | + $all = $Spotter->countAllAircraftManufacturers($filters, $year, $month); |
|
| 224 | 224 | } |
| 225 | 225 | return $all; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 228 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 229 | 229 | global $globalStatsFilters; |
| 230 | 230 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 231 | 231 | if ($year == '' && $month == '') { |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
| 234 | 234 | try { |
| 235 | 235 | $sth = $this->db->prepare($query); |
| 236 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 237 | - } catch(PDOException $e) { |
|
| 236 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 237 | + } catch (PDOException $e) { |
|
| 238 | 238 | echo "error : ".$e->getMessage(); |
| 239 | 239 | } |
| 240 | 240 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | if (empty($all)) { |
| 243 | 243 | $filters = array('airlines' => array($stats_airline)); |
| 244 | 244 | if ($filter_name != '') { |
| 245 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 245 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 246 | 246 | } |
| 247 | 247 | $Spotter = new Spotter($this->db); |
| 248 | - $all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
|
| 248 | + $all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month); |
|
| 249 | 249 | } |
| 250 | 250 | return $all; |
| 251 | 251 | } |
@@ -256,23 +256,23 @@ discard block |
||
| 256 | 256 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
| 257 | 257 | try { |
| 258 | 258 | $sth = $this->db->prepare($query); |
| 259 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 260 | - } catch(PDOException $e) { |
|
| 259 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 260 | + } catch (PDOException $e) { |
|
| 261 | 261 | echo "error : ".$e->getMessage(); |
| 262 | 262 | } |
| 263 | 263 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 264 | 264 | if (empty($all)) { |
| 265 | 265 | $filters = array('airlines' => array($stats_airline)); |
| 266 | 266 | if ($filter_name != '') { |
| 267 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 267 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 268 | 268 | } |
| 269 | 269 | $Spotter = new Spotter($this->db); |
| 270 | - $all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
|
| 270 | + $all = $Spotter->countAllDepartureCountries($filters, $year, $month); |
|
| 271 | 271 | } |
| 272 | 272 | return $all; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 275 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 276 | 276 | global $globalStatsFilters; |
| 277 | 277 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 278 | 278 | if ($year == '' && $month == '') { |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | if (isset($forsource)) { |
| 282 | 282 | 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"; |
| 283 | 283 | 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"; |
| 284 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
| 284 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
| 285 | 285 | } else { |
| 286 | 286 | 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"; |
| 287 | 287 | 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"; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | try { |
| 291 | 291 | $sth = $this->db->prepare($query); |
| 292 | 292 | $sth->execute($query_values); |
| 293 | - } catch(PDOException $e) { |
|
| 293 | + } catch (PDOException $e) { |
|
| 294 | 294 | echo "error : ".$e->getMessage(); |
| 295 | 295 | } |
| 296 | 296 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | $Spotter = new Spotter($this->db); |
| 300 | 300 | $filters = array(); |
| 301 | 301 | if ($filter_name != '') { |
| 302 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 302 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 303 | 303 | } |
| 304 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
|
| 304 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month); |
|
| 305 | 305 | } |
| 306 | 306 | return $all; |
| 307 | 307 | } |
| 308 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 308 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 309 | 309 | global $globalStatsFilters; |
| 310 | 310 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 311 | 311 | if ($year == '' && $month == '') { |
@@ -313,8 +313,8 @@ discard block |
||
| 313 | 313 | 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"; |
| 314 | 314 | try { |
| 315 | 315 | $sth = $this->db->prepare($query); |
| 316 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 317 | - } catch(PDOException $e) { |
|
| 316 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 317 | + } catch (PDOException $e) { |
|
| 318 | 318 | echo "error : ".$e->getMessage(); |
| 319 | 319 | } |
| 320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -322,14 +322,14 @@ discard block |
||
| 322 | 322 | if (empty($all)) { |
| 323 | 323 | $filters = array('airlines' => array($stats_airline)); |
| 324 | 324 | if ($filter_name != '') { |
| 325 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 325 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 326 | 326 | } |
| 327 | 327 | $Spotter = new Spotter($this->db); |
| 328 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
| 328 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month); |
|
| 329 | 329 | } |
| 330 | 330 | return $all; |
| 331 | 331 | } |
| 332 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 332 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 333 | 333 | global $globalStatsFilters; |
| 334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 335 | 335 | if ($year == '' && $month == '') { |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | 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"; |
| 338 | 338 | try { |
| 339 | 339 | $sth = $this->db->prepare($query); |
| 340 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 341 | - } catch(PDOException $e) { |
|
| 340 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 341 | + } catch (PDOException $e) { |
|
| 342 | 342 | echo "error : ".$e->getMessage(); |
| 343 | 343 | } |
| 344 | 344 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -346,14 +346,14 @@ discard block |
||
| 346 | 346 | if (empty($all)) { |
| 347 | 347 | $filters = array('airlines' => array($stats_airline)); |
| 348 | 348 | if ($filter_name != '') { |
| 349 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 349 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 350 | 350 | } |
| 351 | 351 | $Spotter = new Spotter($this->db); |
| 352 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
|
| 352 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month); |
|
| 353 | 353 | } |
| 354 | 354 | return $all; |
| 355 | 355 | } |
| 356 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 356 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 357 | 357 | $Connection = new Connection(); |
| 358 | 358 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 359 | 359 | if ($Connection->tableExists('countries')) { |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | 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"; |
| 363 | 363 | try { |
| 364 | 364 | $sth = $this->db->prepare($query); |
| 365 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 366 | - } catch(PDOException $e) { |
|
| 365 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 366 | + } catch (PDOException $e) { |
|
| 367 | 367 | echo "error : ".$e->getMessage(); |
| 368 | 368 | } |
| 369 | 369 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | return array(); |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
| 382 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 383 | 383 | global $globalStatsFilters; |
| 384 | 384 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 385 | 385 | if ($year == '' && $month == '') { |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | 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"; |
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 391 | - } catch(PDOException $e) { |
|
| 390 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -396,15 +396,15 @@ discard block |
||
| 396 | 396 | if (empty($all)) { |
| 397 | 397 | $filters = array('airlines' => array($stats_airline)); |
| 398 | 398 | if ($filter_name != '') { |
| 399 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 399 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 400 | 400 | } |
| 401 | 401 | $Spotter = new Spotter($this->db); |
| 402 | - $all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
|
| 402 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month); |
|
| 403 | 403 | } |
| 404 | 404 | return $all; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 407 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 408 | 408 | global $globalStatsFilters; |
| 409 | 409 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 410 | 410 | if ($year == '' && $month == '') { |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | 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"; |
| 413 | 413 | try { |
| 414 | 414 | $sth = $this->db->prepare($query); |
| 415 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 416 | - } catch(PDOException $e) { |
|
| 415 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 416 | + } catch (PDOException $e) { |
|
| 417 | 417 | echo "error : ".$e->getMessage(); |
| 418 | 418 | } |
| 419 | 419 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | if (empty($all)) { |
| 422 | 422 | $filters = array('airlines' => array($stats_airline)); |
| 423 | 423 | if ($filter_name != '') { |
| 424 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 424 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 425 | 425 | } |
| 426 | 426 | $Spotter = new Spotter($this->db); |
| 427 | - $all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
| 427 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month); |
|
| 428 | 428 | } |
| 429 | 429 | return $all; |
| 430 | 430 | } |
| 431 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 431 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 432 | 432 | global $globalStatsFilters; |
| 433 | 433 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 434 | 434 | if ($year == '' && $month == '') { |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
| 437 | 437 | try { |
| 438 | 438 | $sth = $this->db->prepare($query); |
| 439 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 440 | - } catch(PDOException $e) { |
|
| 439 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 440 | + } catch (PDOException $e) { |
|
| 441 | 441 | echo "error : ".$e->getMessage(); |
| 442 | 442 | } |
| 443 | 443 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | if (empty($all)) { |
| 446 | 446 | $filters = array('airlines' => array($stats_airline)); |
| 447 | 447 | if ($filter_name != '') { |
| 448 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 448 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 449 | 449 | } |
| 450 | 450 | $Spotter = new Spotter($this->db); |
| 451 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
|
| 452 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
|
| 451 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month); |
|
| 452 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month); |
|
| 453 | 453 | $all = array(); |
| 454 | 454 | foreach ($pall as $value) { |
| 455 | 455 | $icao = $value['airport_departure_icao']; |
@@ -466,11 +466,11 @@ discard block |
||
| 466 | 466 | foreach ($all as $key => $row) { |
| 467 | 467 | $count[$key] = $row['airport_departure_icao_count']; |
| 468 | 468 | } |
| 469 | - array_multisort($count,SORT_DESC,$all); |
|
| 469 | + array_multisort($count, SORT_DESC, $all); |
|
| 470 | 470 | } |
| 471 | 471 | return $all; |
| 472 | 472 | } |
| 473 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 473 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 474 | 474 | global $globalStatsFilters; |
| 475 | 475 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 476 | 476 | if ($year == '' && $month == '') { |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
| 479 | 479 | try { |
| 480 | 480 | $sth = $this->db->prepare($query); |
| 481 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 482 | - } catch(PDOException $e) { |
|
| 481 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 482 | + } catch (PDOException $e) { |
|
| 483 | 483 | echo "error : ".$e->getMessage(); |
| 484 | 484 | } |
| 485 | 485 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -487,11 +487,11 @@ discard block |
||
| 487 | 487 | if (empty($all)) { |
| 488 | 488 | $filters = array('airlines' => array($stats_airline)); |
| 489 | 489 | if ($filter_name != '') { |
| 490 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 490 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 491 | 491 | } |
| 492 | 492 | $Spotter = new Spotter($this->db); |
| 493 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
|
| 494 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
|
| 493 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month); |
|
| 494 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month); |
|
| 495 | 495 | $all = array(); |
| 496 | 496 | foreach ($pall as $value) { |
| 497 | 497 | $icao = $value['airport_arrival_icao']; |
@@ -508,12 +508,12 @@ discard block |
||
| 508 | 508 | foreach ($all as $key => $row) { |
| 509 | 509 | $count[$key] = $row['airport_arrival_icao_count']; |
| 510 | 510 | } |
| 511 | - array_multisort($count,SORT_DESC,$all); |
|
| 511 | + array_multisort($count, SORT_DESC, $all); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | return $all; |
| 515 | 515 | } |
| 516 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
| 516 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
| 517 | 517 | global $globalDBdriver, $globalStatsFilters; |
| 518 | 518 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 519 | 519 | if ($globalDBdriver == 'mysql') { |
@@ -523,18 +523,18 @@ discard block |
||
| 523 | 523 | 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"; |
| 524 | 524 | 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"; |
| 525 | 525 | } |
| 526 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 526 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 527 | 527 | try { |
| 528 | 528 | $sth = $this->db->prepare($query); |
| 529 | 529 | $sth->execute($query_data); |
| 530 | - } catch(PDOException $e) { |
|
| 530 | + } catch (PDOException $e) { |
|
| 531 | 531 | echo "error : ".$e->getMessage(); |
| 532 | 532 | } |
| 533 | 533 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 534 | 534 | if (empty($all)) { |
| 535 | 535 | $filters = array('airlines' => array($stats_airline)); |
| 536 | 536 | if ($filter_name != '') { |
| 537 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 537 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 538 | 538 | } |
| 539 | 539 | $Spotter = new Spotter($this->db); |
| 540 | 540 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -543,29 +543,29 @@ discard block |
||
| 543 | 543 | return $all; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
| 546 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
| 547 | 547 | global $globalStatsFilters; |
| 548 | 548 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 549 | 549 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 550 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 550 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 551 | 551 | try { |
| 552 | 552 | $sth = $this->db->prepare($query); |
| 553 | 553 | $sth->execute($query_data); |
| 554 | - } catch(PDOException $e) { |
|
| 554 | + } catch (PDOException $e) { |
|
| 555 | 555 | echo "error : ".$e->getMessage(); |
| 556 | 556 | } |
| 557 | 557 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 558 | 558 | if (empty($all)) { |
| 559 | 559 | $filters = array('airlines' => array($stats_airline)); |
| 560 | 560 | if ($filter_name != '') { |
| 561 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 561 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 562 | 562 | } |
| 563 | 563 | $Spotter = new Spotter($this->db); |
| 564 | 564 | $all = $Spotter->countAllDatesLastMonth($filters); |
| 565 | 565 | } |
| 566 | 566 | return $all; |
| 567 | 567 | } |
| 568 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
| 568 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
| 569 | 569 | global $globalDBdriver, $globalStatsFilters; |
| 570 | 570 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 571 | 571 | if ($globalDBdriver == 'mysql') { |
@@ -573,40 +573,40 @@ discard block |
||
| 573 | 573 | } else { |
| 574 | 574 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 575 | 575 | } |
| 576 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 576 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 577 | 577 | try { |
| 578 | 578 | $sth = $this->db->prepare($query); |
| 579 | 579 | $sth->execute($query_data); |
| 580 | - } catch(PDOException $e) { |
|
| 580 | + } catch (PDOException $e) { |
|
| 581 | 581 | echo "error : ".$e->getMessage(); |
| 582 | 582 | } |
| 583 | 583 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 584 | 584 | if (empty($all)) { |
| 585 | 585 | $filters = array('airlines' => array($stats_airline)); |
| 586 | 586 | if ($filter_name != '') { |
| 587 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 587 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 588 | 588 | } |
| 589 | 589 | $Spotter = new Spotter($this->db); |
| 590 | 590 | $all = $Spotter->countAllDatesLast7Days($filters); |
| 591 | 591 | } |
| 592 | 592 | return $all; |
| 593 | 593 | } |
| 594 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
| 594 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
| 595 | 595 | global $globalStatsFilters; |
| 596 | 596 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 597 | 597 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 598 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 598 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 599 | 599 | try { |
| 600 | 600 | $sth = $this->db->prepare($query); |
| 601 | 601 | $sth->execute($query_data); |
| 602 | - } catch(PDOException $e) { |
|
| 602 | + } catch (PDOException $e) { |
|
| 603 | 603 | echo "error : ".$e->getMessage(); |
| 604 | 604 | } |
| 605 | 605 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 606 | 606 | if (empty($all)) { |
| 607 | 607 | $filters = array('airlines' => array($stats_airline)); |
| 608 | 608 | if ($filter_name != '') { |
| 609 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 609 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 610 | 610 | } |
| 611 | 611 | $Spotter = new Spotter($this->db); |
| 612 | 612 | $all = $Spotter->countAllDates($filters); |
@@ -621,28 +621,28 @@ discard block |
||
| 621 | 621 | try { |
| 622 | 622 | $sth = $this->db->prepare($query); |
| 623 | 623 | $sth->execute($query_data); |
| 624 | - } catch(PDOException $e) { |
|
| 624 | + } catch (PDOException $e) { |
|
| 625 | 625 | echo "error : ".$e->getMessage(); |
| 626 | 626 | } |
| 627 | 627 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 628 | 628 | if (empty($all)) { |
| 629 | 629 | $filters = array(); |
| 630 | 630 | if ($filter_name != '') { |
| 631 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 631 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 632 | 632 | } |
| 633 | 633 | $Spotter = new Spotter($this->db); |
| 634 | 634 | $all = $Spotter->countAllDatesByAirlines($filters); |
| 635 | 635 | } |
| 636 | 636 | return $all; |
| 637 | 637 | } |
| 638 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
| 638 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
| 639 | 639 | global $globalStatsFilters; |
| 640 | 640 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 641 | 641 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 642 | 642 | try { |
| 643 | 643 | $sth = $this->db->prepare($query); |
| 644 | 644 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 645 | - } catch(PDOException $e) { |
|
| 645 | + } catch (PDOException $e) { |
|
| 646 | 646 | echo "error : ".$e->getMessage(); |
| 647 | 647 | } |
| 648 | 648 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | if (empty($all)) { |
| 651 | 651 | $filters = array('airlines' => array($stats_airline)); |
| 652 | 652 | if ($filter_name != '') { |
| 653 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 653 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 654 | 654 | } |
| 655 | 655 | $Spotter = new Spotter($this->db); |
| 656 | 656 | $all = $Spotter->countAllMonths($filters); |
@@ -665,21 +665,21 @@ discard block |
||
| 665 | 665 | try { |
| 666 | 666 | $sth = $this->db->prepare($query); |
| 667 | 667 | $sth->execute(array(':filter_name' => $filter_name)); |
| 668 | - } catch(PDOException $e) { |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | echo "error : ".$e->getMessage(); |
| 670 | 670 | } |
| 671 | 671 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | 672 | if (empty($all)) { |
| 673 | 673 | $filters = array(); |
| 674 | 674 | if ($filter_name != '') { |
| 675 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 675 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 676 | 676 | } |
| 677 | 677 | $Spotter = new Spotter($this->db); |
| 678 | 678 | $all = $Spotter->countAllMilitaryMonths($filters); |
| 679 | 679 | } |
| 680 | 680 | return $all; |
| 681 | 681 | } |
| 682 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
| 682 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
| 683 | 683 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 684 | 684 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 685 | 685 | 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"; |
@@ -696,91 +696,91 @@ discard block |
||
| 696 | 696 | try { |
| 697 | 697 | $sth = $this->db->prepare($query); |
| 698 | 698 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 699 | - } catch(PDOException $e) { |
|
| 699 | + } catch (PDOException $e) { |
|
| 700 | 700 | echo "error : ".$e->getMessage(); |
| 701 | 701 | } |
| 702 | 702 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 703 | 703 | if (empty($all)) { |
| 704 | 704 | $filters = array('airlines' => array($stats_airline)); |
| 705 | 705 | if ($filter_name != '') { |
| 706 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 706 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 707 | 707 | } |
| 708 | 708 | $Spotter = new Spotter($this->db); |
| 709 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 709 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
| 710 | 710 | } |
| 711 | 711 | return $all; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 714 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 715 | 715 | global $globalStatsFilters; |
| 716 | 716 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 717 | 717 | if ($year == '') $year = date('Y'); |
| 718 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 718 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 719 | 719 | if (empty($all)) { |
| 720 | 720 | $filters = array('airlines' => array($stats_airline)); |
| 721 | 721 | if ($filter_name != '') { |
| 722 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 722 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 723 | 723 | } |
| 724 | 724 | $Spotter = new Spotter($this->db); |
| 725 | - $all = $Spotter->countOverallFlights($filters,$year,$month); |
|
| 725 | + $all = $Spotter->countOverallFlights($filters, $year, $month); |
|
| 726 | 726 | } |
| 727 | 727 | return $all; |
| 728 | 728 | } |
| 729 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
| 729 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
| 730 | 730 | global $globalStatsFilters; |
| 731 | 731 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 732 | 732 | if ($year == '') $year = date('Y'); |
| 733 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
| 733 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
| 734 | 734 | if (empty($all)) { |
| 735 | 735 | $filters = array(); |
| 736 | 736 | if ($filter_name != '') { |
| 737 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 737 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 738 | 738 | } |
| 739 | 739 | $Spotter = new Spotter($this->db); |
| 740 | - $all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
|
| 740 | + $all = $Spotter->countOverallMilitaryFlights($filters, $year, $month); |
|
| 741 | 741 | } |
| 742 | 742 | return $all; |
| 743 | 743 | } |
| 744 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
| 744 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 745 | 745 | global $globalStatsFilters; |
| 746 | 746 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 747 | 747 | if ($year == '') $year = date('Y'); |
| 748 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 748 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 749 | 749 | if (empty($all)) { |
| 750 | 750 | $filters = array('airlines' => array($stats_airline)); |
| 751 | 751 | if ($filter_name != '') { |
| 752 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 752 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 753 | 753 | } |
| 754 | 754 | $Spotter = new Spotter($this->db); |
| 755 | - $all = $Spotter->countOverallArrival($filters,$year,$month); |
|
| 755 | + $all = $Spotter->countOverallArrival($filters, $year, $month); |
|
| 756 | 756 | } |
| 757 | 757 | return $all; |
| 758 | 758 | } |
| 759 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 759 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 760 | 760 | global $globalStatsFilters; |
| 761 | 761 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 762 | 762 | if ($year == '' && $month == '') { |
| 763 | 763 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 764 | 764 | try { |
| 765 | 765 | $sth = $this->db->prepare($query); |
| 766 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
| 767 | - } catch(PDOException $e) { |
|
| 766 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
| 767 | + } catch (PDOException $e) { |
|
| 768 | 768 | echo "error : ".$e->getMessage(); |
| 769 | 769 | } |
| 770 | 770 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 771 | 771 | $all = $result[0]['nb']; |
| 772 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 772 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 773 | 773 | if (empty($all)) { |
| 774 | 774 | $filters = array('airlines' => array($stats_airline)); |
| 775 | 775 | if ($filter_name != '') { |
| 776 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 776 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 777 | 777 | } |
| 778 | 778 | $Spotter = new Spotter($this->db); |
| 779 | - $all = $Spotter->countOverallAircrafts($filters,$year,$month); |
|
| 779 | + $all = $Spotter->countOverallAircrafts($filters, $year, $month); |
|
| 780 | 780 | } |
| 781 | 781 | return $all; |
| 782 | 782 | } |
| 783 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
| 783 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
| 784 | 784 | global $globalStatsFilters; |
| 785 | 785 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 786 | 786 | if ($year == '' && $month == '') { |
@@ -788,23 +788,23 @@ discard block |
||
| 788 | 788 | try { |
| 789 | 789 | $sth = $this->db->prepare($query); |
| 790 | 790 | $sth->execute(array(':filter_name' => $filter_name)); |
| 791 | - } catch(PDOException $e) { |
|
| 791 | + } catch (PDOException $e) { |
|
| 792 | 792 | echo "error : ".$e->getMessage(); |
| 793 | 793 | } |
| 794 | 794 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 795 | 795 | $all = $result[0]['nb_airline']; |
| 796 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 796 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
| 797 | 797 | if (empty($all)) { |
| 798 | 798 | $filters = array(); |
| 799 | 799 | if ($filter_name != '') { |
| 800 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 800 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 801 | 801 | } |
| 802 | 802 | $Spotter = new Spotter($this->db); |
| 803 | - $all = $Spotter->countOverallAirlines($filters,$year,$month); |
|
| 803 | + $all = $Spotter->countOverallAirlines($filters, $year, $month); |
|
| 804 | 804 | } |
| 805 | 805 | return $all; |
| 806 | 806 | } |
| 807 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 807 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 808 | 808 | global $globalStatsFilters; |
| 809 | 809 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 810 | 810 | if ($year == '' && $month == '') { |
@@ -813,25 +813,25 @@ discard block |
||
| 813 | 813 | try { |
| 814 | 814 | $sth = $this->db->prepare($query); |
| 815 | 815 | $sth->execute($query_values); |
| 816 | - } catch(PDOException $e) { |
|
| 816 | + } catch (PDOException $e) { |
|
| 817 | 817 | echo "error : ".$e->getMessage(); |
| 818 | 818 | } |
| 819 | 819 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 820 | 820 | $all = $result[0]['nb']; |
| 821 | 821 | } else { |
| 822 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 822 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 823 | 823 | } |
| 824 | 824 | if (empty($all)) { |
| 825 | 825 | $filters = array('airlines' => array($stats_airline)); |
| 826 | 826 | if ($filter_name != '') { |
| 827 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 827 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 828 | 828 | } |
| 829 | 829 | $Spotter = new Spotter($this->db); |
| 830 | - $all = $Spotter->countOverallOwners($filters,$year,$month); |
|
| 830 | + $all = $Spotter->countOverallOwners($filters, $year, $month); |
|
| 831 | 831 | } |
| 832 | 832 | return $all; |
| 833 | 833 | } |
| 834 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 834 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 835 | 835 | global $globalStatsFilters; |
| 836 | 836 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 837 | 837 | //if ($year == '') $year = date('Y'); |
@@ -841,75 +841,75 @@ discard block |
||
| 841 | 841 | try { |
| 842 | 842 | $sth = $this->db->prepare($query); |
| 843 | 843 | $sth->execute($query_values); |
| 844 | - } catch(PDOException $e) { |
|
| 844 | + } catch (PDOException $e) { |
|
| 845 | 845 | echo "error : ".$e->getMessage(); |
| 846 | 846 | } |
| 847 | 847 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 848 | 848 | $all = $result[0]['nb']; |
| 849 | 849 | } else { |
| 850 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 850 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 851 | 851 | } |
| 852 | 852 | if (empty($all)) { |
| 853 | 853 | $filters = array('airlines' => array($stats_airline)); |
| 854 | 854 | if ($filter_name != '') { |
| 855 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 855 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 856 | 856 | } |
| 857 | 857 | $Spotter = new Spotter($this->db); |
| 858 | - $all = $Spotter->countOverallPilots($filters,$year,$month); |
|
| 858 | + $all = $Spotter->countOverallPilots($filters, $year, $month); |
|
| 859 | 859 | } |
| 860 | 860 | return $all; |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
| 863 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
| 864 | 864 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 865 | 865 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 866 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 866 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 867 | 867 | try { |
| 868 | 868 | $sth = $this->db->prepare($query); |
| 869 | 869 | $sth->execute($query_values); |
| 870 | - } catch(PDOException $e) { |
|
| 870 | + } catch (PDOException $e) { |
|
| 871 | 871 | echo "error : ".$e->getMessage(); |
| 872 | 872 | } |
| 873 | 873 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 874 | 874 | return $all; |
| 875 | 875 | } |
| 876 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
| 876 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
| 877 | 877 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 878 | 878 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 879 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 879 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 880 | 880 | try { |
| 881 | 881 | $sth = $this->db->prepare($query); |
| 882 | 882 | $sth->execute($query_values); |
| 883 | - } catch(PDOException $e) { |
|
| 883 | + } catch (PDOException $e) { |
|
| 884 | 884 | echo "error : ".$e->getMessage(); |
| 885 | 885 | } |
| 886 | 886 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 887 | 887 | return $all; |
| 888 | 888 | } |
| 889 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
| 889 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
| 890 | 890 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 891 | 891 | global $globalArchiveMonths, $globalDBdriver; |
| 892 | 892 | if ($globalDBdriver == 'mysql') { |
| 893 | 893 | if ($month == '') { |
| 894 | 894 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 895 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 895 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 896 | 896 | } else { |
| 897 | 897 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 898 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 898 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 899 | 899 | } |
| 900 | 900 | } else { |
| 901 | 901 | if ($month == '') { |
| 902 | 902 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 903 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 903 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 904 | 904 | } else { |
| 905 | 905 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 906 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 906 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 907 | 907 | } |
| 908 | 908 | } |
| 909 | 909 | try { |
| 910 | 910 | $sth = $this->db->prepare($query); |
| 911 | 911 | $sth->execute($query_values); |
| 912 | - } catch(PDOException $e) { |
|
| 912 | + } catch (PDOException $e) { |
|
| 913 | 913 | echo "error : ".$e->getMessage(); |
| 914 | 914 | } |
| 915 | 915 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | try { |
| 928 | 928 | $sth = $this->db->prepare($query); |
| 929 | 929 | $sth->execute($query_values); |
| 930 | - } catch(PDOException $e) { |
|
| 930 | + } catch (PDOException $e) { |
|
| 931 | 931 | echo "error : ".$e->getMessage(); |
| 932 | 932 | } |
| 933 | 933 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | try { |
| 945 | 945 | $sth = $this->db->prepare($query); |
| 946 | 946 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 947 | - } catch(PDOException $e) { |
|
| 947 | + } catch (PDOException $e) { |
|
| 948 | 948 | echo "error : ".$e->getMessage(); |
| 949 | 949 | } |
| 950 | 950 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | try { |
| 962 | 962 | $sth = $this->db->prepare($query); |
| 963 | 963 | $sth->execute(array(':filter_name' => $filter_name)); |
| 964 | - } catch(PDOException $e) { |
|
| 964 | + } catch (PDOException $e) { |
|
| 965 | 965 | echo "error : ".$e->getMessage(); |
| 966 | 966 | } |
| 967 | 967 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -978,20 +978,20 @@ discard block |
||
| 978 | 978 | try { |
| 979 | 979 | $sth = $this->db->prepare($query); |
| 980 | 980 | $sth->execute(array(':filter_name' => $filter_name)); |
| 981 | - } catch(PDOException $e) { |
|
| 981 | + } catch (PDOException $e) { |
|
| 982 | 982 | echo "error : ".$e->getMessage(); |
| 983 | 983 | } |
| 984 | 984 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 985 | 985 | return $all[0]['total']; |
| 986 | 986 | } |
| 987 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
| 987 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
| 988 | 988 | global $globalArchiveMonths, $globalDBdriver; |
| 989 | 989 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 990 | 990 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 991 | 991 | try { |
| 992 | 992 | $sth = $this->db->prepare($query); |
| 993 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 994 | - } catch(PDOException $e) { |
|
| 993 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
| 994 | + } catch (PDOException $e) { |
|
| 995 | 995 | echo "error : ".$e->getMessage(); |
| 996 | 996 | } |
| 997 | 997 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1009,20 +1009,20 @@ discard block |
||
| 1009 | 1009 | try { |
| 1010 | 1010 | $sth = $this->db->prepare($query); |
| 1011 | 1011 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1012 | - } catch(PDOException $e) { |
|
| 1012 | + } catch (PDOException $e) { |
|
| 1013 | 1013 | echo "error : ".$e->getMessage(); |
| 1014 | 1014 | } |
| 1015 | 1015 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1016 | 1016 | return $all[0]['total']; |
| 1017 | 1017 | } |
| 1018 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
| 1018 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
| 1019 | 1019 | global $globalArchiveMonths, $globalDBdriver; |
| 1020 | 1020 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1021 | 1021 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1022 | 1022 | try { |
| 1023 | 1023 | $sth = $this->db->prepare($query); |
| 1024 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1025 | - } catch(PDOException $e) { |
|
| 1024 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
| 1025 | + } catch (PDOException $e) { |
|
| 1026 | 1026 | echo "error : ".$e->getMessage(); |
| 1027 | 1027 | } |
| 1028 | 1028 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | else return 0; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1033 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1034 | 1034 | global $globalDBdriver; |
| 1035 | 1035 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1036 | 1036 | if ($globalDBdriver == 'mysql') { |
@@ -1038,15 +1038,15 @@ discard block |
||
| 1038 | 1038 | } else { |
| 1039 | 1039 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1040 | 1040 | } |
| 1041 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1041 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1042 | 1042 | try { |
| 1043 | 1043 | $sth = $this->db->prepare($query); |
| 1044 | 1044 | $sth->execute($query_values); |
| 1045 | - } catch(PDOException $e) { |
|
| 1045 | + } catch (PDOException $e) { |
|
| 1046 | 1046 | return "error : ".$e->getMessage(); |
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1049 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1050 | 1050 | global $globalDBdriver; |
| 1051 | 1051 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1052 | 1052 | if ($globalDBdriver == 'mysql') { |
@@ -1055,11 +1055,11 @@ discard block |
||
| 1055 | 1055 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1056 | 1056 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1057 | 1057 | } |
| 1058 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1058 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1059 | 1059 | try { |
| 1060 | 1060 | $sth = $this->db->prepare($query); |
| 1061 | 1061 | $sth->execute($query_values); |
| 1062 | - } catch(PDOException $e) { |
|
| 1062 | + } catch (PDOException $e) { |
|
| 1063 | 1063 | return "error : ".$e->getMessage(); |
| 1064 | 1064 | } |
| 1065 | 1065 | } |
@@ -1083,75 +1083,75 @@ discard block |
||
| 1083 | 1083 | } |
| 1084 | 1084 | */ |
| 1085 | 1085 | |
| 1086 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
| 1086 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
| 1087 | 1087 | global $globalDBdriver; |
| 1088 | 1088 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
| 1089 | 1089 | $query_values = array(); |
| 1090 | 1090 | if ($globalDBdriver == 'mysql') { |
| 1091 | 1091 | if ($year != '') { |
| 1092 | 1092 | $query .= ' AND YEAR(stats_date) = :year'; |
| 1093 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1093 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1094 | 1094 | } |
| 1095 | 1095 | if ($month != '') { |
| 1096 | 1096 | $query .= ' AND MONTH(stats_date) = :month'; |
| 1097 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1097 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | if ($day != '') { |
| 1100 | 1100 | $query .= ' AND DAY(stats_date) = :day'; |
| 1101 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1101 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | } else { |
| 1104 | 1104 | if ($year != '') { |
| 1105 | 1105 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
| 1106 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1106 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | if ($month != '') { |
| 1109 | 1109 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
| 1110 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1110 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | if ($day != '') { |
| 1113 | 1113 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
| 1114 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1114 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | } |
| 1117 | 1117 | $query .= " ORDER BY source_name"; |
| 1118 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
| 1118 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
| 1119 | 1119 | try { |
| 1120 | 1120 | $sth = $this->db->prepare($query); |
| 1121 | 1121 | $sth->execute($query_values); |
| 1122 | - } catch(PDOException $e) { |
|
| 1122 | + } catch (PDOException $e) { |
|
| 1123 | 1123 | echo "error : ".$e->getMessage(); |
| 1124 | 1124 | } |
| 1125 | 1125 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1126 | 1126 | return $all; |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
| 1129 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
| 1130 | 1130 | global $globalDBdriver; |
| 1131 | 1131 | if ($globalDBdriver == 'mysql') { |
| 1132 | 1132 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
| 1133 | 1133 | } else { |
| 1134 | 1134 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
| 1135 | 1135 | } |
| 1136 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 1136 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
| 1137 | 1137 | try { |
| 1138 | 1138 | $sth = $this->db->prepare($query); |
| 1139 | 1139 | $sth->execute($query_values); |
| 1140 | - } catch(PDOException $e) { |
|
| 1140 | + } catch (PDOException $e) { |
|
| 1141 | 1141 | return "error : ".$e->getMessage(); |
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 1144 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
| 1145 | 1145 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
| 1146 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1146 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1147 | 1147 | try { |
| 1148 | 1148 | $sth = $this->db->prepare($query); |
| 1149 | 1149 | $sth->execute($query_values); |
| 1150 | - } catch(PDOException $e) { |
|
| 1150 | + } catch (PDOException $e) { |
|
| 1151 | 1151 | return "error : ".$e->getMessage(); |
| 1152 | 1152 | } |
| 1153 | 1153 | } |
| 1154 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1154 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1155 | 1155 | global $globalDBdriver; |
| 1156 | 1156 | if ($globalDBdriver == 'mysql') { |
| 1157 | 1157 | if ($reset) { |
@@ -1166,15 +1166,15 @@ discard block |
||
| 1166 | 1166 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1169 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1170 | 1170 | try { |
| 1171 | 1171 | $sth = $this->db->prepare($query); |
| 1172 | 1172 | $sth->execute($query_values); |
| 1173 | - } catch(PDOException $e) { |
|
| 1173 | + } catch (PDOException $e) { |
|
| 1174 | 1174 | return "error : ".$e->getMessage(); |
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1177 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1178 | 1178 | global $globalDBdriver; |
| 1179 | 1179 | if ($globalDBdriver == 'mysql') { |
| 1180 | 1180 | if ($reset) { |
@@ -1189,15 +1189,15 @@ discard block |
||
| 1189 | 1189 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1192 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1193 | 1193 | try { |
| 1194 | 1194 | $sth = $this->db->prepare($query); |
| 1195 | 1195 | $sth->execute($query_values); |
| 1196 | - } catch(PDOException $e) { |
|
| 1196 | + } catch (PDOException $e) { |
|
| 1197 | 1197 | return "error : ".$e->getMessage(); |
| 1198 | 1198 | } |
| 1199 | 1199 | } |
| 1200 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1200 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | if ($globalDBdriver == 'mysql') { |
| 1203 | 1203 | if ($reset) { |
@@ -1212,15 +1212,15 @@ discard block |
||
| 1212 | 1212 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 1215 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
| 1216 | 1216 | try { |
| 1217 | 1217 | $sth = $this->db->prepare($query); |
| 1218 | 1218 | $sth->execute($query_values); |
| 1219 | - } catch(PDOException $e) { |
|
| 1219 | + } catch (PDOException $e) { |
|
| 1220 | 1220 | return "error : ".$e->getMessage(); |
| 1221 | 1221 | } |
| 1222 | 1222 | } |
| 1223 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1223 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1224 | 1224 | global $globalDBdriver; |
| 1225 | 1225 | if ($globalDBdriver == 'mysql') { |
| 1226 | 1226 | if ($reset) { |
@@ -1235,15 +1235,15 @@ discard block |
||
| 1235 | 1235 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1238 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1239 | 1239 | try { |
| 1240 | 1240 | $sth = $this->db->prepare($query); |
| 1241 | 1241 | $sth->execute($query_values); |
| 1242 | - } catch(PDOException $e) { |
|
| 1242 | + } catch (PDOException $e) { |
|
| 1243 | 1243 | return "error : ".$e->getMessage(); |
| 1244 | 1244 | } |
| 1245 | 1245 | } |
| 1246 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
| 1246 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
| 1247 | 1247 | global $globalDBdriver; |
| 1248 | 1248 | if ($globalDBdriver == 'mysql') { |
| 1249 | 1249 | if ($reset) { |
@@ -1258,15 +1258,15 @@ discard block |
||
| 1258 | 1258 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 1261 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1262 | 1262 | try { |
| 1263 | 1263 | $sth = $this->db->prepare($query); |
| 1264 | 1264 | $sth->execute($query_values); |
| 1265 | - } catch(PDOException $e) { |
|
| 1265 | + } catch (PDOException $e) { |
|
| 1266 | 1266 | return "error : ".$e->getMessage(); |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
| 1269 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1269 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1270 | 1270 | global $globalDBdriver; |
| 1271 | 1271 | if ($globalDBdriver == 'mysql') { |
| 1272 | 1272 | if ($reset) { |
@@ -1281,15 +1281,15 @@ discard block |
||
| 1281 | 1281 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1282 | 1282 | } |
| 1283 | 1283 | } |
| 1284 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1284 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1285 | 1285 | try { |
| 1286 | 1286 | $sth = $this->db->prepare($query); |
| 1287 | 1287 | $sth->execute($query_values); |
| 1288 | - } catch(PDOException $e) { |
|
| 1288 | + } catch (PDOException $e) { |
|
| 1289 | 1289 | return "error : ".$e->getMessage(); |
| 1290 | 1290 | } |
| 1291 | 1291 | } |
| 1292 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
| 1292 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
| 1293 | 1293 | global $globalDBdriver; |
| 1294 | 1294 | if ($globalDBdriver == 'mysql') { |
| 1295 | 1295 | if ($reset) { |
@@ -1304,15 +1304,15 @@ discard block |
||
| 1304 | 1304 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
| 1307 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
| 1308 | 1308 | try { |
| 1309 | 1309 | $sth = $this->db->prepare($query); |
| 1310 | 1310 | $sth->execute($query_values); |
| 1311 | - } catch(PDOException $e) { |
|
| 1311 | + } catch (PDOException $e) { |
|
| 1312 | 1312 | return "error : ".$e->getMessage(); |
| 1313 | 1313 | } |
| 1314 | 1314 | } |
| 1315 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1315 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1316 | 1316 | global $globalDBdriver; |
| 1317 | 1317 | if ($airport_icao != '') { |
| 1318 | 1318 | if ($globalDBdriver == 'mysql') { |
@@ -1328,16 +1328,16 @@ discard block |
||
| 1328 | 1328 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 1329 | 1329 | } |
| 1330 | 1330 | } |
| 1331 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1331 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1332 | 1332 | try { |
| 1333 | 1333 | $sth = $this->db->prepare($query); |
| 1334 | 1334 | $sth->execute($query_values); |
| 1335 | - } catch(PDOException $e) { |
|
| 1335 | + } catch (PDOException $e) { |
|
| 1336 | 1336 | return "error : ".$e->getMessage(); |
| 1337 | 1337 | } |
| 1338 | 1338 | } |
| 1339 | 1339 | } |
| 1340 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
| 1340 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
| 1341 | 1341 | global $globalDBdriver; |
| 1342 | 1342 | if ($airport_icao != '') { |
| 1343 | 1343 | if ($globalDBdriver == 'mysql') { |
@@ -1345,16 +1345,16 @@ discard block |
||
| 1345 | 1345 | } else { |
| 1346 | 1346 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1347 | 1347 | } |
| 1348 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1348 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1349 | 1349 | try { |
| 1350 | 1350 | $sth = $this->db->prepare($query); |
| 1351 | 1351 | $sth->execute($query_values); |
| 1352 | - } catch(PDOException $e) { |
|
| 1352 | + } catch (PDOException $e) { |
|
| 1353 | 1353 | return "error : ".$e->getMessage(); |
| 1354 | 1354 | } |
| 1355 | 1355 | } |
| 1356 | 1356 | } |
| 1357 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1357 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1358 | 1358 | global $globalDBdriver; |
| 1359 | 1359 | if ($airport_icao != '') { |
| 1360 | 1360 | if ($globalDBdriver == 'mysql') { |
@@ -1370,16 +1370,16 @@ discard block |
||
| 1370 | 1370 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 1371 | 1371 | } |
| 1372 | 1372 | } |
| 1373 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1373 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1374 | 1374 | try { |
| 1375 | 1375 | $sth = $this->db->prepare($query); |
| 1376 | 1376 | $sth->execute($query_values); |
| 1377 | - } catch(PDOException $e) { |
|
| 1377 | + } catch (PDOException $e) { |
|
| 1378 | 1378 | return "error : ".$e->getMessage(); |
| 1379 | 1379 | } |
| 1380 | 1380 | } |
| 1381 | 1381 | } |
| 1382 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
| 1382 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
| 1383 | 1383 | global $globalDBdriver; |
| 1384 | 1384 | if ($airport_icao != '') { |
| 1385 | 1385 | if ($globalDBdriver == 'mysql') { |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | } else { |
| 1388 | 1388 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1389 | 1389 | } |
| 1390 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1390 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1391 | 1391 | try { |
| 1392 | 1392 | $sth = $this->db->prepare($query); |
| 1393 | 1393 | $sth->execute($query_values); |
| 1394 | - } catch(PDOException $e) { |
|
| 1394 | + } catch (PDOException $e) { |
|
| 1395 | 1395 | return "error : ".$e->getMessage(); |
| 1396 | 1396 | } |
| 1397 | 1397 | } |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | try { |
| 1404 | 1404 | $sth = $this->db->prepare($query); |
| 1405 | 1405 | $sth->execute($query_values); |
| 1406 | - } catch(PDOException $e) { |
|
| 1406 | + } catch (PDOException $e) { |
|
| 1407 | 1407 | return "error : ".$e->getMessage(); |
| 1408 | 1408 | } |
| 1409 | 1409 | } |
@@ -1413,7 +1413,7 @@ discard block |
||
| 1413 | 1413 | try { |
| 1414 | 1414 | $sth = $this->db->prepare($query); |
| 1415 | 1415 | $sth->execute($query_values); |
| 1416 | - } catch(PDOException $e) { |
|
| 1416 | + } catch (PDOException $e) { |
|
| 1417 | 1417 | return "error : ".$e->getMessage(); |
| 1418 | 1418 | } |
| 1419 | 1419 | } |
@@ -1423,13 +1423,13 @@ discard block |
||
| 1423 | 1423 | try { |
| 1424 | 1424 | $sth = $this->db->prepare($query); |
| 1425 | 1425 | $sth->execute($query_values); |
| 1426 | - } catch(PDOException $e) { |
|
| 1426 | + } catch (PDOException $e) { |
|
| 1427 | 1427 | return "error : ".$e->getMessage(); |
| 1428 | 1428 | } |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | public function addOldStats() { |
| 1432 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
| 1432 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear; |
|
| 1433 | 1433 | $Common = new Common(); |
| 1434 | 1434 | $Connection = new Connection(); |
| 1435 | 1435 | date_default_timezone_set('UTC'); |
@@ -1446,40 +1446,40 @@ discard block |
||
| 1446 | 1446 | $Spotter = new Spotter($this->db); |
| 1447 | 1447 | |
| 1448 | 1448 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 1449 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
| 1449 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
| 1450 | 1450 | foreach ($alldata as $number) { |
| 1451 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
| 1451 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 1454 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
| 1454 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
| 1455 | 1455 | foreach ($alldata as $number) { |
| 1456 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
| 1456 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
| 1459 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
| 1459 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
| 1460 | 1460 | foreach ($alldata as $number) { |
| 1461 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
| 1461 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 1464 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
| 1464 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
| 1465 | 1465 | foreach ($alldata as $number) { |
| 1466 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 1466 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 1467 | 1467 | } |
| 1468 | 1468 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 1469 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
| 1469 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
| 1470 | 1470 | foreach ($alldata as $number) { |
| 1471 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
| 1471 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 1474 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
| 1474 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
| 1475 | 1475 | foreach ($alldata as $number) { |
| 1476 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
| 1476 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 1480 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
| 1480 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
| 1481 | 1481 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 1482 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 1482 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
| 1483 | 1483 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 1484 | 1484 | $alldata = array(); |
| 1485 | 1485 | |
@@ -1497,14 +1497,14 @@ discard block |
||
| 1497 | 1497 | foreach ($alldata as $key => $row) { |
| 1498 | 1498 | $count[$key] = $row['airport_departure_icao_count']; |
| 1499 | 1499 | } |
| 1500 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1500 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 1501 | 1501 | foreach ($alldata as $number) { |
| 1502 | - 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); |
|
| 1502 | + 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); |
|
| 1503 | 1503 | } |
| 1504 | 1504 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 1505 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
| 1505 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
| 1506 | 1506 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 1507 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 1507 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
| 1508 | 1508 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 1509 | 1509 | $alldata = array(); |
| 1510 | 1510 | foreach ($pall as $value) { |
@@ -1521,16 +1521,16 @@ discard block |
||
| 1521 | 1521 | foreach ($alldata as $key => $row) { |
| 1522 | 1522 | $count[$key] = $row['airport_arrival_icao_count']; |
| 1523 | 1523 | } |
| 1524 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1524 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 1525 | 1525 | foreach ($alldata as $number) { |
| 1526 | - 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); |
|
| 1526 | + 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); |
|
| 1527 | 1527 | } |
| 1528 | 1528 | if ($Connection->tableExists('countries')) { |
| 1529 | 1529 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
| 1530 | 1530 | $SpotterArchive = new SpotterArchive(); |
| 1531 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
| 1531 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
| 1532 | 1532 | foreach ($alldata as $number) { |
| 1533 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
| 1533 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
| 1534 | 1534 | } |
| 1535 | 1535 | } |
| 1536 | 1536 | |
@@ -1544,37 +1544,37 @@ discard block |
||
| 1544 | 1544 | $lastyear = false; |
| 1545 | 1545 | foreach ($alldata as $number) { |
| 1546 | 1546 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 1547 | - $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']))); |
|
| 1547 | + $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']))); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
| 1550 | 1550 | $alldata = $Spotter->countAllMilitaryMonths(); |
| 1551 | 1551 | foreach ($alldata as $number) { |
| 1552 | - $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']))); |
|
| 1552 | + $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']))); |
|
| 1553 | 1553 | } |
| 1554 | 1554 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 1555 | 1555 | $alldata = $Spotter->countAllMonthsOwners(); |
| 1556 | 1556 | foreach ($alldata as $number) { |
| 1557 | - $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']))); |
|
| 1557 | + $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']))); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 1560 | 1560 | $alldata = $Spotter->countAllMonthsPilots(); |
| 1561 | 1561 | foreach ($alldata as $number) { |
| 1562 | - $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']))); |
|
| 1562 | + $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']))); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
| 1565 | 1565 | $alldata = $Spotter->countAllMonthsAirlines(); |
| 1566 | 1566 | foreach ($alldata as $number) { |
| 1567 | - $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']))); |
|
| 1567 | + $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']))); |
|
| 1568 | 1568 | } |
| 1569 | 1569 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 1570 | 1570 | $alldata = $Spotter->countAllMonthsAircrafts(); |
| 1571 | 1571 | foreach ($alldata as $number) { |
| 1572 | - $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']))); |
|
| 1572 | + $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']))); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 1575 | 1575 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
| 1576 | 1576 | foreach ($alldata as $number) { |
| 1577 | - $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']))); |
|
| 1577 | + $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']))); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | if ($globalDebug) echo 'Airports data...'."\n"; |
| 1580 | 1580 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1619,7 +1619,7 @@ discard block |
||
| 1619 | 1619 | } |
| 1620 | 1620 | $alldata = $pall; |
| 1621 | 1621 | foreach ($alldata as $number) { |
| 1622 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
| 1622 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
| 1623 | 1623 | } |
| 1624 | 1624 | echo '...Arrival'."\n"; |
| 1625 | 1625 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1661,7 +1661,7 @@ discard block |
||
| 1661 | 1661 | } |
| 1662 | 1662 | $alldata = $pall; |
| 1663 | 1663 | foreach ($alldata as $number) { |
| 1664 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
| 1664 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | echo 'Flights data...'."\n"; |
@@ -1669,28 +1669,28 @@ discard block |
||
| 1669 | 1669 | echo '-> countAllDatesLastMonth...'."\n"; |
| 1670 | 1670 | $alldata = $Spotter->countAllDatesLastMonth(); |
| 1671 | 1671 | foreach ($alldata as $number) { |
| 1672 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
| 1672 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
| 1673 | 1673 | } |
| 1674 | 1674 | echo '-> countAllDates...'."\n"; |
| 1675 | 1675 | $previousdata = $this->countAllDates(); |
| 1676 | 1676 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
| 1677 | 1677 | $this->deleteStatFlight('date'); |
| 1678 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
| 1678 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
| 1679 | 1679 | $values = array(); |
| 1680 | 1680 | foreach ($alldata as $cnt) { |
| 1681 | 1681 | $values[] = $cnt['date_count']; |
| 1682 | 1682 | } |
| 1683 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 1684 | - array_splice($alldata,11); |
|
| 1683 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 1684 | + array_splice($alldata, 11); |
|
| 1685 | 1685 | foreach ($alldata as $number) { |
| 1686 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
| 1686 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | 1689 | $this->deleteStatFlight('hour'); |
| 1690 | 1690 | echo '-> countAllHours...'."\n"; |
| 1691 | 1691 | $alldata = $Spotter->countAllHours('hour'); |
| 1692 | 1692 | foreach ($alldata as $number) { |
| 1693 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
| 1693 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | |
@@ -1700,41 +1700,41 @@ discard block |
||
| 1700 | 1700 | if ($Connection->tableExists('countries')) { |
| 1701 | 1701 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
| 1702 | 1702 | $SpotterArchive = new SpotterArchive(); |
| 1703 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
| 1703 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
| 1704 | 1704 | foreach ($alldata as $number) { |
| 1705 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
| 1705 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
| 1706 | 1706 | } |
| 1707 | 1707 | } |
| 1708 | 1708 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
| 1709 | 1709 | $Spotter = new Spotter($this->db); |
| 1710 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
| 1710 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
| 1711 | 1711 | foreach ($alldata as $number) { |
| 1712 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
| 1712 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
| 1713 | 1713 | } |
| 1714 | 1714 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
| 1715 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
| 1715 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
| 1716 | 1716 | foreach ($alldata as $number) { |
| 1717 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
| 1717 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
| 1718 | 1718 | } |
| 1719 | 1719 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
| 1720 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
| 1720 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
| 1721 | 1721 | foreach ($alldata as $number) { |
| 1722 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 1722 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
| 1725 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
| 1725 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
| 1726 | 1726 | foreach ($alldata as $number) { |
| 1727 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
| 1727 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
| 1728 | 1728 | } |
| 1729 | 1729 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
| 1730 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
| 1730 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
| 1731 | 1731 | foreach ($alldata as $number) { |
| 1732 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
| 1732 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 1735 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 1735 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 1736 | 1736 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 1737 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 1737 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 1738 | 1738 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 1739 | 1739 | //$alldata = array(); |
| 1740 | 1740 | foreach ($dall as $value) { |
@@ -1754,12 +1754,12 @@ discard block |
||
| 1754 | 1754 | } |
| 1755 | 1755 | $alldata = $pall; |
| 1756 | 1756 | foreach ($alldata as $number) { |
| 1757 | - 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); |
|
| 1757 | + 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); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 1760 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 1760 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 1761 | 1761 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 1762 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 1762 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 1763 | 1763 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 1764 | 1764 | //$alldata = array(); |
| 1765 | 1765 | foreach ($dall as $value) { |
@@ -1779,7 +1779,7 @@ discard block |
||
| 1779 | 1779 | } |
| 1780 | 1780 | $alldata = $pall; |
| 1781 | 1781 | foreach ($alldata as $number) { |
| 1782 | - 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); |
|
| 1782 | + 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); |
|
| 1783 | 1783 | } |
| 1784 | 1784 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
| 1785 | 1785 | $Spotter = new Spotter($this->db); |
@@ -1787,27 +1787,27 @@ discard block |
||
| 1787 | 1787 | $lastyear = false; |
| 1788 | 1788 | foreach ($alldata as $number) { |
| 1789 | 1789 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 1790 | - $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']); |
|
| 1790 | + $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']); |
|
| 1791 | 1791 | } |
| 1792 | 1792 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
| 1793 | 1793 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
| 1794 | 1794 | foreach ($alldata as $number) { |
| 1795 | - $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']); |
|
| 1795 | + $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']); |
|
| 1796 | 1796 | } |
| 1797 | 1797 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
| 1798 | 1798 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
| 1799 | 1799 | foreach ($alldata as $number) { |
| 1800 | - $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']); |
|
| 1800 | + $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']); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
| 1803 | 1803 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
| 1804 | 1804 | foreach ($alldata as $number) { |
| 1805 | - $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']); |
|
| 1805 | + $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']); |
|
| 1806 | 1806 | } |
| 1807 | 1807 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
| 1808 | 1808 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
| 1809 | 1809 | foreach ($alldata as $number) { |
| 1810 | - $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']); |
|
| 1810 | + $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']); |
|
| 1811 | 1811 | } |
| 1812 | 1812 | if ($globalDebug) echo '...Departure'."\n"; |
| 1813 | 1813 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1830,7 +1830,7 @@ discard block |
||
| 1830 | 1830 | } |
| 1831 | 1831 | $alldata = $pall; |
| 1832 | 1832 | foreach ($alldata as $number) { |
| 1833 | - $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']); |
|
| 1833 | + $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']); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | if ($globalDebug) echo '...Arrival'."\n"; |
| 1836 | 1836 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1853,32 +1853,32 @@ discard block |
||
| 1853 | 1853 | } |
| 1854 | 1854 | $alldata = $pall; |
| 1855 | 1855 | foreach ($alldata as $number) { |
| 1856 | - $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']); |
|
| 1856 | + $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']); |
|
| 1857 | 1857 | } |
| 1858 | 1858 | |
| 1859 | 1859 | if ($globalDebug) echo 'Flights data...'."\n"; |
| 1860 | 1860 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
| 1861 | 1861 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
| 1862 | 1862 | foreach ($alldata as $number) { |
| 1863 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
| 1863 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
| 1866 | 1866 | //$previousdata = $this->countAllDatesByAirlines(); |
| 1867 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
| 1867 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
| 1868 | 1868 | $values = array(); |
| 1869 | 1869 | foreach ($alldata as $cnt) { |
| 1870 | 1870 | $values[] = $cnt['date_count']; |
| 1871 | 1871 | } |
| 1872 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 1873 | - array_splice($alldata,11); |
|
| 1872 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 1873 | + array_splice($alldata, 11); |
|
| 1874 | 1874 | foreach ($alldata as $number) { |
| 1875 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
| 1875 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 1878 | 1878 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
| 1879 | 1879 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
| 1880 | 1880 | foreach ($alldata as $number) { |
| 1881 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
| 1881 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | 1884 | |
@@ -1897,32 +1897,32 @@ discard block |
||
| 1897 | 1897 | // Count by filter |
| 1898 | 1898 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
| 1899 | 1899 | $Spotter = new Spotter($this->db); |
| 1900 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
| 1900 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
| 1901 | 1901 | foreach ($alldata as $number) { |
| 1902 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
| 1902 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
| 1903 | 1903 | } |
| 1904 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
| 1904 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
| 1905 | 1905 | foreach ($alldata as $number) { |
| 1906 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
| 1906 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
| 1907 | 1907 | } |
| 1908 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
| 1908 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
| 1909 | 1909 | foreach ($alldata as $number) { |
| 1910 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
| 1910 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
| 1911 | 1911 | } |
| 1912 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
| 1912 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
| 1913 | 1913 | foreach ($alldata as $number) { |
| 1914 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
| 1914 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
| 1915 | 1915 | } |
| 1916 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
| 1916 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
| 1917 | 1917 | foreach ($alldata as $number) { |
| 1918 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
| 1918 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
| 1919 | 1919 | } |
| 1920 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
| 1920 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
| 1921 | 1921 | foreach ($alldata as $number) { |
| 1922 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
| 1922 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
| 1923 | 1923 | } |
| 1924 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
| 1925 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 1924 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 1925 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 1926 | 1926 | $alldata = array(); |
| 1927 | 1927 | foreach ($pall as $value) { |
| 1928 | 1928 | $icao = $value['airport_departure_icao']; |
@@ -1938,12 +1938,12 @@ discard block |
||
| 1938 | 1938 | foreach ($alldata as $key => $row) { |
| 1939 | 1939 | $count[$key] = $row['airport_departure_icao_count']; |
| 1940 | 1940 | } |
| 1941 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1941 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 1942 | 1942 | foreach ($alldata as $number) { |
| 1943 | - 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); |
|
| 1943 | + 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); |
|
| 1944 | 1944 | } |
| 1945 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 1946 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 1945 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 1946 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 1947 | 1947 | $alldata = array(); |
| 1948 | 1948 | foreach ($pall as $value) { |
| 1949 | 1949 | $icao = $value['airport_arrival_icao']; |
@@ -1959,40 +1959,40 @@ discard block |
||
| 1959 | 1959 | foreach ($alldata as $key => $row) { |
| 1960 | 1960 | $count[$key] = $row['airport_arrival_icao_count']; |
| 1961 | 1961 | } |
| 1962 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1962 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 1963 | 1963 | foreach ($alldata as $number) { |
| 1964 | - 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); |
|
| 1964 | + 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); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | $Spotter = new Spotter($this->db); |
| 1967 | 1967 | $alldata = $Spotter->countAllMonths($filter); |
| 1968 | 1968 | $lastyear = false; |
| 1969 | 1969 | foreach ($alldata as $number) { |
| 1970 | 1970 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 1971 | - $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); |
|
| 1971 | + $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); |
|
| 1972 | 1972 | } |
| 1973 | 1973 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 1974 | 1974 | foreach ($alldata as $number) { |
| 1975 | - $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); |
|
| 1975 | + $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); |
|
| 1976 | 1976 | } |
| 1977 | 1977 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 1978 | 1978 | foreach ($alldata as $number) { |
| 1979 | - $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); |
|
| 1979 | + $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); |
|
| 1980 | 1980 | } |
| 1981 | 1981 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 1982 | 1982 | foreach ($alldata as $number) { |
| 1983 | - $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); |
|
| 1983 | + $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); |
|
| 1984 | 1984 | } |
| 1985 | 1985 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 1986 | 1986 | foreach ($alldata as $number) { |
| 1987 | - $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); |
|
| 1987 | + $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); |
|
| 1988 | 1988 | } |
| 1989 | 1989 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 1990 | 1990 | foreach ($alldata as $number) { |
| 1991 | - $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); |
|
| 1991 | + $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); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | echo '...Departure'."\n"; |
| 1994 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
| 1995 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 1994 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
| 1995 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
| 1996 | 1996 | foreach ($dall as $value) { |
| 1997 | 1997 | $icao = $value['departure_airport_icao']; |
| 1998 | 1998 | $ddate = $value['date']; |
@@ -2010,11 +2010,11 @@ discard block |
||
| 2010 | 2010 | } |
| 2011 | 2011 | $alldata = $pall; |
| 2012 | 2012 | foreach ($alldata as $number) { |
| 2013 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
| 2013 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | echo '...Arrival'."\n"; |
| 2016 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
| 2017 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 2016 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
| 2017 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
| 2018 | 2018 | foreach ($dall as $value) { |
| 2019 | 2019 | $icao = $value['arrival_airport_icao']; |
| 2020 | 2020 | $ddate = $value['date']; |
@@ -2032,40 +2032,40 @@ discard block |
||
| 2032 | 2032 | } |
| 2033 | 2033 | $alldata = $pall; |
| 2034 | 2034 | foreach ($alldata as $number) { |
| 2035 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
| 2035 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | echo 'Flights data...'."\n"; |
| 2039 | 2039 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2040 | 2040 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
| 2041 | 2041 | foreach ($alldata as $number) { |
| 2042 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
| 2042 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2043 | 2043 | } |
| 2044 | 2044 | echo '-> countAllDates...'."\n"; |
| 2045 | - $previousdata = $this->countAllDates('',$filter_name); |
|
| 2046 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
| 2045 | + $previousdata = $this->countAllDates('', $filter_name); |
|
| 2046 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
| 2047 | 2047 | $values = array(); |
| 2048 | 2048 | foreach ($alldata as $cnt) { |
| 2049 | 2049 | $values[] = $cnt['date_count']; |
| 2050 | 2050 | } |
| 2051 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2052 | - array_splice($alldata,11); |
|
| 2051 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2052 | + array_splice($alldata, 11); |
|
| 2053 | 2053 | foreach ($alldata as $number) { |
| 2054 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
| 2054 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2055 | 2055 | } |
| 2056 | 2056 | |
| 2057 | 2057 | echo '-> countAllHours...'."\n"; |
| 2058 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
| 2058 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
| 2059 | 2059 | foreach ($alldata as $number) { |
| 2060 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
| 2060 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | echo 'Insert last stats update date...'."\n"; |
| 2063 | 2063 | date_default_timezone_set('UTC'); |
| 2064 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
| 2064 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
| 2065 | 2065 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
| 2066 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 2066 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 2067 | 2067 | $this->deleteOldStats($filter_name); |
| 2068 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
| 2068 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | |
@@ -2078,16 +2078,16 @@ discard block |
||
| 2078 | 2078 | // SUM all previous month to put as year |
| 2079 | 2079 | $previous_year = date('Y'); |
| 2080 | 2080 | $previous_year--; |
| 2081 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2082 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2083 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2084 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2081 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2082 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2083 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2084 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2085 | 2085 | $allairlines = $this->getAllAirlineNames(); |
| 2086 | 2086 | foreach ($allairlines as $data) { |
| 2087 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2088 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2089 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2090 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2087 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2088 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2089 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2090 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | 2093 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2096,7 +2096,7 @@ discard block |
||
| 2096 | 2096 | try { |
| 2097 | 2097 | $sth = $this->db->prepare($query); |
| 2098 | 2098 | $sth->execute(); |
| 2099 | - } catch(PDOException $e) { |
|
| 2099 | + } catch (PDOException $e) { |
|
| 2100 | 2100 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2101 | 2101 | } |
| 2102 | 2102 | } |
@@ -2105,15 +2105,15 @@ discard block |
||
| 2105 | 2105 | try { |
| 2106 | 2106 | $sth = $this->db->prepare($query); |
| 2107 | 2107 | $sth->execute(); |
| 2108 | - } catch(PDOException $e) { |
|
| 2108 | + } catch (PDOException $e) { |
|
| 2109 | 2109 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2110 | 2110 | } |
| 2111 | 2111 | } |
| 2112 | 2112 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
| 2113 | 2113 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 2114 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2114 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2115 | 2115 | $this->deleteOldStats(); |
| 2116 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
| 2116 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
| 2117 | 2117 | $lastyearupdate = true; |
| 2118 | 2118 | } |
| 2119 | 2119 | } |
@@ -2135,7 +2135,7 @@ discard block |
||
| 2135 | 2135 | try { |
| 2136 | 2136 | $sth = $this->db->prepare($query); |
| 2137 | 2137 | $sth->execute(); |
| 2138 | - } catch(PDOException $e) { |
|
| 2138 | + } catch (PDOException $e) { |
|
| 2139 | 2139 | return "error : ".$e->getMessage(); |
| 2140 | 2140 | } |
| 2141 | 2141 | } |
@@ -2149,14 +2149,14 @@ discard block |
||
| 2149 | 2149 | try { |
| 2150 | 2150 | $sth = $this->db->prepare($query); |
| 2151 | 2151 | $sth->execute(); |
| 2152 | - } catch(PDOException $e) { |
|
| 2152 | + } catch (PDOException $e) { |
|
| 2153 | 2153 | return "error : ".$e->getMessage(); |
| 2154 | 2154 | } |
| 2155 | 2155 | } |
| 2156 | 2156 | if (!isset($lastyearupdate)) { |
| 2157 | 2157 | echo 'Insert last stats update date...'."\n"; |
| 2158 | 2158 | date_default_timezone_set('UTC'); |
| 2159 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
| 2159 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
| 2160 | 2160 | } |
| 2161 | 2161 | if ($globalStatsResetYear) { |
| 2162 | 2162 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | global $globalFilterName; |
| 15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 15 | + if (isset($globalFilterName)) { |
|
| 16 | + $this->filter_name = $globalFilterName; |
|
| 17 | + } |
|
| 16 | 18 | $Connection = new Connection($dbc); |
| 17 | 19 | $this->db = $Connection->db(); |
| 18 | 20 | } |
@@ -77,7 +79,9 @@ discard block |
||
| 77 | 79 | } |
| 78 | 80 | } |
| 79 | 81 | public function getAllAirlineNames($filter_name = '') { |
| 80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 82 | + if ($filter_name == '') { |
|
| 83 | + $filter_name = $this->filter_name; |
|
| 84 | + } |
|
| 81 | 85 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 82 | 86 | try { |
| 83 | 87 | $sth = $this->db->prepare($query); |
@@ -89,7 +93,9 @@ discard block |
||
| 89 | 93 | return $all; |
| 90 | 94 | } |
| 91 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 92 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 96 | + if ($filter_name == '') { |
|
| 97 | + $filter_name = $this->filter_name; |
|
| 98 | + } |
|
| 93 | 99 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 94 | 100 | try { |
| 95 | 101 | $sth = $this->db->prepare($query); |
@@ -101,7 +107,9 @@ discard block |
||
| 101 | 107 | return $all; |
| 102 | 108 | } |
| 103 | 109 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 104 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 110 | + if ($filter_name == '') { |
|
| 111 | + $filter_name = $this->filter_name; |
|
| 112 | + } |
|
| 105 | 113 | $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"; |
| 106 | 114 | try { |
| 107 | 115 | $sth = $this->db->prepare($query); |
@@ -113,7 +121,9 @@ discard block |
||
| 113 | 121 | return $all; |
| 114 | 122 | } |
| 115 | 123 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 124 | + if ($filter_name == '') { |
|
| 125 | + $filter_name = $this->filter_name; |
|
| 126 | + } |
|
| 117 | 127 | $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"; |
| 118 | 128 | try { |
| 119 | 129 | $sth = $this->db->prepare($query); |
@@ -126,7 +136,9 @@ discard block |
||
| 126 | 136 | } |
| 127 | 137 | |
| 128 | 138 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 129 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 139 | + if ($filter_name == '') { |
|
| 140 | + $filter_name = $this->filter_name; |
|
| 141 | + } |
|
| 130 | 142 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 131 | 143 | try { |
| 132 | 144 | $sth = $this->db->prepare($query); |
@@ -139,7 +151,9 @@ discard block |
||
| 139 | 151 | } |
| 140 | 152 | |
| 141 | 153 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 142 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 154 | + if ($filter_name == '') { |
|
| 155 | + $filter_name = $this->filter_name; |
|
| 156 | + } |
|
| 143 | 157 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 144 | 158 | try { |
| 145 | 159 | $sth = $this->db->prepare($query); |
@@ -154,10 +168,15 @@ discard block |
||
| 154 | 168 | |
| 155 | 169 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 156 | 170 | global $globalStatsFilters; |
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 171 | + if ($filter_name == '') { |
|
| 172 | + $filter_name = $this->filter_name; |
|
| 173 | + } |
|
| 158 | 174 | if ($year == '' && $month == '') { |
| 159 | - 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"; |
|
| 160 | - 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"; |
|
| 175 | + if ($limit) { |
|
| 176 | + $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"; |
|
| 177 | + } else { |
|
| 178 | + $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"; |
|
| 179 | + } |
|
| 161 | 180 | try { |
| 162 | 181 | $sth = $this->db->prepare($query); |
| 163 | 182 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -165,7 +184,9 @@ discard block |
||
| 165 | 184 | echo "error : ".$e->getMessage(); |
| 166 | 185 | } |
| 167 | 186 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 168 | - } else $all = array(); |
|
| 187 | + } else { |
|
| 188 | + $all = array(); |
|
| 189 | + } |
|
| 169 | 190 | if (empty($all)) { |
| 170 | 191 | $filters = array('airlines' => array($stats_airline)); |
| 171 | 192 | if ($filter_name != '') { |
@@ -178,10 +199,15 @@ discard block |
||
| 178 | 199 | } |
| 179 | 200 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 180 | 201 | global $globalStatsFilters; |
| 181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 202 | + if ($filter_name == '') { |
|
| 203 | + $filter_name = $this->filter_name; |
|
| 204 | + } |
|
| 182 | 205 | if ($year == '' && $month == '') { |
| 183 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 184 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 206 | + if ($limit) { |
|
| 207 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 208 | + } else { |
|
| 209 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 210 | + } |
|
| 185 | 211 | try { |
| 186 | 212 | $sth = $this->db->prepare($query); |
| 187 | 213 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,7 +215,9 @@ discard block |
||
| 189 | 215 | echo "error : ".$e->getMessage(); |
| 190 | 216 | } |
| 191 | 217 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 192 | - } else $all = array(); |
|
| 218 | + } else { |
|
| 219 | + $all = array(); |
|
| 220 | + } |
|
| 193 | 221 | if (empty($all)) { |
| 194 | 222 | $Spotter = new Spotter($this->db); |
| 195 | 223 | $filters = array(); |
@@ -202,10 +230,15 @@ discard block |
||
| 202 | 230 | } |
| 203 | 231 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 204 | 232 | global $globalStatsFilters; |
| 205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 233 | + if ($filter_name == '') { |
|
| 234 | + $filter_name = $this->filter_name; |
|
| 235 | + } |
|
| 206 | 236 | if ($year == '' && $month == '') { |
| 207 | - 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"; |
|
| 208 | - 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"; |
|
| 237 | + if ($limit) { |
|
| 238 | + $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"; |
|
| 239 | + } else { |
|
| 240 | + $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"; |
|
| 241 | + } |
|
| 209 | 242 | try { |
| 210 | 243 | $sth = $this->db->prepare($query); |
| 211 | 244 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -213,7 +246,9 @@ discard block |
||
| 213 | 246 | echo "error : ".$e->getMessage(); |
| 214 | 247 | } |
| 215 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 216 | - } else $all = array(); |
|
| 249 | + } else { |
|
| 250 | + $all = array(); |
|
| 251 | + } |
|
| 217 | 252 | if (empty($all)) { |
| 218 | 253 | $filters = array('airlines' => array($stats_airline)); |
| 219 | 254 | if ($filter_name != '') { |
@@ -227,10 +262,15 @@ discard block |
||
| 227 | 262 | |
| 228 | 263 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 229 | 264 | global $globalStatsFilters; |
| 230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 265 | + if ($filter_name == '') { |
|
| 266 | + $filter_name = $this->filter_name; |
|
| 267 | + } |
|
| 231 | 268 | if ($year == '' && $month == '') { |
| 232 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 233 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 269 | + if ($limit) { |
|
| 270 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 271 | + } else { |
|
| 272 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 273 | + } |
|
| 234 | 274 | try { |
| 235 | 275 | $sth = $this->db->prepare($query); |
| 236 | 276 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -238,7 +278,9 @@ discard block |
||
| 238 | 278 | echo "error : ".$e->getMessage(); |
| 239 | 279 | } |
| 240 | 280 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 241 | - } else $all = array(); |
|
| 281 | + } else { |
|
| 282 | + $all = array(); |
|
| 283 | + } |
|
| 242 | 284 | if (empty($all)) { |
| 243 | 285 | $filters = array('airlines' => array($stats_airline)); |
| 244 | 286 | if ($filter_name != '') { |
@@ -251,9 +293,14 @@ discard block |
||
| 251 | 293 | } |
| 252 | 294 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 253 | 295 | global $globalStatsFilters; |
| 254 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 255 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 256 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 296 | + if ($filter_name == '') { |
|
| 297 | + $filter_name = $this->filter_name; |
|
| 298 | + } |
|
| 299 | + if ($limit) { |
|
| 300 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 301 | + } else { |
|
| 302 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 303 | + } |
|
| 257 | 304 | try { |
| 258 | 305 | $sth = $this->db->prepare($query); |
| 259 | 306 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,17 +321,29 @@ discard block |
||
| 274 | 321 | |
| 275 | 322 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 276 | 323 | global $globalStatsFilters; |
| 277 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 324 | + if ($filter_name == '') { |
|
| 325 | + $filter_name = $this->filter_name; |
|
| 326 | + } |
|
| 278 | 327 | if ($year == '' && $month == '') { |
| 279 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 280 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 328 | + if ($globalVATSIM) { |
|
| 329 | + $forsource = 'vatsim'; |
|
| 330 | + } |
|
| 331 | + if ($globalIVAO) { |
|
| 332 | + $forsource = 'ivao'; |
|
| 333 | + } |
|
| 281 | 334 | if (isset($forsource)) { |
| 282 | - 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"; |
|
| 283 | - 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"; |
|
| 335 | + if ($limit) { |
|
| 336 | + $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"; |
|
| 337 | + } else { |
|
| 338 | + $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"; |
|
| 339 | + } |
|
| 284 | 340 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 285 | 341 | } else { |
| 286 | - 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"; |
|
| 287 | - 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"; |
|
| 342 | + if ($limit) { |
|
| 343 | + $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"; |
|
| 344 | + } else { |
|
| 345 | + $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"; |
|
| 346 | + } |
|
| 288 | 347 | $query_values = array(':filter_name' => $filter_name); |
| 289 | 348 | } |
| 290 | 349 | try { |
@@ -294,7 +353,9 @@ discard block |
||
| 294 | 353 | echo "error : ".$e->getMessage(); |
| 295 | 354 | } |
| 296 | 355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 297 | - } else $all = array(); |
|
| 356 | + } else { |
|
| 357 | + $all = array(); |
|
| 358 | + } |
|
| 298 | 359 | if (empty($all)) { |
| 299 | 360 | $Spotter = new Spotter($this->db); |
| 300 | 361 | $filters = array(); |
@@ -307,10 +368,15 @@ discard block |
||
| 307 | 368 | } |
| 308 | 369 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 309 | 370 | global $globalStatsFilters; |
| 310 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 371 | + if ($filter_name == '') { |
|
| 372 | + $filter_name = $this->filter_name; |
|
| 373 | + } |
|
| 311 | 374 | if ($year == '' && $month == '') { |
| 312 | - 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"; |
|
| 313 | - 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"; |
|
| 375 | + if ($limit) { |
|
| 376 | + $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"; |
|
| 377 | + } else { |
|
| 378 | + $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"; |
|
| 379 | + } |
|
| 314 | 380 | try { |
| 315 | 381 | $sth = $this->db->prepare($query); |
| 316 | 382 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -318,7 +384,9 @@ discard block |
||
| 318 | 384 | echo "error : ".$e->getMessage(); |
| 319 | 385 | } |
| 320 | 386 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 321 | - } else $all = array(); |
|
| 387 | + } else { |
|
| 388 | + $all = array(); |
|
| 389 | + } |
|
| 322 | 390 | if (empty($all)) { |
| 323 | 391 | $filters = array('airlines' => array($stats_airline)); |
| 324 | 392 | if ($filter_name != '') { |
@@ -331,10 +399,15 @@ discard block |
||
| 331 | 399 | } |
| 332 | 400 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 333 | 401 | global $globalStatsFilters; |
| 334 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 402 | + if ($filter_name == '') { |
|
| 403 | + $filter_name = $this->filter_name; |
|
| 404 | + } |
|
| 335 | 405 | if ($year == '' && $month == '') { |
| 336 | - 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"; |
|
| 337 | - 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"; |
|
| 406 | + if ($limit) { |
|
| 407 | + $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"; |
|
| 408 | + } else { |
|
| 409 | + $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"; |
|
| 410 | + } |
|
| 338 | 411 | try { |
| 339 | 412 | $sth = $this->db->prepare($query); |
| 340 | 413 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -342,7 +415,9 @@ discard block |
||
| 342 | 415 | echo "error : ".$e->getMessage(); |
| 343 | 416 | } |
| 344 | 417 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 345 | - } else $all = array(); |
|
| 418 | + } else { |
|
| 419 | + $all = array(); |
|
| 420 | + } |
|
| 346 | 421 | if (empty($all)) { |
| 347 | 422 | $filters = array('airlines' => array($stats_airline)); |
| 348 | 423 | if ($filter_name != '') { |
@@ -355,11 +430,16 @@ discard block |
||
| 355 | 430 | } |
| 356 | 431 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 357 | 432 | $Connection = new Connection(); |
| 358 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 433 | + if ($filter_name == '') { |
|
| 434 | + $filter_name = $this->filter_name; |
|
| 435 | + } |
|
| 359 | 436 | if ($Connection->tableExists('countries')) { |
| 360 | 437 | if ($year == '' && $month == '') { |
| 361 | - 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"; |
|
| 362 | - 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"; |
|
| 438 | + if ($limit) { |
|
| 439 | + $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"; |
|
| 440 | + } else { |
|
| 441 | + $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"; |
|
| 442 | + } |
|
| 363 | 443 | try { |
| 364 | 444 | $sth = $this->db->prepare($query); |
| 365 | 445 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -374,17 +454,24 @@ discard block |
||
| 374 | 454 | } |
| 375 | 455 | */ |
| 376 | 456 | return $all; |
| 377 | - } else return array(); |
|
| 457 | + } else { |
|
| 458 | + return array(); |
|
| 459 | + } |
|
| 378 | 460 | } else { |
| 379 | 461 | return array(); |
| 380 | 462 | } |
| 381 | 463 | } |
| 382 | 464 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 383 | 465 | global $globalStatsFilters; |
| 384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 466 | + if ($filter_name == '') { |
|
| 467 | + $filter_name = $this->filter_name; |
|
| 468 | + } |
|
| 385 | 469 | if ($year == '' && $month == '') { |
| 386 | - 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"; |
|
| 387 | - 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"; |
|
| 470 | + if ($limit) { |
|
| 471 | + $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"; |
|
| 472 | + } else { |
|
| 473 | + $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"; |
|
| 474 | + } |
|
| 388 | 475 | try { |
| 389 | 476 | $sth = $this->db->prepare($query); |
| 390 | 477 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -392,7 +479,9 @@ discard block |
||
| 392 | 479 | echo "error : ".$e->getMessage(); |
| 393 | 480 | } |
| 394 | 481 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 395 | - } else $all = array(); |
|
| 482 | + } else { |
|
| 483 | + $all = array(); |
|
| 484 | + } |
|
| 396 | 485 | if (empty($all)) { |
| 397 | 486 | $filters = array('airlines' => array($stats_airline)); |
| 398 | 487 | if ($filter_name != '') { |
@@ -406,10 +495,15 @@ discard block |
||
| 406 | 495 | |
| 407 | 496 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 408 | 497 | global $globalStatsFilters; |
| 409 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 498 | + if ($filter_name == '') { |
|
| 499 | + $filter_name = $this->filter_name; |
|
| 500 | + } |
|
| 410 | 501 | if ($year == '' && $month == '') { |
| 411 | - 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"; |
|
| 412 | - 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"; |
|
| 502 | + if ($limit) { |
|
| 503 | + $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"; |
|
| 504 | + } else { |
|
| 505 | + $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"; |
|
| 506 | + } |
|
| 413 | 507 | try { |
| 414 | 508 | $sth = $this->db->prepare($query); |
| 415 | 509 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -417,7 +511,9 @@ discard block |
||
| 417 | 511 | echo "error : ".$e->getMessage(); |
| 418 | 512 | } |
| 419 | 513 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 420 | - } else $all = array(); |
|
| 514 | + } else { |
|
| 515 | + $all = array(); |
|
| 516 | + } |
|
| 421 | 517 | if (empty($all)) { |
| 422 | 518 | $filters = array('airlines' => array($stats_airline)); |
| 423 | 519 | if ($filter_name != '') { |
@@ -430,10 +526,15 @@ discard block |
||
| 430 | 526 | } |
| 431 | 527 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 432 | 528 | global $globalStatsFilters; |
| 433 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 529 | + if ($filter_name == '') { |
|
| 530 | + $filter_name = $this->filter_name; |
|
| 531 | + } |
|
| 434 | 532 | if ($year == '' && $month == '') { |
| 435 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 436 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 533 | + if ($limit) { |
|
| 534 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 535 | + } else { |
|
| 536 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 537 | + } |
|
| 437 | 538 | try { |
| 438 | 539 | $sth = $this->db->prepare($query); |
| 439 | 540 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -441,7 +542,9 @@ discard block |
||
| 441 | 542 | echo "error : ".$e->getMessage(); |
| 442 | 543 | } |
| 443 | 544 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 444 | - } else $all = array(); |
|
| 545 | + } else { |
|
| 546 | + $all = array(); |
|
| 547 | + } |
|
| 445 | 548 | if (empty($all)) { |
| 446 | 549 | $filters = array('airlines' => array($stats_airline)); |
| 447 | 550 | if ($filter_name != '') { |
@@ -460,7 +563,9 @@ discard block |
||
| 460 | 563 | $icao = $value['airport_departure_icao']; |
| 461 | 564 | if (isset($all[$icao])) { |
| 462 | 565 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 463 | - } else $all[$icao] = $value; |
|
| 566 | + } else { |
|
| 567 | + $all[$icao] = $value; |
|
| 568 | + } |
|
| 464 | 569 | } |
| 465 | 570 | $count = array(); |
| 466 | 571 | foreach ($all as $key => $row) { |
@@ -472,10 +577,15 @@ discard block |
||
| 472 | 577 | } |
| 473 | 578 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 474 | 579 | global $globalStatsFilters; |
| 475 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 580 | + if ($filter_name == '') { |
|
| 581 | + $filter_name = $this->filter_name; |
|
| 582 | + } |
|
| 476 | 583 | if ($year == '' && $month == '') { |
| 477 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 478 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 584 | + if ($limit) { |
|
| 585 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 586 | + } else { |
|
| 587 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 588 | + } |
|
| 479 | 589 | try { |
| 480 | 590 | $sth = $this->db->prepare($query); |
| 481 | 591 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -483,7 +593,9 @@ discard block |
||
| 483 | 593 | echo "error : ".$e->getMessage(); |
| 484 | 594 | } |
| 485 | 595 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 486 | - } else $all = array(); |
|
| 596 | + } else { |
|
| 597 | + $all = array(); |
|
| 598 | + } |
|
| 487 | 599 | if (empty($all)) { |
| 488 | 600 | $filters = array('airlines' => array($stats_airline)); |
| 489 | 601 | if ($filter_name != '') { |
@@ -502,7 +614,9 @@ discard block |
||
| 502 | 614 | $icao = $value['airport_arrival_icao']; |
| 503 | 615 | if (isset($all[$icao])) { |
| 504 | 616 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 505 | - } else $all[$icao] = $value; |
|
| 617 | + } else { |
|
| 618 | + $all[$icao] = $value; |
|
| 619 | + } |
|
| 506 | 620 | } |
| 507 | 621 | $count = array(); |
| 508 | 622 | foreach ($all as $key => $row) { |
@@ -515,13 +629,21 @@ discard block |
||
| 515 | 629 | } |
| 516 | 630 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 517 | 631 | global $globalDBdriver, $globalStatsFilters; |
| 518 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 632 | + if ($filter_name == '') { |
|
| 633 | + $filter_name = $this->filter_name; |
|
| 634 | + } |
|
| 519 | 635 | if ($globalDBdriver == 'mysql') { |
| 520 | - 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"; |
|
| 521 | - 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"; |
|
| 636 | + if ($limit) { |
|
| 637 | + $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"; |
|
| 638 | + } else { |
|
| 639 | + $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"; |
|
| 640 | + } |
|
| 522 | 641 | } else { |
| 523 | - 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"; |
|
| 524 | - 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"; |
|
| 642 | + if ($limit) { |
|
| 643 | + $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"; |
|
| 644 | + } else { |
|
| 645 | + $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"; |
|
| 646 | + } |
|
| 525 | 647 | } |
| 526 | 648 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 527 | 649 | try { |
@@ -545,7 +667,9 @@ discard block |
||
| 545 | 667 | |
| 546 | 668 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 547 | 669 | global $globalStatsFilters; |
| 548 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 670 | + if ($filter_name == '') { |
|
| 671 | + $filter_name = $this->filter_name; |
|
| 672 | + } |
|
| 549 | 673 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 550 | 674 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 551 | 675 | try { |
@@ -567,7 +691,9 @@ discard block |
||
| 567 | 691 | } |
| 568 | 692 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 569 | 693 | global $globalDBdriver, $globalStatsFilters; |
| 570 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 694 | + if ($filter_name == '') { |
|
| 695 | + $filter_name = $this->filter_name; |
|
| 696 | + } |
|
| 571 | 697 | if ($globalDBdriver == 'mysql') { |
| 572 | 698 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 573 | 699 | } else { |
@@ -593,7 +719,9 @@ discard block |
||
| 593 | 719 | } |
| 594 | 720 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 595 | 721 | global $globalStatsFilters; |
| 596 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 722 | + if ($filter_name == '') { |
|
| 723 | + $filter_name = $this->filter_name; |
|
| 724 | + } |
|
| 597 | 725 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 598 | 726 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 599 | 727 | try { |
@@ -615,7 +743,9 @@ discard block |
||
| 615 | 743 | } |
| 616 | 744 | public function countAllDatesByAirlines($filter_name = '') { |
| 617 | 745 | global $globalStatsFilters; |
| 618 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 746 | + if ($filter_name == '') { |
|
| 747 | + $filter_name = $this->filter_name; |
|
| 748 | + } |
|
| 619 | 749 | $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"; |
| 620 | 750 | $query_data = array('filter_name' => $filter_name); |
| 621 | 751 | try { |
@@ -637,7 +767,9 @@ discard block |
||
| 637 | 767 | } |
| 638 | 768 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 639 | 769 | global $globalStatsFilters; |
| 640 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 770 | + if ($filter_name == '') { |
|
| 771 | + $filter_name = $this->filter_name; |
|
| 772 | + } |
|
| 641 | 773 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 642 | 774 | try { |
| 643 | 775 | $sth = $this->db->prepare($query); |
@@ -660,7 +792,9 @@ discard block |
||
| 660 | 792 | } |
| 661 | 793 | public function countAllMilitaryMonths($filter_name = '') { |
| 662 | 794 | global $globalStatsFilters; |
| 663 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 795 | + if ($filter_name == '') { |
|
| 796 | + $filter_name = $this->filter_name; |
|
| 797 | + } |
|
| 664 | 798 | $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"; |
| 665 | 799 | try { |
| 666 | 800 | $sth = $this->db->prepare($query); |
@@ -681,9 +815,14 @@ discard block |
||
| 681 | 815 | } |
| 682 | 816 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 683 | 817 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 684 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 685 | - 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"; |
|
| 686 | - 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"; |
|
| 818 | + if ($filter_name == '') { |
|
| 819 | + $filter_name = $this->filter_name; |
|
| 820 | + } |
|
| 821 | + if ($limit) { |
|
| 822 | + $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"; |
|
| 823 | + } else { |
|
| 824 | + $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"; |
|
| 825 | + } |
|
| 687 | 826 | if ($orderby == 'hour') { |
| 688 | 827 | /* |
| 689 | 828 | if ($globalDBdriver == 'mysql') { |
@@ -692,7 +831,9 @@ discard block |
||
| 692 | 831 | */ |
| 693 | 832 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 694 | 833 | } |
| 695 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 834 | + if ($orderby == 'count') { |
|
| 835 | + $query .= " ORDER BY hour_count DESC"; |
|
| 836 | + } |
|
| 696 | 837 | try { |
| 697 | 838 | $sth = $this->db->prepare($query); |
| 698 | 839 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -713,8 +854,12 @@ discard block |
||
| 713 | 854 | |
| 714 | 855 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 715 | 856 | global $globalStatsFilters; |
| 716 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 717 | - if ($year == '') $year = date('Y'); |
|
| 857 | + if ($filter_name == '') { |
|
| 858 | + $filter_name = $this->filter_name; |
|
| 859 | + } |
|
| 860 | + if ($year == '') { |
|
| 861 | + $year = date('Y'); |
|
| 862 | + } |
|
| 718 | 863 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 719 | 864 | if (empty($all)) { |
| 720 | 865 | $filters = array('airlines' => array($stats_airline)); |
@@ -728,8 +873,12 @@ discard block |
||
| 728 | 873 | } |
| 729 | 874 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 730 | 875 | global $globalStatsFilters; |
| 731 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 732 | - if ($year == '') $year = date('Y'); |
|
| 876 | + if ($filter_name == '') { |
|
| 877 | + $filter_name = $this->filter_name; |
|
| 878 | + } |
|
| 879 | + if ($year == '') { |
|
| 880 | + $year = date('Y'); |
|
| 881 | + } |
|
| 733 | 882 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 734 | 883 | if (empty($all)) { |
| 735 | 884 | $filters = array(); |
@@ -743,8 +892,12 @@ discard block |
||
| 743 | 892 | } |
| 744 | 893 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 745 | 894 | global $globalStatsFilters; |
| 746 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 747 | - if ($year == '') $year = date('Y'); |
|
| 895 | + if ($filter_name == '') { |
|
| 896 | + $filter_name = $this->filter_name; |
|
| 897 | + } |
|
| 898 | + if ($year == '') { |
|
| 899 | + $year = date('Y'); |
|
| 900 | + } |
|
| 748 | 901 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 749 | 902 | if (empty($all)) { |
| 750 | 903 | $filters = array('airlines' => array($stats_airline)); |
@@ -758,7 +911,9 @@ discard block |
||
| 758 | 911 | } |
| 759 | 912 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 760 | 913 | global $globalStatsFilters; |
| 761 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 914 | + if ($filter_name == '') { |
|
| 915 | + $filter_name = $this->filter_name; |
|
| 916 | + } |
|
| 762 | 917 | if ($year == '' && $month == '') { |
| 763 | 918 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 764 | 919 | try { |
@@ -769,7 +924,9 @@ discard block |
||
| 769 | 924 | } |
| 770 | 925 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 771 | 926 | $all = $result[0]['nb']; |
| 772 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 927 | + } else { |
|
| 928 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 929 | + } |
|
| 773 | 930 | if (empty($all)) { |
| 774 | 931 | $filters = array('airlines' => array($stats_airline)); |
| 775 | 932 | if ($filter_name != '') { |
@@ -782,7 +939,9 @@ discard block |
||
| 782 | 939 | } |
| 783 | 940 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 784 | 941 | global $globalStatsFilters; |
| 785 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 942 | + if ($filter_name == '') { |
|
| 943 | + $filter_name = $this->filter_name; |
|
| 944 | + } |
|
| 786 | 945 | if ($year == '' && $month == '') { |
| 787 | 946 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 788 | 947 | try { |
@@ -793,7 +952,9 @@ discard block |
||
| 793 | 952 | } |
| 794 | 953 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 795 | 954 | $all = $result[0]['nb_airline']; |
| 796 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 955 | + } else { |
|
| 956 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 957 | + } |
|
| 797 | 958 | if (empty($all)) { |
| 798 | 959 | $filters = array(); |
| 799 | 960 | if ($filter_name != '') { |
@@ -806,7 +967,9 @@ discard block |
||
| 806 | 967 | } |
| 807 | 968 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 808 | 969 | global $globalStatsFilters; |
| 809 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 970 | + if ($filter_name == '') { |
|
| 971 | + $filter_name = $this->filter_name; |
|
| 972 | + } |
|
| 810 | 973 | if ($year == '' && $month == '') { |
| 811 | 974 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 812 | 975 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -833,7 +996,9 @@ discard block |
||
| 833 | 996 | } |
| 834 | 997 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 835 | 998 | global $globalStatsFilters; |
| 836 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 999 | + if ($filter_name == '') { |
|
| 1000 | + $filter_name = $this->filter_name; |
|
| 1001 | + } |
|
| 837 | 1002 | //if ($year == '') $year = date('Y'); |
| 838 | 1003 | if ($year == '' && $month == '') { |
| 839 | 1004 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -861,7 +1026,9 @@ discard block |
||
| 861 | 1026 | } |
| 862 | 1027 | |
| 863 | 1028 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 864 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1029 | + if ($filter_name == '') { |
|
| 1030 | + $filter_name = $this->filter_name; |
|
| 1031 | + } |
|
| 865 | 1032 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 866 | 1033 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 867 | 1034 | try { |
@@ -874,7 +1041,9 @@ discard block |
||
| 874 | 1041 | return $all; |
| 875 | 1042 | } |
| 876 | 1043 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 877 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1044 | + if ($filter_name == '') { |
|
| 1045 | + $filter_name = $this->filter_name; |
|
| 1046 | + } |
|
| 878 | 1047 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 879 | 1048 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 880 | 1049 | try { |
@@ -887,7 +1056,9 @@ discard block |
||
| 887 | 1056 | return $all; |
| 888 | 1057 | } |
| 889 | 1058 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 890 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1059 | + if ($filter_name == '') { |
|
| 1060 | + $filter_name = $this->filter_name; |
|
| 1061 | + } |
|
| 891 | 1062 | global $globalArchiveMonths, $globalDBdriver; |
| 892 | 1063 | if ($globalDBdriver == 'mysql') { |
| 893 | 1064 | if ($month == '') { |
@@ -917,7 +1088,9 @@ discard block |
||
| 917 | 1088 | } |
| 918 | 1089 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 919 | 1090 | global $globalArchiveMonths, $globalDBdriver; |
| 920 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1091 | + if ($filter_name == '') { |
|
| 1092 | + $filter_name = $this->filter_name; |
|
| 1093 | + } |
|
| 921 | 1094 | if ($globalDBdriver == 'mysql') { |
| 922 | 1095 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 923 | 1096 | } else { |
@@ -935,7 +1108,9 @@ discard block |
||
| 935 | 1108 | } |
| 936 | 1109 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 937 | 1110 | global $globalArchiveMonths, $globalDBdriver; |
| 938 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1111 | + if ($filter_name == '') { |
|
| 1112 | + $filter_name = $this->filter_name; |
|
| 1113 | + } |
|
| 939 | 1114 | if ($globalDBdriver == 'mysql') { |
| 940 | 1115 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 941 | 1116 | } else { |
@@ -952,7 +1127,9 @@ discard block |
||
| 952 | 1127 | } |
| 953 | 1128 | public function getStatsAirlineTotal($filter_name = '') { |
| 954 | 1129 | global $globalArchiveMonths, $globalDBdriver; |
| 955 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1130 | + if ($filter_name == '') { |
|
| 1131 | + $filter_name = $this->filter_name; |
|
| 1132 | + } |
|
| 956 | 1133 | if ($globalDBdriver == 'mysql') { |
| 957 | 1134 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 958 | 1135 | } else { |
@@ -969,7 +1146,9 @@ discard block |
||
| 969 | 1146 | } |
| 970 | 1147 | public function getStatsOwnerTotal($filter_name = '') { |
| 971 | 1148 | global $globalArchiveMonths, $globalDBdriver; |
| 972 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1149 | + if ($filter_name == '') { |
|
| 1150 | + $filter_name = $this->filter_name; |
|
| 1151 | + } |
|
| 973 | 1152 | if ($globalDBdriver == 'mysql') { |
| 974 | 1153 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 975 | 1154 | } else { |
@@ -986,7 +1165,9 @@ discard block |
||
| 986 | 1165 | } |
| 987 | 1166 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 988 | 1167 | global $globalArchiveMonths, $globalDBdriver; |
| 989 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1168 | + if ($filter_name == '') { |
|
| 1169 | + $filter_name = $this->filter_name; |
|
| 1170 | + } |
|
| 990 | 1171 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 991 | 1172 | try { |
| 992 | 1173 | $sth = $this->db->prepare($query); |
@@ -995,12 +1176,17 @@ discard block |
||
| 995 | 1176 | echo "error : ".$e->getMessage(); |
| 996 | 1177 | } |
| 997 | 1178 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 998 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 999 | - else return 0; |
|
| 1179 | + if (isset($all[0]['cnt'])) { |
|
| 1180 | + return $all[0]['cnt']; |
|
| 1181 | + } else { |
|
| 1182 | + return 0; |
|
| 1183 | + } |
|
| 1000 | 1184 | } |
| 1001 | 1185 | public function getStatsPilotTotal($filter_name = '') { |
| 1002 | 1186 | global $globalArchiveMonths, $globalDBdriver; |
| 1003 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1187 | + if ($filter_name == '') { |
|
| 1188 | + $filter_name = $this->filter_name; |
|
| 1189 | + } |
|
| 1004 | 1190 | if ($globalDBdriver == 'mysql') { |
| 1005 | 1191 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1006 | 1192 | } else { |
@@ -1017,7 +1203,9 @@ discard block |
||
| 1017 | 1203 | } |
| 1018 | 1204 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1019 | 1205 | global $globalArchiveMonths, $globalDBdriver; |
| 1020 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1206 | + if ($filter_name == '') { |
|
| 1207 | + $filter_name = $this->filter_name; |
|
| 1208 | + } |
|
| 1021 | 1209 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1022 | 1210 | try { |
| 1023 | 1211 | $sth = $this->db->prepare($query); |
@@ -1026,13 +1214,18 @@ discard block |
||
| 1026 | 1214 | echo "error : ".$e->getMessage(); |
| 1027 | 1215 | } |
| 1028 | 1216 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1029 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1030 | - else return 0; |
|
| 1217 | + if (isset($all[0]['cnt'])) { |
|
| 1218 | + return $all[0]['cnt']; |
|
| 1219 | + } else { |
|
| 1220 | + return 0; |
|
| 1221 | + } |
|
| 1031 | 1222 | } |
| 1032 | 1223 | |
| 1033 | 1224 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1034 | 1225 | global $globalDBdriver; |
| 1035 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1226 | + if ($filter_name == '') { |
|
| 1227 | + $filter_name = $this->filter_name; |
|
| 1228 | + } |
|
| 1036 | 1229 | if ($globalDBdriver == 'mysql') { |
| 1037 | 1230 | $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"; |
| 1038 | 1231 | } else { |
@@ -1048,7 +1241,9 @@ discard block |
||
| 1048 | 1241 | } |
| 1049 | 1242 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1050 | 1243 | global $globalDBdriver; |
| 1051 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1244 | + if ($filter_name == '') { |
|
| 1245 | + $filter_name = $this->filter_name; |
|
| 1246 | + } |
|
| 1052 | 1247 | if ($globalDBdriver == 'mysql') { |
| 1053 | 1248 | $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"; |
| 1054 | 1249 | } else { |
@@ -1434,10 +1629,14 @@ discard block |
||
| 1434 | 1629 | $Connection = new Connection(); |
| 1435 | 1630 | date_default_timezone_set('UTC'); |
| 1436 | 1631 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1437 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 1632 | + if ($globalDebug) { |
|
| 1633 | + echo 'Update stats !'."\n"; |
|
| 1634 | + } |
|
| 1438 | 1635 | if (isset($last_update[0]['value'])) { |
| 1439 | 1636 | $last_update_day = $last_update[0]['value']; |
| 1440 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 1637 | + } else { |
|
| 1638 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 1639 | + } |
|
| 1441 | 1640 | $reset = false; |
| 1442 | 1641 | if ($globalStatsResetYear) { |
| 1443 | 1642 | $reset = true; |
@@ -1445,42 +1644,60 @@ discard block |
||
| 1445 | 1644 | } |
| 1446 | 1645 | $Spotter = new Spotter($this->db); |
| 1447 | 1646 | |
| 1448 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 1647 | + if ($globalDebug) { |
|
| 1648 | + echo 'Count all aircraft types...'."\n"; |
|
| 1649 | + } |
|
| 1449 | 1650 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 1450 | 1651 | foreach ($alldata as $number) { |
| 1451 | 1652 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 1452 | 1653 | } |
| 1453 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 1654 | + if ($globalDebug) { |
|
| 1655 | + echo 'Count all airlines...'."\n"; |
|
| 1656 | + } |
|
| 1454 | 1657 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 1455 | 1658 | foreach ($alldata as $number) { |
| 1456 | 1659 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 1457 | 1660 | } |
| 1458 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 1661 | + if ($globalDebug) { |
|
| 1662 | + echo 'Count all registrations...'."\n"; |
|
| 1663 | + } |
|
| 1459 | 1664 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 1460 | 1665 | foreach ($alldata as $number) { |
| 1461 | 1666 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 1462 | 1667 | } |
| 1463 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 1668 | + if ($globalDebug) { |
|
| 1669 | + echo 'Count all callsigns...'."\n"; |
|
| 1670 | + } |
|
| 1464 | 1671 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 1465 | 1672 | foreach ($alldata as $number) { |
| 1466 | 1673 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1467 | 1674 | } |
| 1468 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 1675 | + if ($globalDebug) { |
|
| 1676 | + echo 'Count all owners...'."\n"; |
|
| 1677 | + } |
|
| 1469 | 1678 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 1470 | 1679 | foreach ($alldata as $number) { |
| 1471 | 1680 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 1472 | 1681 | } |
| 1473 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 1682 | + if ($globalDebug) { |
|
| 1683 | + echo 'Count all pilots...'."\n"; |
|
| 1684 | + } |
|
| 1474 | 1685 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 1475 | 1686 | foreach ($alldata as $number) { |
| 1476 | 1687 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 1477 | 1688 | } |
| 1478 | 1689 | |
| 1479 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 1690 | + if ($globalDebug) { |
|
| 1691 | + echo 'Count all departure airports...'."\n"; |
|
| 1692 | + } |
|
| 1480 | 1693 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 1481 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 1694 | + if ($globalDebug) { |
|
| 1695 | + echo 'Count all detected departure airports...'."\n"; |
|
| 1696 | + } |
|
| 1482 | 1697 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 1483 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 1698 | + if ($globalDebug) { |
|
| 1699 | + echo 'Order departure airports...'."\n"; |
|
| 1700 | + } |
|
| 1484 | 1701 | $alldata = array(); |
| 1485 | 1702 | |
| 1486 | 1703 | foreach ($pall as $value) { |
@@ -1491,7 +1708,9 @@ discard block |
||
| 1491 | 1708 | $icao = $value['airport_departure_icao']; |
| 1492 | 1709 | if (isset($alldata[$icao])) { |
| 1493 | 1710 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1494 | - } else $alldata[$icao] = $value; |
|
| 1711 | + } else { |
|
| 1712 | + $alldata[$icao] = $value; |
|
| 1713 | + } |
|
| 1495 | 1714 | } |
| 1496 | 1715 | $count = array(); |
| 1497 | 1716 | foreach ($alldata as $key => $row) { |
@@ -1501,11 +1720,17 @@ discard block |
||
| 1501 | 1720 | foreach ($alldata as $number) { |
| 1502 | 1721 | 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); |
| 1503 | 1722 | } |
| 1504 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 1723 | + if ($globalDebug) { |
|
| 1724 | + echo 'Count all arrival airports...'."\n"; |
|
| 1725 | + } |
|
| 1505 | 1726 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 1506 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 1727 | + if ($globalDebug) { |
|
| 1728 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 1729 | + } |
|
| 1507 | 1730 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 1508 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 1731 | + if ($globalDebug) { |
|
| 1732 | + echo 'Order arrival airports...'."\n"; |
|
| 1733 | + } |
|
| 1509 | 1734 | $alldata = array(); |
| 1510 | 1735 | foreach ($pall as $value) { |
| 1511 | 1736 | $icao = $value['airport_arrival_icao']; |
@@ -1515,7 +1740,9 @@ discard block |
||
| 1515 | 1740 | $icao = $value['airport_arrival_icao']; |
| 1516 | 1741 | if (isset($alldata[$icao])) { |
| 1517 | 1742 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1518 | - } else $alldata[$icao] = $value; |
|
| 1743 | + } else { |
|
| 1744 | + $alldata[$icao] = $value; |
|
| 1745 | + } |
|
| 1519 | 1746 | } |
| 1520 | 1747 | $count = array(); |
| 1521 | 1748 | foreach ($alldata as $key => $row) { |
@@ -1526,7 +1753,9 @@ discard block |
||
| 1526 | 1753 | 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); |
| 1527 | 1754 | } |
| 1528 | 1755 | if ($Connection->tableExists('countries')) { |
| 1529 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 1756 | + if ($globalDebug) { |
|
| 1757 | + echo 'Count all flights by countries...'."\n"; |
|
| 1758 | + } |
|
| 1530 | 1759 | $SpotterArchive = new SpotterArchive(); |
| 1531 | 1760 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 1532 | 1761 | foreach ($alldata as $number) { |
@@ -1538,46 +1767,66 @@ discard block |
||
| 1538 | 1767 | // Add by month using getstat if month finish... |
| 1539 | 1768 | |
| 1540 | 1769 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 1541 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 1770 | + if ($globalDebug) { |
|
| 1771 | + echo 'Count all flights by months...'."\n"; |
|
| 1772 | + } |
|
| 1542 | 1773 | $Spotter = new Spotter($this->db); |
| 1543 | 1774 | $alldata = $Spotter->countAllMonths(); |
| 1544 | 1775 | $lastyear = false; |
| 1545 | 1776 | foreach ($alldata as $number) { |
| 1546 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1777 | + if ($number['year_name'] != date('Y')) { |
|
| 1778 | + $lastyear = true; |
|
| 1779 | + } |
|
| 1547 | 1780 | $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']))); |
| 1548 | 1781 | } |
| 1549 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 1782 | + if ($globalDebug) { |
|
| 1783 | + echo 'Count all military flights by months...'."\n"; |
|
| 1784 | + } |
|
| 1550 | 1785 | $alldata = $Spotter->countAllMilitaryMonths(); |
| 1551 | 1786 | foreach ($alldata as $number) { |
| 1552 | 1787 | $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']))); |
| 1553 | 1788 | } |
| 1554 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 1789 | + if ($globalDebug) { |
|
| 1790 | + echo 'Count all owners by months...'."\n"; |
|
| 1791 | + } |
|
| 1555 | 1792 | $alldata = $Spotter->countAllMonthsOwners(); |
| 1556 | 1793 | foreach ($alldata as $number) { |
| 1557 | 1794 | $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']))); |
| 1558 | 1795 | } |
| 1559 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 1796 | + if ($globalDebug) { |
|
| 1797 | + echo 'Count all pilots by months...'."\n"; |
|
| 1798 | + } |
|
| 1560 | 1799 | $alldata = $Spotter->countAllMonthsPilots(); |
| 1561 | 1800 | foreach ($alldata as $number) { |
| 1562 | 1801 | $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']))); |
| 1563 | 1802 | } |
| 1564 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 1803 | + if ($globalDebug) { |
|
| 1804 | + echo 'Count all airlines by months...'."\n"; |
|
| 1805 | + } |
|
| 1565 | 1806 | $alldata = $Spotter->countAllMonthsAirlines(); |
| 1566 | 1807 | foreach ($alldata as $number) { |
| 1567 | 1808 | $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']))); |
| 1568 | 1809 | } |
| 1569 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 1810 | + if ($globalDebug) { |
|
| 1811 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 1812 | + } |
|
| 1570 | 1813 | $alldata = $Spotter->countAllMonthsAircrafts(); |
| 1571 | 1814 | foreach ($alldata as $number) { |
| 1572 | 1815 | $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']))); |
| 1573 | 1816 | } |
| 1574 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 1817 | + if ($globalDebug) { |
|
| 1818 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 1819 | + } |
|
| 1575 | 1820 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
| 1576 | 1821 | foreach ($alldata as $number) { |
| 1577 | 1822 | $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']))); |
| 1578 | 1823 | } |
| 1579 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 1580 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 1824 | + if ($globalDebug) { |
|
| 1825 | + echo 'Airports data...'."\n"; |
|
| 1826 | + } |
|
| 1827 | + if ($globalDebug) { |
|
| 1828 | + echo '...Departure'."\n"; |
|
| 1829 | + } |
|
| 1581 | 1830 | $this->deleteStatAirport('daily'); |
| 1582 | 1831 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1583 | 1832 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1698,44 +1947,62 @@ discard block |
||
| 1698 | 1947 | // Count by airlines |
| 1699 | 1948 | echo '--- Stats by airlines ---'."\n"; |
| 1700 | 1949 | if ($Connection->tableExists('countries')) { |
| 1701 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1950 | + if ($globalDebug) { |
|
| 1951 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1952 | + } |
|
| 1702 | 1953 | $SpotterArchive = new SpotterArchive(); |
| 1703 | 1954 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 1704 | 1955 | foreach ($alldata as $number) { |
| 1705 | 1956 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 1706 | 1957 | } |
| 1707 | 1958 | } |
| 1708 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1959 | + if ($globalDebug) { |
|
| 1960 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1961 | + } |
|
| 1709 | 1962 | $Spotter = new Spotter($this->db); |
| 1710 | 1963 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 1711 | 1964 | foreach ($alldata as $number) { |
| 1712 | 1965 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 1713 | 1966 | } |
| 1714 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1967 | + if ($globalDebug) { |
|
| 1968 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1969 | + } |
|
| 1715 | 1970 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 1716 | 1971 | foreach ($alldata as $number) { |
| 1717 | 1972 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 1718 | 1973 | } |
| 1719 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 1974 | + if ($globalDebug) { |
|
| 1975 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 1976 | + } |
|
| 1720 | 1977 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 1721 | 1978 | foreach ($alldata as $number) { |
| 1722 | 1979 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1723 | 1980 | } |
| 1724 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 1981 | + if ($globalDebug) { |
|
| 1982 | + echo 'Count all owners by airlines...'."\n"; |
|
| 1983 | + } |
|
| 1725 | 1984 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 1726 | 1985 | foreach ($alldata as $number) { |
| 1727 | 1986 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 1728 | 1987 | } |
| 1729 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 1988 | + if ($globalDebug) { |
|
| 1989 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 1990 | + } |
|
| 1730 | 1991 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 1731 | 1992 | foreach ($alldata as $number) { |
| 1732 | 1993 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 1733 | 1994 | } |
| 1734 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 1995 | + if ($globalDebug) { |
|
| 1996 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 1997 | + } |
|
| 1735 | 1998 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1736 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 1999 | + if ($globalDebug) { |
|
| 2000 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2001 | + } |
|
| 1737 | 2002 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1738 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2003 | + if ($globalDebug) { |
|
| 2004 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2005 | + } |
|
| 1739 | 2006 | //$alldata = array(); |
| 1740 | 2007 | foreach ($dall as $value) { |
| 1741 | 2008 | $icao = $value['airport_departure_icao']; |
@@ -1756,11 +2023,17 @@ discard block |
||
| 1756 | 2023 | foreach ($alldata as $number) { |
| 1757 | 2024 | 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); |
| 1758 | 2025 | } |
| 1759 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2026 | + if ($globalDebug) { |
|
| 2027 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2028 | + } |
|
| 1760 | 2029 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1761 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2030 | + if ($globalDebug) { |
|
| 2031 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2032 | + } |
|
| 1762 | 2033 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1763 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 2034 | + if ($globalDebug) { |
|
| 2035 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 2036 | + } |
|
| 1764 | 2037 | //$alldata = array(); |
| 1765 | 2038 | foreach ($dall as $value) { |
| 1766 | 2039 | $icao = $value['airport_arrival_icao']; |
@@ -1779,37 +2052,53 @@ discard block |
||
| 1779 | 2052 | } |
| 1780 | 2053 | $alldata = $pall; |
| 1781 | 2054 | foreach ($alldata as $number) { |
| 1782 | - 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); |
|
| 2055 | + if ($number['airline_icao'] != '') { |
|
| 2056 | + 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); |
|
| 2057 | + } |
|
| 2058 | + } |
|
| 2059 | + if ($globalDebug) { |
|
| 2060 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 1783 | 2061 | } |
| 1784 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 1785 | 2062 | $Spotter = new Spotter($this->db); |
| 1786 | 2063 | $alldata = $Spotter->countAllMonthsByAirlines(); |
| 1787 | 2064 | $lastyear = false; |
| 1788 | 2065 | foreach ($alldata as $number) { |
| 1789 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2066 | + if ($number['year_name'] != date('Y')) { |
|
| 2067 | + $lastyear = true; |
|
| 2068 | + } |
|
| 1790 | 2069 | $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']); |
| 1791 | 2070 | } |
| 1792 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 2071 | + if ($globalDebug) { |
|
| 2072 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2073 | + } |
|
| 1793 | 2074 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
| 1794 | 2075 | foreach ($alldata as $number) { |
| 1795 | 2076 | $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']); |
| 1796 | 2077 | } |
| 1797 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2078 | + if ($globalDebug) { |
|
| 2079 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2080 | + } |
|
| 1798 | 2081 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
| 1799 | 2082 | foreach ($alldata as $number) { |
| 1800 | 2083 | $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']); |
| 1801 | 2084 | } |
| 1802 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2085 | + if ($globalDebug) { |
|
| 2086 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2087 | + } |
|
| 1803 | 2088 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
| 1804 | 2089 | foreach ($alldata as $number) { |
| 1805 | 2090 | $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']); |
| 1806 | 2091 | } |
| 1807 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2092 | + if ($globalDebug) { |
|
| 2093 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2094 | + } |
|
| 1808 | 2095 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
| 1809 | 2096 | foreach ($alldata as $number) { |
| 1810 | 2097 | $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']); |
| 1811 | 2098 | } |
| 1812 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2099 | + if ($globalDebug) { |
|
| 2100 | + echo '...Departure'."\n"; |
|
| 2101 | + } |
|
| 1813 | 2102 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 1814 | 2103 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 1815 | 2104 | foreach ($dall as $value) { |
@@ -1832,7 +2121,9 @@ discard block |
||
| 1832 | 2121 | foreach ($alldata as $number) { |
| 1833 | 2122 | $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']); |
| 1834 | 2123 | } |
| 1835 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2124 | + if ($globalDebug) { |
|
| 2125 | + echo '...Arrival'."\n"; |
|
| 2126 | + } |
|
| 1836 | 2127 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 1837 | 2128 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 1838 | 2129 | foreach ($dall as $value) { |
@@ -1856,13 +2147,19 @@ discard block |
||
| 1856 | 2147 | $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']); |
| 1857 | 2148 | } |
| 1858 | 2149 | |
| 1859 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 1860 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2150 | + if ($globalDebug) { |
|
| 2151 | + echo 'Flights data...'."\n"; |
|
| 2152 | + } |
|
| 2153 | + if ($globalDebug) { |
|
| 2154 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2155 | + } |
|
| 1861 | 2156 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
| 1862 | 2157 | foreach ($alldata as $number) { |
| 1863 | 2158 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 1864 | 2159 | } |
| 1865 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2160 | + if ($globalDebug) { |
|
| 2161 | + echo '-> countAllDates...'."\n"; |
|
| 2162 | + } |
|
| 1866 | 2163 | //$previousdata = $this->countAllDatesByAirlines(); |
| 1867 | 2164 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
| 1868 | 2165 | $values = array(); |
@@ -1875,7 +2172,9 @@ discard block |
||
| 1875 | 2172 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 1876 | 2173 | } |
| 1877 | 2174 | |
| 1878 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2175 | + if ($globalDebug) { |
|
| 2176 | + echo '-> countAllHours...'."\n"; |
|
| 2177 | + } |
|
| 1879 | 2178 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
| 1880 | 2179 | foreach ($alldata as $number) { |
| 1881 | 2180 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1883,7 +2182,9 @@ discard block |
||
| 1883 | 2182 | |
| 1884 | 2183 | |
| 1885 | 2184 | // Stats by filters |
| 1886 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2185 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2186 | + $globalStatsFilters = array(); |
|
| 2187 | + } |
|
| 1887 | 2188 | foreach ($globalStatsFilters as $name => $filter) { |
| 1888 | 2189 | //$filter_name = $filter['name']; |
| 1889 | 2190 | $filter_name = $name; |
@@ -1891,11 +2192,15 @@ discard block |
||
| 1891 | 2192 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 1892 | 2193 | if (isset($last_update[0]['value'])) { |
| 1893 | 2194 | $last_update_day = $last_update[0]['value']; |
| 1894 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2195 | + } else { |
|
| 2196 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2197 | + } |
|
| 1895 | 2198 | $reset = false; |
| 1896 | 2199 | |
| 1897 | 2200 | // Count by filter |
| 1898 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2201 | + if ($globalDebug) { |
|
| 2202 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2203 | + } |
|
| 1899 | 2204 | $Spotter = new Spotter($this->db); |
| 1900 | 2205 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 1901 | 2206 | foreach ($alldata as $number) { |
@@ -1932,7 +2237,9 @@ discard block |
||
| 1932 | 2237 | $icao = $value['airport_departure_icao']; |
| 1933 | 2238 | if (isset($alldata[$icao])) { |
| 1934 | 2239 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1935 | - } else $alldata[$icao] = $value; |
|
| 2240 | + } else { |
|
| 2241 | + $alldata[$icao] = $value; |
|
| 2242 | + } |
|
| 1936 | 2243 | } |
| 1937 | 2244 | $count = array(); |
| 1938 | 2245 | foreach ($alldata as $key => $row) { |
@@ -1953,7 +2260,9 @@ discard block |
||
| 1953 | 2260 | $icao = $value['airport_arrival_icao']; |
| 1954 | 2261 | if (isset($alldata[$icao])) { |
| 1955 | 2262 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1956 | - } else $alldata[$icao] = $value; |
|
| 2263 | + } else { |
|
| 2264 | + $alldata[$icao] = $value; |
|
| 2265 | + } |
|
| 1957 | 2266 | } |
| 1958 | 2267 | $count = array(); |
| 1959 | 2268 | foreach ($alldata as $key => $row) { |
@@ -1967,7 +2276,9 @@ discard block |
||
| 1967 | 2276 | $alldata = $Spotter->countAllMonths($filter); |
| 1968 | 2277 | $lastyear = false; |
| 1969 | 2278 | foreach ($alldata as $number) { |
| 1970 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2279 | + if ($number['year_name'] != date('Y')) { |
|
| 2280 | + $lastyear = true; |
|
| 2281 | + } |
|
| 1971 | 2282 | $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); |
| 1972 | 2283 | } |
| 1973 | 2284 | $alldata = $Spotter->countAllMonthsOwners($filter); |